fix: bundle of handoff and tracing fixes (#2258, #2151, #2094)#2645
fix: bundle of handoff and tracing fixes (#2258, #2151, #2094)#2645hkc5 wants to merge 1 commit intoopenai:mainfrom
Conversation
…penai#2094) This PR fixes three related issues: 1. Fix openai#2258: Exclude handoff-internal messages from to_input_list() When nest_handoff_history=True, the SDK creates internal assistant messages containing conversation history summaries. These messages should be excluded from to_input_list() as they are not valid API input items. - Add _is_handoff_internal_message() helper to detect handoff summary messages - Filter out handoff-internal messages in run_item_to_input_item() 2. Fix openai#2151: Add validation for nest_handoff_history with server-managed conversations Using nest_handoff_history=True with server-managed conversations (conversation_id, previous_response_id) is not supported and now raises a clear error. - Add validate_nest_handoff_history_settings() helper - Call validation before agent runner initialization 3. Fix openai#2094: Handle big integers in tracing data serialization Large integers (> 2^53-1) caused JSON serialization errors in tracing. Now converts them to strings to prevent data loss. - Add _sanitize_for_json() helper to recursively sanitize data - Apply sanitization in SpanExporter._process_data() All changes include comprehensive test coverage. Fixes openai#2258 Fixes openai#2151 Fixes openai#2094
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 76261d462f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if role != "assistant" or not isinstance(content, str): | ||
| return False | ||
| # Check for the conversation history markers | ||
| return "<CONVERSATION HISTORY>" in content |
There was a problem hiding this comment.
Narrow handoff-internal detection to synthetic summaries
This check treats any assistant message containing <CONVERSATION HISTORY> as internal and drops it, but run_item_to_input_item() runs for all transcripts (including when nest_handoff_history is disabled) and feeds to_input_list()/session replay paths. A normal model response that legitimately includes that marker text (for example when discussing XML-like tags) will now be silently removed from history, causing later turns to lose context. The filter should match the full synthetic handoff-summary signature (or a dedicated metadata flag) rather than a single substring.
Useful? React with 👍 / 👎.
This PR fixes three related issues:
1. Fix #2258: Exclude handoff-internal messages from to_input_list()
When
nest_handoff_history=True, the SDK creates internal assistant messages containing conversation history summaries. These messages should be excluded fromto_input_list()as they are not valid API input items.Changes:
_is_handoff_internal_message()helper to detect handoff summary messagesrun_item_to_input_item()2. Fix #2151: Add validation for nest_handoff_history with server-managed conversations
Using
nest_handoff_history=Truewith server-managed conversations (conversation_id,previous_response_id) is not supported and now raises a clear error.Changes:
validate_nest_handoff_history_settings()helper3. Fix #2094: Handle big integers in tracing data serialization
Large integers (> 2^53-1) caused JSON serialization errors in tracing. Now converts them to strings to prevent data loss.
Changes:
_sanitize_for_json()helper to recursively sanitize dataSpanExporter._process_data()Testing
All changes include comprehensive test coverage:
tests/test_issue_2258_handoff_internal_messages.py- 9 teststests/test_issue_2151_nest_handoff_server_managed.py- 7 teststests/test_issue_2094_big_int_tracing.py- 7 testsAll 23 new tests pass.
Fixes #2258
Fixes #2151
Fixes #2094