Skip to content

Conversation

@jhills20
Copy link
Contributor

Summary

  • add a nest_handoff_history flag to RunConfig and call a new helper that condenses the prior transcript into a developer-role summary when handing off
  • update the default handoff path, docs, and helper library so that the developer summary is produced automatically unless a custom filter overrides it
  • expand the handoff-focused tests to cover the new behavior (including helper unit tests) and update existing expectations

Testing

  • uv run pytest tests/test_extension_filters.py
  • uv run pytest tests/test_agent_runner.py -k handoff
  • uv run pytest tests/test_agent_runner_streamed.py -k handoff

https://chatgpt.com/codex/tasks/task_i_68ff73bda0f4832496f3d1fa9103905f

@seratch seratch added feature:core enhancement New feature or request labels Oct 28, 2025
@seratch seratch requested a review from rm-openai October 28, 2025 04:38
Copy link
Collaborator

@rm-openai rm-openai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of kaz's feedback seems right. In addition, I'd say two major things:

  1. This setting should be on the Handoff object
  2. Since you're updating the default, this is a breaking change, so please update the changelog.

@seratch seratch mentioned this pull request Oct 30, 2025
@seratch seratch added this to the 0.6.x milestone Nov 5, 2025
@jhills20 jhills20 closed this Nov 7, 2025
@jhills20 jhills20 reopened this Nov 8, 2025
Copy link
Contributor Author

@jhills20 jhills20 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved to Handoff, added handoff history .py file for non extension parts of handoff filter, added changelog

Comment on lines +28 to +29
- By default handoff history is now packaged into a single assistant message instead of exposing the raw user/assistant turns, giving downstream agents a concise, predictable recap
- The existing single-message handoff transcript now by default starts with "For context, here is the conversation so far between the user and the previous agent:" before the `<CONVERSATION HISTORY>` block, so downstream agents get a clearly labeled recap
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we;ve release 0.5.0 so you'll need to move this to a 0.6.0 section

Comment on lines +1019 to +1027
filter_name = getattr(input_filter, "__qualname__", repr(input_filter))
from_agent = getattr(agent, "name", agent.__class__.__name__)
to_agent = getattr(new_agent, "name", new_agent.__class__.__name__)
logger.debug(
"Filtering handoff inputs with %s for %s -> %s",
filter_name,
from_agent,
to_agent,
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weird syntax - also can you use f-strings and get rid of getattr?

Comment on lines +20 to +24
__all__ = [
"remove_all_tools",
"nest_handoff_history",
"default_handoff_history_mapper",
]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can remove this, not super useful


When a handoff occurs, it's as though the new agent takes over the conversation, and gets to see the entire previous conversation history. If you want to change this, you can set an [`input_filter`][agents.handoffs.Handoff.input_filter]. An input filter is a function that receives the existing input via a [`HandoffInputData`][agents.handoffs.HandoffInputData], and must return a new `HandoffInputData`.

By default the runner now collapses the prior transcript into a single assistant summary message (see [`RunConfig.nest_handoff_history`][agents.run.RunConfig.nest_handoff_history]). The summary appears inside a `<CONVERSATION HISTORY>` block that keeps appending new turns when multiple handoffs happen during the same run. You can provide your own mapping function via [`RunConfig.handoff_history_mapper`][agents.run.RunConfig.handoff_history_mapper] to replace the generated message without writing a full `input_filter`. That default only applies when neither the handoff nor the run supplies an explicit `input_filter`, so existing code that already customizes the payload (including the examples in this repository) keeps its current behavior without changes. You can override the nesting behaviour for a single handoff by passing `nest_handoff_history=True` or `False` to [`handoff(...)`][agents.handoffs.handoff], which sets [`Handoff.nest_handoff_history`][agents.handoffs.Handoff.nest_handoff_history]. If you just need to change the wrapper text for the generated summary, call [`set_conversation_history_wrappers`][agents.handoffs.set_conversation_history_wrappers] (and optionally [`reset_conversation_history_wrappers`][agents.handoffs.reset_conversation_history_wrappers]) before running your agents.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to make merging the code changes easier, can you make a separate pull request for document changes? with this, we can merge code first, and then merge document changes after thre release including the changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants