Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix(handoffs): preserve user messages containing history wrappers - #3815

#3815
Merged
seratch merged 2 commits into
openai:mainopenai/openai-agents-python:mainfrom
russeell:fix/preserve-user-handoff-wrapper-contentrusseell/openai-agents-python:fix/preserve-user-handoff-wrapper-contentCopy head branch name to clipboard
Jul 12, 2026
Merged

fix(handoffs): preserve user messages containing history wrappers#3815
seratch merged 2 commits into
openai:mainopenai/openai-agents-python:mainfrom
russeell:fix/preserve-user-handoff-wrapper-contentrusseell/openai-agents-python:fix/preserve-user-handoff-wrapper-contentCopy head branch name to clipboard

Conversation

@russeell

@russeell russeell commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Summary

This pull request fixes nested handoff history parsing so ordinary user messages containing the configured conversation wrapper strings are preserved instead of being interpreted as SDK-generated summaries.

nest_handoff_history() now requires both the assistant role and a complete SDK-generated summary envelope before extracting a nested transcript. The parser recognizes the current and legacy SDK preambles, requires the configured start wrapper in its expected position, and requires the message to end with the configured end wrapper.

Regression tests cover user and assistant messages containing parseable <CONVERSATION HISTORY> blocks with surrounding text and verify that the complete original items reach the history mapper unchanged. Existing SDK-generated summaries, legacy summaries, and custom conversation wrappers continue to flatten normally.

Test plan

  • bash .agents/skills/code-change-verification/scripts/run.sh
  • Result: format, lint, typecheck, and the complete test suite passed.
  • Focused coverage:
    • pytest tests/test_extension_filters.py -q (42 passed)
    • pytest tests/test_handoff_history_duplication.py -q (12 passed)

Issue number

Closes #3814

Checks

  • I've added new tests, if relevant
  • I've run .agents/skills/code-change-verification/scripts/run.sh
  • I've confirmed all verification steps pass
  • If using Codex, I've run /review before submitting this PR

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4b724e30d5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +229 to +230
if item.get("role") != "assistant":
return None

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Use more than role to identify generated history

This still treats any assistant message containing the wrapper pair as an SDK-generated summary. When callers provide or replay prior transcript items in input_history, an ordinary assistant response that literally includes a <CONVERSATION HISTORY> example is parsed and replaced with records such as 1. user: injected, dropping the surrounding assistant text before the mapper sees it. The parser needs a stronger signature than the public assistant role to avoid corrupting regular assistant history.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch. I’ll tighten the parser to require the complete SDK-generated summary envelope, not just the assistant role, and add regression coverage for ordinary assistant messages containing these wrappers.

@seratch seratch added this to the 0.18.x milestone Jul 12, 2026
@seratch
seratch enabled auto-merge (squash) July 12, 2026 21:55
@seratch
seratch merged commit b24d5dd into openai:main Jul 12, 2026
9 checks passed
@russeell
russeell deleted the fix/preserve-user-handoff-wrapper-content branch July 13, 2026 11:18
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.

Nested handoff history misclassifies user messages containing conversation wrappers

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.