fix(provider): propagate options.extraBody for openai-compatible providers#26233
Open
jeremy-newhouse wants to merge 1 commit intoanomalyco:devfrom
Open
fix(provider): propagate options.extraBody for openai-compatible providers#26233jeremy-newhouse wants to merge 1 commit intoanomalyco:devfrom
jeremy-newhouse wants to merge 1 commit intoanomalyco:devfrom
Conversation
…iders opencode silently drops `provider.<id>.options.extraBody` from opencode.json, so users of OpenAI-compatible servers (vLLM, SGLang, NVIDIA NIM, direct DashScope) cannot pass server-specific chat-completions body fields like `chat_template_kwargs`. Concrete impact (vLLM + qwen3): without `chat_template_kwargs.enable_thinking=false` on the wire, qwen3 produces pathological reasoning that consumes its output budget and emits EOS without finishing tool calls; the agent loop dies mid-flight. The harness today ships a Python wire proxy as a stopgap. Fix: read `input.providerOptions.extraBody` in `ProviderTransform.options()` and merge into `result`. The fields then ride the same path as the existing alibaba-cn `enable_thinking=true` hardcoding (transform.ts:1040-1047) — `providerOptions()` wraps the result under the SDK-recognized key for `@ai-sdk/openai-compatible`, and the Vercel AI SDK serializes it onto the request body. The alibaba-cn block proves this routing reaches the wire (DashScope users rely on it). Also adds a typed `extraBody` field on the `Info.options` schema for documentation and IDE completion. The existing rest record on `Info.options` already permits the field; this purely improves discoverability. Tests cover: positive case (qwen3 enable_thinking), nested objects, undefined / null / array no-ops, non-clobbering of unrelated fields, and explicit precedence (user config wins over hardcoded blocks). Closes anomalyco#13584 Closes anomalyco#23995 Closes anomalyco#24264
8551430 to
cd2b14b
Compare
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
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.
Issue for this PR
Closes #13584
Closes #23995
Closes #24264
Type of change
What does this PR do?
provider.<id>.options.extraBodyfromopencode.jsonis silently dropped —extraBodyis permitted by the schema's rest record but never read. Users of OpenAI-compatible servers (vLLM, NVIDIA NIM, SGLang, direct DashScope) can't pass server-specific body fields likechat_template_kwargsthat those endpoints need.The fix: read
input.providerOptions.extraBodyinProviderTransform.options()andObject.assignit intoresult. Routing then matches the existingalibaba-cnenable_thinking=trueblock attransform.ts:1040— which is proof the path reaches the wire (DashScope users rely on it). Also adds a typedextraBodyfield toInfo.optionsfor IDE completion.Pattern matches #25573 (cf-ai-gateway fix); avoids the larger surface change in #6761 (closed without merge).
How did you verify your code works?
7 new unit tests in
transform.test.ts: positive case, nested objects,undefined/null/array no-ops, non-clobbering of unrelated fields, explicit precedence (userextraBodyoverrides hardcoded blocks). Full provider suite passes (291/291).End-to-end against vLLM serving
Qwen3.6-35B-A3B(--reasoning-parser qwen3 --tool-call-parser qwen3_coder):extraBody.chat_template_kwargs.enable_thinking=falseinopencode.json: agent loop dies — model emits EOS without finishing tool calls becauseenable_thinking=falsenever reaches vLLM and qwen3 produces runaway reasoning.Screenshots / recordings
n/a — not a UI change
Checklist