fix: handle reasoning model output in OpenAI Responses API#68
Merged
Conversation
Reasoning models (e.g. gpt-oss-120b) return a "reasoning" output block before the "message" output, both using "output_text" content type. extractResponsesOutputText now skips reasoning outputs and prefers the message output. As defense-in-depth, both parseSectionClassifiedResponse and parseCriticResponse fall back to extracting the outermost JSON array when the response contains chain-of-thought preamble. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
type: "reasoning"output blocks in OpenAI Responses API extraction — reasoning models (e.g.gpt-oss-120b) return chain-of-thought in a separate output block before the actual message, both usingoutput_textcontent typeextractJSONArrayfallback toparseSectionClassifiedResponseandparseCriticResponsefor OpenAI-compatible endpoints that ignorejson_schemastructured output constraintsTest Coverage
All new code paths have test coverage:
TestExtractJSONArray— 5 subtests (pure array, reasoning prefix, reasoning both sides, no array, only open bracket)TestParseSectionClassifiedResponse_WithReasoning— end-to-end parsing with chain-of-thought preambleTestExtractResponsesOutputText_ReasoningWithOutputText— reasoning output withoutput_textcontent type is skippedPre-Landing Review
No issues found.
Documentation
tls_skip_verifyto YAML config example, env var example, and config descriptiontls_skip_verifyto Configuration section under NetworkTest plan
🤖 Generated with Claude Code