Repository navigation
Support the OpenAI Responses API - #67
Merged
Merged
Conversation
Anthropic: - Add `claude-fable-5-2`, `claude-opus-5-5`, `claude-sonnet-5-5`, `claude-haiku-5-5` and `claude-fable-5-1`; the default model is now `claude-sonnet-5-5`. - Omit sampling parameters for `claude-haiku-5-5`, which rejects non-default values; the existing prefixes already cover the point releases of Opus 5, Fable 5 and Sonnet 5. - Map the `refusal` stop reason to `kFinishReasonContentFilter` instead of `kFinishReasonStop`, both in responses and in streams. - Document that the newest models reject a forced tool choice. OpenAI: - Add `gpt-6.2-astra`, `gpt-6.2-sol`, `gpt-6.1-terra` and `gpt-6-luna`. - Treat the GPT-6 family as reasoning-first: omit sampling parameters, and send the lowest accepted `reasoning_effort` (`low`; `none` for `gpt-6-luna` and `gpt-6.1-terra`; GPT-6.2 rejects `none`). - Note the shutdown dates of `gpt-5-mini`, `gpt-5-nano`, `gpt-4.1`, `gpt-4.1-mini` and `gpt-5.4-nano`. - Keep `gpt-5.6` as the default: GPT-6 models support tool calling only through the Responses API, not Chat Completions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The GPT-6 models (`gpt-6.2-astra`, `gpt-6.2-sol`, `gpt-6.1-terra`, `gpt-6-luna`) call tools only through the Responses API (`POST /v1/responses`), while the SDK only spoke Chat Completions. `ai::openai::create_responses_client` (with the same overloads as `create_client`, plus `try_create_responses_client`) creates a client with its own request builder, response parser, and SSE stream for the Responses API. `create_client` stays on Chat Completions, which OpenAI-compatible providers implement; neither falls back to the other API. Requests are stateless (`store: false`). The `reasoning` items that a reasoning model returns with its function calls must be sent back with the tool outputs, so the parser returns the assistant turn in `response_messages` with its items in their original order, carrying the reasoning items (and the item IDs of the function calls) as a new `ProviderContentPart`, which other providers ignore. The multi-step coordinator feeds that turn back as is when it carries the tool calls. The lowest accepted reasoning effort and the sampling parameter omission are shared with the Chat Completions builder. Closes: #44 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ersion in a test Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 78171ee. Configure here.
… test The step stops at the tool calls, so `TestAssertions::assertSuccess`, which requires text, failed in CI. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`max_output_tokens` counts reasoning tokens too, so a response can end as `incomplete` after some of its function calls were completed. Those calls are now executed and answered (finish reason `tool_calls`), while the truncated ones (`status: incomplete`) are dropped instead of failing on their cut-off arguments. A terminal step no longer keeps a provider-built turn with tool calls in `response_messages`, because an unanswered `function_call` cannot be replayed. Reported by Cursor Bugbot in #67 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 27, 2026
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.

Adds support for the OpenAI Responses API (
POST /v1/responses). The current OpenAI frontier models (gpt-6.2-astra,gpt-6.2-sol,gpt-6.1-terra,gpt-6-luna) support tool calling only through the Responses API, and until now the SDK only spoke Chat Completions.Depends on: #64 (the model catalog update). This branch is based on it, so its commits show up here until it is merged.
Closes: #44
How you pick the API
ai::openai::create_responses_client(...)overloads, the same set ascreate_client, plustry_create_responses_client. They return anOpenAIResponsesClientwith its own request builder, response parser and SSE stream (openai_responses_*.cpp).create_clientstays on Chat Completions, so OpenAI-compatible providers (OpenRouter and others) keep working. Neither client falls back to the other API.models::kDefaultResponsesModel=kGpt62Sol.kDefaultModeldoes not change.Request mapping
inputitems: the messages,function_callitems andfunction_call_outputitems.systemgoes toinstructions.{type: "function", name, description, parameters, strict: false}.strict: falsekeeps the non-strict Chat Completions behaviour, because otherwise the API attempts strict mode.tool_choicemaps toauto,required,noneor{type: "function", name}.max_tokensbecomesmax_output_tokens.response_formatbecomestext.format, and the Chat Completionsjson_schemawrapper is flattened.reasoning.effortuses the lowest accepted effort. That helper and the rule that leaves outtemperature/top_pfor GPT-5/6 now live inopenai_model_traits.cppand are shared with the Chat Completions builder.frequency_penalty,presence_penaltyandseeddo not exist in the Responses API. They are left out and a warning is logged.How reasoning items are carried
store: false). In that mode the API returnsencrypted_contenton reasoning items by default, and the current docs callinclude: ["reasoning.encrypted_content"]legacy, so it is not sent.response_messageswith the output items in their original order:TextContentPart,ToolCallContentPart, and a newai::ProviderContentPart{provider, data}. That new part holds eachreasoningitem verbatim, plus thefc_...item ID of each function call.MultiStepCoordinatornow feeds back a provider-built turn as is when that turn contains the tool calls. Chat Completions and Anthropic never return tool calls inresponse_messages, so they behave as before.Response parsing and streaming
status/incomplete_details.reasonmap to the finish reason:max_output_tokens→ length,content_filter→ content filter, function calls →tool_calls.failedand other incomplete reasons become errors.input_tokens/output_tokens/total_tokens.response.output_text.delta,response.output_item.added/.done,response.function_call_arguments.delta/.done,response.completed/.incomplete/.failedanderror. A stream that ends without a terminal event is reported as an error.Tests, example, docs
tests/unit/openai_responses_test.cpp: request building, parsing, stream events, and a multi-step loop that checks the reasoning item reaches the follow-up request.tests/integration/openai_responses_integration_test.cpp: tool calling ongpt-6.2-sol, a multi-step tool loop with a follow-up turn, structured output, streaming text and tool calls.ToolCallingIntegrationTestsuite now also runs onopenai_responseswithgpt-6-luna.examples/openai_responses.cppand a README section.🤖 Generated with Claude Code
Note
Medium Risk
Touches core multi-step tool orchestration and adds a second OpenAI wire protocol; bugs could break GPT-6 tool loops or conversation replay, though Chat Completions and other providers are largely isolated.
Overview
Adds a parallel OpenAI integration path via
ai::openai::create_responses_client(and matching overloads /try_create_responses_client) that talks toPOST /v1/responsesinstead of Chat Completions. Chat Completionscreate_clientis unchanged; neither client falls back to the other, which keeps OpenAI-compatible providers on the existing API.The Responses stack includes dedicated client, request builder, response parser, and SSE stream code. Requests are stateless (
store: false), map SDK options to Responses fields (instructions,input,max_output_tokens,text.format, flat function tools withstrict: false), and sharedopenai_model_traitslogic for GPT-5/6 reasoning effort and sampling omissions.Reasoning replay for multi-step tools: responses can include
reasoningand function-call item IDs, stored in a newProviderContentParton assistant messages. The Responses builder replays them in order on follow-up requests;MultiStepCoordinatornow forwards provider-built assistant turns (with tool calls) verbatim instead of reconstructing them, so reasoning state survivesmax_stepsloops and manual continuations fromresponse_messages.Also refreshes model constants (GPT-6, Anthropic 5.5 defaults), Anthropic
refusal→ content-filter finish reasons, docs/exampleopenai_responses.cpp, and unit/integration tests for the Responses path.Reviewed by Cursor Bugbot for commit 99508bd. Bugbot is set up for automated code reviews on this repo. Configure here.