Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for the OpenAI Responses API in the compat-oai plugin, allowing automatic routing for specific models and manual opt-in via openAI.responsesModel(). It also adds configuration schemas for parameters like previousResponseId, reasoningEffort, and reasoningSummary, along with comprehensive tests. Feedback on the changes suggests avoiding in-place mutation of the ref object in pinResponsesTransport to prevent side effects and preserve the this context, as well as defensively checking that body.reasoning is a non-null object before spreading it to handle potential non-object values.
73f6b6d to
d5eb1e0
Compare
d5eb1e0 to
a7ba1b8
Compare
8148836 to
5125bb5
Compare
5125bb5 to
29475bb
Compare
29475bb to
db1da1c
Compare
adesinah
left a comment
There was a problem hiding this comment.
Went through this against the ticket. The dispatch design holds up well — I checked the ref pinning against core's modelRef and it's correct for the right reasons (arrow functions so the unbound method extraction is safe, withVersion spreads the original options so the pin survives, withConfig replaces wholesale hence the re-injection). transport is also stripped on both wire builders, so nothing leaks to either API. Typecheck clean, 199 tests pass.
Five notes inline — mostly documentation rather than code changes.
| const use: ModelMiddleware[] | undefined = | ||
| params.responsesTransport && !ownConstrained | ||
| ? [ | ||
| (req, next) => | ||
| req.config?.transport === 'responses' | ||
| ? next(req) | ||
| : simulateConstrainedGeneration()(req, next), | ||
| ] | ||
| : undefined; |
There was a problem hiding this comment.
Worth pulling into Known Limitations: core runs use middleware before augmentWithContext(), but its own simulator runs after it. So a request carrying both context docs and an output schema now gets its injected text in a different order than before this PR.
You spotted this in 1aacfe0's commit message, but right now it only lives in a test comment. It's also wider than it looks — only MULTIMODAL_MODEL_INFO declares constrained, so this path covers ~19 of the 30 curated chat refs (all of GPT-5, GPT-4 non-multimodal, GPT-4-vision, GPT-3.5), not just edge cases.
Nothing to fix in code — core always prepends use — just worth saying out loud in the description.
| // dispatch runs. Models that never declared constrained still need that | ||
| // simulation on their Chat Completions requests, so the middleware below | ||
| // re-applies it for exactly those. | ||
| const ownConstrained = modelRef?.info?.supports?.constrained; |
There was a problem hiding this comment.
Latent, not actionable today: ownConstrained ?? 'all' treats any declared value as "no compensation needed".
If a dispatch-capable model ever declared constrained: 'no-tools', core's simulator would fire for tool-carrying requests on both transports — simulating a schema into the prompt on the Responses path, where it's supported natively.
Unreachable right now (only openai sets responsesTransport, and no chat info declares 'no-tools'), so just a note for whoever extends this.
| client, | ||
| pluginOptions, | ||
| modelRef, | ||
| responsesTransport: true, |
There was a problem hiding this comment.
listActions above builds its metadata straight from modelRef.info, so it never picks up the constrained: 'all' override that defineCompatOpenAIModel applies here. Net effect: gpt-5 lists as no-constrained but registers as 'all'.
The description calls the over-claim display-only, which is fair — just flagging that the two display surfaces disagree with each other.
| reasoningEffort: z | ||
| .enum(['none', 'minimal', 'low', 'medium', 'high', 'xhigh']) | ||
| .optional(), |
There was a problem hiding this comment.
The pinned SDK types ReasoningEffort as 'low' | 'medium' | 'high' | null, so none, minimal and xhigh sit outside its union and pass straight through to the wire.
Same risk class as the config.tools: [{ type: 'web_search' }] passthrough that's already on the live-smoke checklist — and since this landed in the last commit on the branch, it's had the least live exercise. Probably worth its own line on that checklist.
| ).rejects.toThrow(expect.objectContaining({ status: 'INVALID_ARGUMENT' })); | ||
| }); | ||
|
|
||
| test('rejects a near-miss transport value instead of serving it silently', async () => { |
There was a problem hiding this comment.
This drives openAIModelRunner directly, so it skips the action + config-schema layer. The scenario in the description is dotprompt frontmatter, which does go through that layer, and transport is a z.enum there.
An end-to-end case would pin down which layer actually rejects 'Responses' — otherwise a later change to config validation could relocate the behavior without failing anything.
db1da1c to
e4c8004
Compare
…sponses API on config opt-in A chat-registered model with responsesTransport enabled routes a request carrying config.transport === 'responses' to the Responses runner instead of throwing; the openAI plugin enables it for its Chat Completions models and declares the transport key on their config schema. Providers that do not opt in keep the INVALID_ARGUMENT rejection.
Typed ref pinned to the Responses transport for dual-transport models, with withConfig/withVersion re-wrapped so the pin survives chaining. Declares previousResponseId and reasoning effort/summary on the Responses config schema and maps them onto their wire fields, composing declared reasoning fields over any raw passthrough object.
…sponses wire frequencyPenalty, presencePenalty, logProbs and topLogProbs are declared on the dual-transport chat schema but have no Responses equivalent, so a working chat config opting into the Responses transport would 400 on the unknown camelCase fields. Drop them like topK/stopSequences, and pin the passthrough-wins precedence for previous_response_id.
GenerateResponse.raw is typed unknown, so the snippet did not compile.
…ive constrained support A dual-transport action inherits its chat info, and most of those infos leave supports.constrained unset, so genkit wrapped the action in simulateConstrainedGeneration and stripped output.schema into the prompt before the transport dispatch ran. Default constrained to 'all' on dispatch-capable registrations; both wire formats carry the schema natively.
…at path 'Responses' or any other near-miss was silently destructured off the wire and served over Chat Completions, while every other cell of the transport matrix throws. 'chat_completions' stays accepted as the explicit chat pin.
…-wins precedence as the reasoning fields The two mapped-key features introduced together resolved a declared-vs-raw collision in opposite directions; a declared key now wins both times, and a raw passthrough still works when the declared key is absent.
… plain chat path Defaulting supports.constrained at registration also disarmed core's simulator for Chat Completions requests, so legacy models that reject response_format json_schema (gpt-3.5, gpt-4) went from working simulation to an OpenAI 400 with no transport opt-in anywhere. Dispatch-capable models that never declared constrained now re-apply the simulator via middleware on every non-Responses request, and the chat schema's transport enum gains the 'chat_completions' value the builder accepts.
Simulation now runs before context augmentation, so with docs present the injected part order differs from the pre-dispatch chain.
… range Adds none and xhigh; xhigh is the flagship setting for the codex line this plugin registers, and the old enum could not express either. Also note the plugin timeout option for the slow pro models.
e4c8004 to
9284e7a
Compare
Part of #6002, closes #6005. Slice 3 of the Responses API stack, on top of #6148.
openAI.responsesModel(name): typed ref pinned toconfig: { transport: 'responses' };withConfig/withVersionre-wrapped so the pin survives chaining.config: { transport: 'responses' }to the Responses runner, so the opt-in also works from dotprompt frontmatter. Providers that do not opt in keep the INVALID_ARGUMENT rejection.previousResponseId,reasoningEffort,reasoningSummary, mapped toprevious_response_idandreasoning: { effort, summary }on the wire; declared fields compose over a raw passthroughreasoningobject.config.tools, stateless default and opting into server-side threading.Review hardening applied on top: chat-only config keys (
frequencyPenaltyetc.) are dropped from the Responses wire; dispatch-capable registrations defaultsupports.constrainedto'all'so an output schema reaches the Responses wire natively instead of being simulated into the prompt, while middleware re-applies the simulation to Chat Completions requests on models that never declared constrained support, keeping the plain chat path byte-identical to before; near-miss transport values (e.g.'Responses') throw INVALID_ARGUMENT instead of silently serving Chat Completions ('auto'stays accepted, as in #6006); declaredpreviousResponseIdwins over a rawprevious_response_idpassthrough, matching the reasoning fields.Tests: 230 passing. Stack rebased onto current main.
Known limitations, noted deliberately:
responsesModel()'s config type inherits.passthrough()from the schema, so unknown keys (typos included) compile and pass to the wire. Cost of keeping the passthrough escape hatch; consistent withmodel().previousResponseId/reasoningEffort/reasoningSummaryon it. Runtime honors them regardless; inherent to one action serving two transports.supports.constrained: 'all'even when their Chat Completions API would rejectresponse_format: json_schema; runtime behavior is correct on both transports (see above), the metadata over-claim is display-only.Live smoke checklist before un-drafting:
config.tools: [{ type: 'web_search' }]passthrough (type absent from the pinned SDK union).previousResponseIdunder the defaultstore: false(unverified whether OpenAI accepts the combination).responsesModel('gpt-4o')): confirms the reasoning-gated encrypted-content include.reasoningSummaryon (multi-turn, no tools): the assistant message replays without itsmsg_id next to an id-carrying reasoning item; one shape passed live already, ecosystem reports 400s on close variants.