OpenAI Responses API model classes#1435
Merged
Merged
Conversation
Adds Responses and AsyncResponses classes that drive the OpenAI /v1/responses endpoint. The existing Chat / AsyncChat classes are unchanged because other plugins import them. gpt-5.5 (and gpt-5.5-2026-04-23) is now registered against Responses by default. Pass `-o chat_completions 1` to fall back to the older /v1/chat/completions code path. This is feature parity with the Chat path (text, tools, streaming, schema, reasoning_effort, verbosity, attachments, system prompts). Interleaved reasoning across tool round-trips is not exercised yet - encrypted reasoning items are accepted on the input side, but the plugin doesn't yet stash them on outgoing ReasoningParts.
When the Responses API returns a reasoning item alongside function calls, capture its opaque id + encrypted_content as provider_metadata on the resulting ReasoningPart. _build_responses_input already echoed that metadata back as a reasoning input item on the next turn - now the output side actually populates it. This preserves the model's hidden chain of thought across the tool round-trip. Without it, GPT-5-class models silently lose ~3% on SWE-bench (per OpenAI) when used with tools. Adds a dedicated VCR test that asserts the encrypted_content captured on the first turn appears verbatim in the second turn's outgoing request body.
The previous commit wired up encrypted_content round-trip but only tested that the data flows through correctly on a single tool round- trip. This adds a multi-turn cassette test that proves the full interleaved-reasoning capability: - Each turn produces fresh reasoning_tokens (not just the first) - Every prior reasoning block is round-tripped on every subsequent turn (the Nth turn echoes >= N-1 reasoning items) - ReasoningParts persisted on the assistant messages carry the same encrypted_content + id that gets sent back on the wire The puzzle is shaped so the model can't parallelize tool calls - each db_lookup result tells it the next key to use, forcing the model to think between calls. The recorded 4-turn chain shows reasoning_tokens of 45/98/196/17 across turns with reasoning items accumulating in every outgoing input. This is the GPT-5-class capability that Chat Completions can't deliver because it discards reasoning between turns.
Owner
Author
|
I had Codex run a manual testing run against the branch using Showboat, results here: https://gist.github.com/simonw/19cfef23659a939c12b1f8a6ccfe227a |
Owner
Author
|
Had Codex write and execute a script to test ALL the model IDs, which I used to help decide which ones to port to Responses: https://gist.github.com/simonw/4d1a1749475b092a328b92ae5f272e87 |
When building the `input` list for the OpenAI Responses API from prior
conversation turns, an assistant text-only turn was being serialized as:
{"role": "assistant",
"content": [{"type": "output_text", "text": "..."}]}
The openai-python SDK's EasyInputMessage shape uses a plain string for
this case, matching what a direct OpenAI Responses call would send. Use
the same shape so our history matches the SDK exactly, and add tests
covering both _build_responses_input and a two-turn response.reply()
flow.
simonw
added a commit
that referenced
this pull request
May 12, 2026
simonw
added a commit
that referenced
this pull request
May 12, 2026
7 tasks
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.
https://claude.ai/code/session_01S7UevnY7zKogbthSz4UXJv