Skip to main content

Session Management in AgentOps

AgentOps supports running multiple concurrent traces (sessions) without any special mode switching or restrictions. The modern approach uses the trace-based API with start_trace() and end_trace(), while legacy session functions remain available for backwards compatibility.

Modern Trace-Based Approach

The recommended way to manage sessions is using the trace-based API:

Legacy Session API

For backwards compatibility, the legacy session functions are still available:

Managing Multiple Traces

Starting Traces

You can start multiple traces concurrently without any restrictions:

Ending Traces

End traces individually or all at once:

Using Decorators

The modern approach also supports decorators for automatic trace management:

LLM Call Tracking

LLM calls are automatically tracked when using the modern instrumentation. No special handling is needed for multiple concurrent traces:

Migration from Legacy Multi-Session Mode

If you’re migrating from older AgentOps versions that had multi-session mode restrictions:
  1. Remove multi-session mode checks - These are no longer needed
  2. Update to trace-based API - Use start_trace() and end_trace() for new code
  3. Simplify LLM tracking - Automatic instrumentation handles LLM calls without special session assignment
  4. Use decorators - Consider using @trace, @agent, and @tool decorators for cleaner code

Examples

Concurrent Traces Example

Create multiple concurrent traces and manage them independently

REST API

Create a REST server with FastAPI and manage traces per request