Skip to main content
Additional histories allow you to include multiple separate conversation histories within a single trajectory. This powerful feature enables training of agents with non-linear conversation flows, such as agents that call sub-agents or compact their message history periodically.

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. The additional_histories feature addresses this need. Each trajectory can contain:
  • A primary messages_and_choices sequence (the main conversation)
  • An optional list of additional_histories, where each history contains its own messages_and_choices and optional tools

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:
  1. The main history (from messages_and_choices) is tokenized first
  2. Each additional history is tokenized separately
  3. The training weight is distributed across all tokenized results
  4. Each history maintains its own context and token boundaries

Data Structure

The History class structure:
The Trajectory class with additional histories:

Implementation Guide

Creating a Trajectory with Additional Histories

Current Limitations

The RULER reward function does not currently support trajectories with additional histories. If you attempt to use RULER with additional_histories, it will raise an error. Support for this feature in RULER is planned for a future release.
  • Models - Model-specific considerations including Qwen 3