Skip to content

fix(provider): guard reasoningSummary injection for @ai-sdk/openai-compatible providers#22352

Merged
rekram1-node merged 1 commit intoanomalyco:devfrom
nazarhnatyshen:fix/reasoning-summary-openai-compatible
Apr 14, 2026
Merged

fix(provider): guard reasoningSummary injection for @ai-sdk/openai-compatible providers#22352
rekram1-node merged 1 commit intoanomalyco:devfrom
nazarhnatyshen:fix/reasoning-summary-openai-compatible

Conversation

@nazarhnatyshen
Copy link
Copy Markdown
Contributor

@nazarhnatyshen nazarhnatyshen commented Apr 13, 2026

Issue for this PR

Closes #21237
Closes #18882

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The bug: When using @ai-sdk/openai-compatible provider (e.g. LiteLLM proxy) with any GPT-5.x model, opencode injects reasoningSummary: "auto" into every request. LiteLLM does not recognize this parameter and rejects the request:

litellm.BadRequestError: OpenAIException - Unknown parameter: 'reasoningSummary'

Why it happens: In options() (transform.ts:835), reasoningSummary is set unconditionally for any provider whose model.api.id contains "gpt-5". The variants() function in the same file already correctly guards reasoningSummary behind a provider check — only setting it for @ai-sdk/openai, @ai-sdk/azure, and @ai-sdk/github-copilot. The options() function lacks this guard.

The fix: Apply the same provider check in options() as already exists in variants(). reasoningSummary is now only injected for the three providers that translate it into the OpenAI Responses API format (reasoning.summary). For @ai-sdk/openai-compatible, the parameter is skipped entirely, which is correct — compatible proxies pass options directly in the request body without any translation.

How did you verify your code works?

Reproduced the error locally using a LiteLLM proxy with gpt-5.4 configured as an @ai-sdk/openai-compatible model. After this fix, the request succeeds without the Unknown parameter: 'reasoningSummary' error. Models on native @ai-sdk/openai continue to send reasoningSummary: "auto" as before.

Screenshots / recordings

N/A — no UI change

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@ai-sdk/openai-compatible proxies such as LiteLLM do not support the
reasoningSummary parameter and return an error when it is present:

  Unknown parameter: 'reasoningSummary'

The variants() function already correctly scopes reasoningSummary to
@ai-sdk/openai, @ai-sdk/azure, and @ai-sdk/github-copilot. Apply the
same guard in options() to be consistent.

Fixes anomalyco#22350, anomalyco#21237, anomalyco#18882
@github-actions github-actions bot added the needs:compliance This means the issue will auto-close after 2 hours. label Apr 13, 2026
@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate PRs Found

  1. PR fix: OpenCode was injecting reasoningSummary for GPT-5 and forwarding it through the openai-compatible chat adapter #14783: "fix: OpenCode was injecting reasoningSummary for GPT-5 and forwarding it through the openai-compatible chat adapter"

  2. PR fix(opencode): guard reasoningSummary for azure in options() #21575: "fix(opencode): guard reasoningSummary for azure in options()"

  3. PR fix(provider): avoid incompatible GPT-5 defaults and sanitize Gemini tool schemas #18915: "fix(provider): avoid incompatible GPT-5 defaults and sanitize Gemini tool schemas"

These PRs address the same underlying problem of guarding provider-specific parameters like reasoningSummary in the options() function for GPT-5 models.

@github-actions github-actions bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Apr 13, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@rekram1-node
Copy link
Copy Markdown
Collaborator

clean fix thxx

@rekram1-node rekram1-node merged commit c2403d0 into anomalyco:dev Apr 14, 2026
14 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants