Skip to main content
Back to how-to guides Use this pattern when you must set how many earlier messages a target agent receives in a handoff.

Concept

When a handoff creates a target thread, the runtime copies zero or more earlier messages into it. The HISTORY setting on the route controls the copy. The copy applies once, when the target thread starts. summary_only and auto also exist. They depend on SUMMARY. See Choose the right history strategy for handoff. If you omit HISTORY, the target receives the whole conversation. A project-level default, if your deployment sets one, replaces this default. Set HISTORY on every route so the behavior does not depend on a default. HISTORY controls messages. PASS and SET still send field values when HISTORY: none is set. See Pass specific fields between agents.

Minimal working example

A retail router has three specialists with different history needs. The order status agent needs only the order number. The returns agent needs recent context. The complaint agent needs the whole story. The specialists are short stand-ins in the same project. Replace them with your real agents. agents/retail-hub.agent.abl
agents/order-status-agent.agent.abl
agents/returns-agent.agent.abl
agents/complaint-agent.agent.abl
Variable sources:
  • order_id is a GATHER field of the router. Each route passes it.
  • return_reason and desired_outcome are gathered by the specialists.

How it works

The runtime resolves the history setting when it creates the target thread.
  1. full copies the calling agent’s conversation. It also adds customer messages that earlier child agents handled, so the target sees every customer turn. It leaves out messages from a child that gathered a sensitive field, such as a PIN.
  2. last_n takes the most recent messages of the calling agent’s conversation. A tool call and its result count as one unit. The runtime never splits the pair. If the newest unit is larger than the count, the target receives no messages.
  3. none copies no messages.
Rules that apply to every value:
  • The count is in messages, not customer turns. A user message and an assistant reply are two messages.
  • The setting applies when the target thread is created. If the route returns to a child that is still waiting, the runtime resumes that thread and keeps its own history. It does not apply HISTORY again.
  • When a returnable child returns control, the setting also decides what comes back. With full or last_n, the child’s replies join the parent conversation. With none, the child’s prompts stay out of the parent conversation.
  • The setting applies to remote targets. The runtime sends the selected messages as they are stored. See Preserve context when calling remote agents.
How the compiler reads the value: Use a positive count. A value that the compiler does not recognize silently gives the target the whole conversation.

Common variations

Write the window in a CONTEXT block

Inside CONTEXT, write the key in lowercase.
This is a section snippet. It needs the router GATHER field from the minimal example.

Send no history but brief the target

Pair none with a SUMMARY when the target needs a reason but not the transcript. See Pass a conversation summary during handoff. summary_only gives the same result and states the intent. Use full when the target must see the customer’s exact words, such as a complaint or a dispute. Check Minimize context for privacy and compliance first.

Verification

  1. Run the validator on all four files. Expect no errors and no warnings.
  2. Send an order status request after two other messages. Expect a handoff event to Order_Status_Agent.
  3. Ask the order status agent “What did I say earlier?” Expect it not to know.
  4. Send a return request. Expect the returns agent to know only the latest 6 messages.
  5. Send a complaint. Ask the complaint agent to restate your earlier messages. Expect it to know all of them.
  6. In the trace, open the first model call of each target agent. Count the earlier messages. The count must match the route setting.

Production readiness checklist

  • Every route sets HISTORY on purpose.
  • Every count is a positive number.
  • Each target works with the history it receives. Test the target with exactly that history.
  • Each target that gets none or last_n receives the facts it needs through PASS or SUMMARY.
  • The team reviewed each route that sends full for personal data in earlier messages.
  • Tests cover a long conversation and a conversation that is shorter than the window.

Common mistakes

Troubleshooting

Related articles: