Change providers to accept extra parameter#5080
Change providers to accept extra parameter#5080glGarg wants to merge 1 commit intomicrosoft:mainfrom
Conversation
|
This is how I set the thinking parameter in the config: |
There was a problem hiding this comment.
Pull request overview
Adds support for propagating a provider-specified extraBody object through BYOK model metadata/config so OpenAI-compatible endpoints can inject additional request fields when forming outbound requests.
Changes:
- Extend model metadata/types (
IChatModelInformation,BYOKModelCapabilities) to includeextraBody. - Plumb
extraBodyfrom Custom OAI model configuration into resolved model info. - Merge
extraBodyinto the outgoing OpenAI request body inOpenAIEndpoint.
Show a summary per file
| File | Description |
|---|---|
| src/platform/endpoint/common/endpointProvider.ts | Adds extraBody to chat model metadata shape. |
| src/extension/byok/vscode-node/customOAIProvider.ts | Allows custom OAI model configs to specify extraBody and forwards it into model metadata. |
| src/extension/byok/node/openAIEndpoint.ts | Merges extraBody into request payloads before sending. |
| src/extension/byok/common/byokProvider.ts | Carries extraBody through BYOK capability resolution into IChatModelInformation. |
Copilot's findings
- Files reviewed: 4/4 changed files
- Comments generated: 2
| // Merge extraBody fields (e.g. thinking: {type: "disabled"} for Fireworks) | ||
| if (this.modelMetadata.extraBody) { | ||
| Object.assign(body, this.modelMetadata.extraBody); | ||
| } |
There was a problem hiding this comment.
Object.assign(body, this.modelMetadata.extraBody) merges unvalidated, user-configurable data into the request body. This can lead to prototype pollution via keys like __proto__, constructor, or prototype, and also produces odd results if extraBody is not a plain object at runtime. Consider validating extraBody is a non-null plain object and filtering out dangerous keys before merging (or doing a safe merge helper).
| // Merge extraBody fields (e.g. thinking: {type: "disabled"} for Fireworks) | ||
| if (this.modelMetadata.extraBody) { | ||
| Object.assign(body, this.modelMetadata.extraBody); | ||
| } |
There was a problem hiding this comment.
New behavior merges modelMetadata.extraBody into outgoing requests, but there are existing unit tests for OpenAIEndpoint and none appear to assert this merge behavior. Please add coverage that verifies extraBody fields are applied (and, if you add validation/sanitization, that unsafe keys are ignored).
|
I was just looking for this feature and am glad it is being added, as we can then use reasoning in OpenRouter. @glGarg Would we put this in |
Adds support for passing custom fields via an
extraBodyproperty throughout the BYOK (Bring Your Own Key) model configuration and request pipeline. This enables providers to specify additional request parameters (such as special options for certain endpoints) in a flexible way. The changes ensure that these custom fields are available in model metadata, configuration, and are included in outgoing requests.