Repository navigation
fix(responses): parse real Responses API output - #9
Merged
Merged
Conversation
theQuert
force-pushed
the
claude/responses-output-items
branch
from
October 7, 2026 00:22
bbdd4df to
3d9770f
Compare
Response validation rejected every real response: message parts are output_text (not text), and reasoning / function_call items sit beside the message in output. Model output_text and refusal parts, reasoning and function_call items, and keep any other item type as ResponseUnknownOutputItem. Output items are dispatched on their type, so a malformed known item still fails validation instead of degrading to the unknown type. Add Response.output_text and the queued / in_progress statuses. The legacy text / reasoning content parts are still accepted. Closes #2 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uy5vXsRpMhug7v3XwTMZHv
theQuert
force-pushed
the
claude/responses-output-items
branch
from
October 7, 2026 00:23
3d9770f to
831056c
Compare
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.
Closes #2.
client.responses.create()raisedValidationErroron every successful response. Real Responses API output differs from the old model in two ways:type: "output_text", withannotations.outputalso contains non-message items, such asreasoningandfunction_call.Changes in
apertis/types/responses.pyResponseOutputText(output_text,annotations)ResponseOutputRefusaltextandreasoningparts still validate.ResponseReasoningItemResponseFunctionToolCallResponseUnknownOutputItem, which usesextra="allow"and keeps any other item type (for exampleweb_search_call) with all its fields.typein abeforevalidator, not resolved by a plain union. A malformedmessagetherefore still fails validation instead of silently becoming an unknown item. This works on pydantic ≥2.0, so the dependency floor is unchanged.Response.output_textjoins the text parts of every message item.Response.statusacceptsqueuedandin_progress.in_progress.ResponseOutputMessageis an alias ofResponseOutput, so existing imports keep working.apertis.types.response.output_text. The oldoutput[0].content[0].textbreaks whenever a reasoning item comes first.Proof
TestResponsesOutputItems(sync and async):web_search_callitems, and each maps to its class.in_progressstatus parses.types/responses.py.Optional/Liststyle, which pydantic needs on Python 3.9.Not in scope: the input TypedDicts (
ResponseInputTextContentandResponseInputImageContent) still usetextandimage. The API names theseinput_textandinput_image. That needs a follow-up.🤖 Generated with Claude Code
https://claude.ai/code/session_01Uy5vXsRpMhug7v3XwTMZHv