fix(handoffs): summarize all tool item types in nest_handoff_history#3412
Closed
adityasingh2400 wants to merge 1 commit into
Closed
fix(handoffs): summarize all tool item types in nest_handoff_history#3412adityasingh2400 wants to merge 1 commit into
adityasingh2400 wants to merge 1 commit into
Conversation
The _SUMMARY_ONLY_INPUT_TYPES set in src/agents/handoffs/history.py only filtered out function_call, function_call_output, and reasoning from forwarded items after nest_handoff_history built its conversation summary. Hosted, computer, shell, apply_patch, custom, MCP, file/web/ tool search, code interpreter, and image generation tool calls and outputs were therefore included in the JSON summary *and* re-forwarded as raw RunItems, duplicating them for the next agent. Mirror the comprehensive tool-type list maintained by the sibling extensions.handoff_filters._remove_tool_types_from_input filter so every tool kind the SDK can emit (including the recently audited hosted_tool_call from openai#3386 and the custom_tool_call from openai#3095) is summarized once and dropped from the forwarded items. Tests in tests/test_extension_filters.py cover the pre_handoff_items and input_items (mapped from new_items) paths.
Member
|
This may be relevant for some use cases, but it could be a breaking change for existing apps. Thus, we won't make this change. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extends the precedent set by #3095 (custom_tool_call) and #3386 (hosted_tool_call) into the sibling helper that powers
RunConfig.nest_handoff_history. The_SUMMARY_ONLY_INPUT_TYPESset insrc/agents/handoffs/history.py:30-37only markedfunction_call,function_call_output, andreasoningas summarized-only. Every other tool kind the SDK can emit (computer, file_search, web_search, mcp_*, code_interpreter, image_generation, local_shell, shell, apply_patch, custom, hosted, tool_search) was included in the JSON conversation summary built by_format_transcript_item_jsonand re-forwarded verbatim as a rawRunIteminpre_handoff_items/input_items, duplicating it for the next agent.Repro (passes pre-fix, fails post-fix without the new set entries):
The fix expands
_SUMMARY_ONLY_INPUT_TYPESto mirror the comprehensive list maintained byextensions.handoff_filters._remove_tool_types_from_input. The two lists exist for adjacent reasons (one forremove_all_tools, one fornest_handoff_history) but should agree on what counts as a tool item; the comment block documents that intent.Test plan
test_nest_handoff_history_filters_hosted_tool_pre_itemsandtest_nest_handoff_history_filters_hosted_tool_new_itemsintests/test_extension_filters.pycover every hosted-tool call and output type for both thepre_handoff_itemsandnew_items→input_itemspaths.uv run pytest tests/test_extension_filters.py— 42 passed (was 40, +2 regressions).uv run pytest tests/test_agent_runner.py tests/test_agent_runner_streamed.py -k handoff_history— 7 passed.make format,make lint,uv run mypy src/agents/handoffs/history.py tests/test_extension_filters.py— clean.Issue number
N/A — found while auditing for the same gap that #3095 and #3386 fixed in the sibling
remove_all_toolsfilter.