fix: extend output_text to include code_interpreter and shell output#2925
Open
roli-lpci wants to merge 1 commit intoopenai:mainfrom
Open
fix: extend output_text to include code_interpreter and shell output#2925roli-lpci wants to merge 1 commit intoopenai:mainfrom
roli-lpci wants to merge 1 commit intoopenai:mainfrom
Conversation
The `output_text` convenience property only aggregated text from `message` output items, silently returning an empty string when the response contained `code_interpreter_call` or `shell_call_output` items with textual results. This extends the property to also collect: - Log output from `code_interpreter_call` items (OutputLogs.logs) - Stdout from `shell_call_output` items (Output.stdout) Adds 6 regression tests covering: mixed output, code-interpreter-only, null outputs, image-only outputs, and shell call output. Fixes openai#2870 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
The
output_textconvenience property only aggregates text frommessageoutput items. When a response containscode_interpreter_callorshell_call_outputitems with textual results but no accompanying message,output_textreturns an empty string.This extends the property to also collect:
code_interpreter_call: log output fromOutputLogs.logsshell_call_output: stdout fromOutput.stdoutRoot Cause
Despite the report in #2870, the SDK code between v2.19.0 and v2.20.0 is unchanged for this codepath —
output_texthas always only traversedmessage-type output items:Code interpreter results live in
code_interpreter_callitems viaoutputs[].logs, which is a separate data path thatoutput_textnever traversed. This is a feature gap in the convenience property, not a deserialization regression.Changes
src/openai/types/responses/response.py— Extendoutput_textto also iteratecode_interpreter_calllog outputs andshell_call_outputstdout. Updated docstring to reflect the expanded aggregation.tests/lib/responses/test_responses.py— 6 new tests:outputs: null(graceful empty string)Scope note
This PR covers
code_interpreter_callandshell_call_outputas the two tool types with unambiguous textual output. Other tool types (mcp_call,apply_patch_call_output) could be added in a follow-up if desired.Testing
All 110
tests/lib/tests pass, including the 6 new ones.Fixes #2870