What are Additional Histories?
In ART, a trajectory typically contains a single sequence of messages representing the agent’s conversation. However, some advanced use cases require training on multiple related but separate conversations within the same trajectory context. Theadditional_histories feature addresses this need.
Each trajectory can contain:
- A primary
messages_and_choicessequence (the main conversation) - An optional list of
additional_histories, where each history contains its ownmessages_and_choicesand optionaltools
Why Use Additional Histories?
Note: for simplicity and ease of use, we’ve used normal “assistant” messages
in the examples below. In reality, you’ll want to use
Choice objects to
represent assistant messages that should be trained on, as seen in the example
notebooks.1. Preserving Special Tokens in Multi-Turn Conversations
Some models, like Qwen 3, use chat templates that remove special tokens (such as<think>) from previous turns in multi-turn conversations. This can interfere with training when you want the model to learn from its thinking process across all turns.
By splitting each turn into a separate history, you can preserve these tokens for training:
2. Training Agents That Call Sub-Agents
When an agent delegates work to sub-agents, each sub-agent conversation can be stored as an additional history:3. History Compaction and Summarization
For long-running agents that periodically compress their conversation history:How It Works
Tokenization Process
When a trajectory with additional histories is tokenized:- The main history (from
messages_and_choices) is tokenized first - Each additional history is tokenized separately
- The training weight is distributed across all tokenized results
- Each history maintains its own context and token boundaries
Data Structure
TheHistory class structure:
Trajectory class with additional histories:
Implementation Guide
Creating a Trajectory with Additional Histories
Current Limitations
Related Topics
- Models - Model-specific considerations including Qwen 3