Concepts
Sessions
Effectively manage sessions in your agent workflow
Automatic Session Management
The simplest way to create and manage sessions is to use the init
function with automatic session management:
This approach:
- Creates a session automatically when you initialize the SDK
- Tracks all events in the context of this session
- Manages the session throughout the lifecycle of your application
Manual Session Creation
For more control, you can disable automatic session creation and start sessions manually:
Manual session management is useful when:
- You want to control exactly when session tracking begins
- You need to associate different sessions with different sets of tags
- Your application has distinct workflows that should be tracked separately
Using the Session Decorator
As an alternative to the methods above, you can use the @session
decorator to create a session for a specific function:
Session State
Every session has an associated state that includes:
- Session ID: A unique identifier
- Start Time: When the session began
- Tags: Labels associated with the session
- Events: All events recorded during the session
This state is automatically managed by AgentOps and synchronized with the dashboard.
Session Context
Sessions create a context for all event recording. When an event is recorded:
- It’s associated with the current active session
- It’s automatically included in the session’s timeline
- It inherits the session’s tags for filtering and analysis
Viewing Sessions in the Dashboard
The AgentOps dashboard provides several views for analyzing your sessions:
- Session List: Overview of all sessions with filtering options
- Session Details: In-depth view of a single session
- Timeline View: Chronological display of all events in a session
- Tree View: Hierarchical representation of agents, operations, and events
- Analytics: Aggregated metrics across sessions
Best Practices
- Start sessions at logical boundaries in your application workflow
- Use descriptive session names to easily identify them in the dashboard
- Apply consistent tags to group related sessions
- Use fewer, longer sessions rather than many short ones for better analysis
- Use automatic session management unless you have specific needs for manual control