Skip to content

fix(handoffs): avoid orphan reasoning items when nesting handoff history#2504

Closed
OiPunk wants to merge 1 commit intoopenai:mainfrom
OiPunk:codex/openai-agents-2503-nest-handoff-reasoning
Closed

fix(handoffs): avoid orphan reasoning items when nesting handoff history#2504
OiPunk wants to merge 1 commit intoopenai:mainfrom
OiPunk:codex/openai-agents-2503-nest-handoff-reasoning

Conversation

@OiPunk
Copy link
Contributor

@OiPunk OiPunk commented Feb 17, 2026

Summary

  • fix nest_handoff_history so standalone reasoning items are summarized but not forwarded as raw input items
  • keep new_items unchanged for session persistence while filtering only next-agent model input
  • add regression tests for reasoning filtering and tool-approval filtering paths

Why

With RunConfig(nest_handoff_history=True), forwarding a raw reasoning item can produce Responses API 400 errors (...reasoning... without its required following item).

Changes

  • add "reasoning" to _SUMMARY_ONLY_INPUT_TYPES in src/agents/handoffs/history.py
  • add tests in tests/test_extension_filters.py:
    • test_nest_handoff_history_does_not_forward_raw_reasoning_items
    • test_nest_handoff_history_skips_tool_approval_items
    • test_parse_summary_line_rejects_blank_lines

Validation

  • uv run --with ruff ruff check src/agents/handoffs/history.py tests/test_extension_filters.py
  • uv run --with mypy mypy src/agents/handoffs/history.py
  • env -u ALL_PROXY -u all_proxy -u HTTPS_PROXY -u https_proxy -u HTTP_PROXY -u http_proxy -u NO_PROXY -u no_proxy uv run --with pytest pytest tests/test_extension_filters.py -q
  • env -u ALL_PROXY -u all_proxy -u HTTPS_PROXY -u https_proxy -u HTTP_PROXY -u http_proxy -u NO_PROXY -u no_proxy uv run --with pytest pytest tests/test_run_step_processing.py -q
  • env -u ALL_PROXY -u all_proxy -u HTTPS_PROXY -u https_proxy -u HTTP_PROXY -u http_proxy -u NO_PROXY -u no_proxy uv run --with pytest --with pytest-cov pytest tests/test_extension_filters.py tests/test_run_step_processing.py --cov=agents.handoffs.history --cov-report=term-missing -q
    • coverage: src/agents/handoffs/history.py = 100%

Fixes #2503

@seratch
Copy link
Member

seratch commented Feb 17, 2026

Closing this in favor of #2508

@seratch seratch closed this Feb 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: handoff with nest_handoff_history=True can send orphan reasoning item and return 400

2 participants