-
Notifications
You must be signed in to change notification settings - Fork 264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: reorganize session management into dedicated components #631
Conversation
Split session logic into dedicated components for better separation of concerns and maintainability: - Move session code to dedicated session/ module - Split Session class into: - Session: Data container with minimal public API - SessionManager: Handles lifecycle and state management - SessionApi: Handles API communication - SessionTelemetry: Manages event recording and OTEL integration Key fixes: - Proper UUID and timestamp serialization in events - Consistent API key header handling - Correct token cost formatting in analytics - Proper session ID inheritance - Tags conversion and validation - Event counts type handling This refactor improves code organization while maintaining backward compatibility through the session/__init__.py module. Signed-off-by: Teo <[email protected]>
6a8e7af
to
eb072db
Compare
@the-praxs can you please review and run manual (integration) tests? 🙏 |
#632 is failing for both #633 is failing for this PR which means we need to have the edge test cases for such issues. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left comments on the failing tests for CrewAI and Autogen.
We need to fix the issue with CrewAI failing in this PR. Then we have to fix Autogen in a new PR since it's occurring on main
too.
After these I think the PR is ready to be tested and merged, should the tests pass!
Overview
This PR refactors the session management code to improve maintainability, testability, and separation of concerns, historically proposed in #486. The main changes include:
Session
class into smaller, focused componentsKey Changes
1. New Module Structure
Created a dedicated
session
package with clear component separation:session.py
- Core session data container and public APImanager.py
- Session lifecycle and state managementapi.py
- API communication layertelemetry.py
- OpenTelemetry integrationregistry.py
- Active sessions tracking2. Improved Error Event Handling
ErrorEvent
properly inherit fromEvent
base class (booyah! @areibman)3. Client Simplification
Implementation Details
Session Components
Each component has a single responsibility: