Skip to main content
Product agents use sessions to keep each conversation thread separate and continue it across requests. A stable session_id groups related runs, while user_id associates the thread with the person using your product.
support_agent.py
The database stores both runs under support-thread-7. On the second run, add_history_to_context=True loads messages from the same session into the model context.

IDs and Persistence

An ID labels a run or thread. A configured database provides durable storage.

Persistence and Model Context

Session storage and chat history serve separate purposes: add_history_to_context defaults to False. Configure it when the model needs conversational continuity. See Chat History for message selection and storage controls.

Multi-User Applications

Use IDs from your application instead of sharing one generated session across customers: A user can have multiple session IDs, such as separate support tickets or chat tabs. Reuse a session ID only for runs that belong to the same thread.

Workflow Sessions

Agent and team sessions store conversational runs and messages. Workflow sessions track pipeline executions with their inputs, outputs, and state. See Workflow Sessions for workflow-specific behavior.

Next Steps

Session Management

Assign IDs and manage agent and team sessions.

History Management

Control which previous messages enter model context.

Session Summaries

Condense long conversations to manage context size.