Skip to main content
Teams with storage enabled automatically have access to the run history of the session (also called the “conversation history” or “chat history”).
For all forms of session history, you need to have a database assigned to the team. See Storage for more details.
We can give the Team access to the chat history in the following ways:
  • Team-Level History:
    • You can set add_history_to_context=True and num_history_runs=5 to add the inputs and responses from the last 5 runs automatically to every request sent to the team leader.
    • You can be more granular about how many messages to add to include in the list sent to the model, by setting num_history_messages.
    • You can set read_chat_history=True to provide a get_chat_history() tool to your team allowing it to read any message in the entire chat history.
    • You can set read_tool_call_history=True to provide a get_tool_call_history() tool to your team allowing it to read tool calls in reverse chronological order.
    • You can enable search_session_history to allow searching through previous sessions.
    • You can set add_team_history_to_members=True and num_team_history_runs=5 to add the inputs and responses from the last 5 runs (that is the team-level inputs and responses) automatically to every message sent to the team members.
  • Member-Level History:
    • You can also enable add_history_to_context for individual team members. This will only add the inputs and outputs for that member to all requests sent to that member, giving it access to its own history.
Working with team history can be tricky. Experiment with the above settings to find the best fit for your use case. See the History Reference for help on how to use the different history features.

History Reference

Start with Team History in Context for basic conversation continuity:
Database Requirement: All history features require a database configured on the team. See Storage for setup.
Performance Tip: More history = larger context = slower and costlier requests. Start with num_history_runs=3 and increase only if needed.

Add history to the team context

To add the history of the conversation to the context, you can set add_history_to_context=True. This will add the inputs and responses from the last 3 runs (that is the default) to the context of the team leader. You can change the number of runs by setting num_history_runs=n where n is the number of runs to include. Take a look at this example:
See the full example in the Add history to the team context documentation.

Send team history to members

To send the team history to the members, you can set add_team_history_to_members=True. This will send the inputs and responses from the last 3 team-level runs (that is the default) to the members when tasks are delegated to them. You can change the number of runs by setting num_team_history_runs=n where n is the number of runs to include. Take a look at this example:
In the above example the team history is sent to members who would not otherwise have access to it. That allows the Spanish agent to recall the information that was originally sent to the German agent. add_team_history_to_members=True appends team history to the task sent to a team member, for example:
See the full example in the Team History for Members documentation.

Share member interactions with other members

All interactions with team members are automatically recorded. This includes the member name, the task that was given to the member, and the response from the member. This is only available during a single run. If you want members to have access to all interactions that has happened during the current run, you can set share_member_interactions=True. See the example below and how information is shared between members during the run.
share_member_interactions=True appends interaction details to the task sent to a team member, for example:
See the full example in the Share Member Interactions documentation.

Read the chat history

To read the chat history, you can set read_chat_history=True. This will provide a get_chat_history() tool to your team allowing it to read any message in the entire chat history.

Search the session history

In some scenarios, you might want to fetch messages from across multiple sessions to provide context or continuity in conversations. To enable fetching messages from the last N sessions, you need to use the following flags:
  • search_session_history: Set this to True to allow searching through previous sessions.
  • num_history_sessions: Specify the number of past sessions to include in the search. In the example below, it is set to 2 to include only the last 2 sessions.
It’s advisable to keep this number low (2 or 3), as a larger number might fill up the context length of the model, potentially leading to performance issues. Here’s an example of searching through the last 2 sessions:
session_history_search.py

Developer Resources