Documentation Index
Fetch the complete documentation index at: https://reagent-ai.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Sessions
A session is a context manager that records everything an agent does during one run. Every tool call, every LLM response, every result — captured as a structured trace.Session parameters
| Parameter | Type | Description |
|---|---|---|
name | str | Identifies this session (used for storage and golden baselines) |
trace_dir | str | Directory for saving trace files (default: .reagent) |
golden | bool | If True, saves the trace as a golden baseline |
parent_trace_id | str | Links this session to a parent session (for multi-agent chains) |
handoff_context | dict | Structured data received from the parent agent |
metadata | dict | Arbitrary metadata attached to the trace |
Lifecycle
- Enter —
with reagent_flow.session(...) as s:sets the session as the active context - Record — tool calls and results are logged via
log_llm_callandlog_tool_result - Exit — the session finalizes the trace and saves it to disk
- Assert — after exiting, call assertion methods on the closed session
Traces
A trace is the structured record of a session. It contains a list of turns, each with an LLM call and its resulting tool executions.Storage
Traces are saved as JSON files:- Regular traces:
{trace_dir}/{name}.trace.json - Golden baselines:
{trace_dir}/golden/{name}.trace.json
Manual logging
When using framework adapters (OpenAI, LangChain, etc.), logging happens automatically. For manual instrumentation or testing:Thread safety
Sessions use Python’scontextvars for thread-safe tracking. Each thread or async task sees its own active session — no global mutable state.