add_history_to_context=True, previous messages are automatically included in every request.
Enable Chat History
Setadd_history_to_context=True to include previous messages in every run:
Chat history requires a database. Without one, there’s nothing to retrieve.
Control History Size
More history means more tokens. Use these parameters to control what gets included:On-Demand History Access
Instead of always including history, let the agent decide when to look it up:get_chat_history() when it needs context, rather than having history in every request. Useful for analytics, auditing, or when most queries don’t need prior context.
Cross-Session History
Search across multiple sessions for context that spans conversations:Programmatic Access
Retrieve history directly in your code:Team History
Teams support additional history sharing between members:add_team_history_to_members=True, member agents see the full team conversation, not just their own interactions.
Workflow History
Workflows useadd_workflow_history_to_steps to pass previous run results to steps:
Workflow history passes previous workflow outputs to steps, not conversation messages. See Workflow Sessions for details.
Choosing a Pattern
Developer Resources
- Session Storage - What gets stored and how to retrieve it.
- AgentSession reference
- TeamSession reference