FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: OpenCode was injecting reasoningSummary for GPT-5 and forwarding it through the openai-compatible chat adapter by ayaz · Pull Request #14783 · anomalyco/opencode · GitHub

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

Open
ayaz wants to merge 1 commit into
anomalyco:devfrom
ayaz:ayaz/openai-reasoning-bug
Open

fix: OpenCode was injecting reasoningSummary for GPT-5 and forwarding it through the openai-compatible chat adapter#14783
ayaz wants to merge 1 commit into
anomalyco:devfrom
ayaz:ayaz/openai-reasoning-bug

Conversation

ayaz commented Feb 23, 2026
edited
Loading

Copy link
Copy Markdown

Issue for this PR

Fixes #13546

Type of change

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

What does this PR do?

OpenCode was injecting reasoningSummary for GPT-5 and forwarding it through the openai-compatible chat adapter, which broke OpenAI-compatible /chat/completions requests with Unknown parameter: reasoningSummary. This keeps reasoning enabled (reasoningEffort) while blocking reasoningSummary for openai-compatible providers and adds regression tests.

How did you verify your code works?

I bun install'd the binary, and bun run dev with my custom opencode config which broke with the unpatched version. It worked fine.

Checklist

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

…hrough the openai-compatible chat adapter, which broke OpenAI-compatible /chat/completions requests with Unknown parameter: reasoningSummary. This keeps reasoning enabled (reasoningEffort) while blocking reasoningSummary for openai-compatible providers and adds regression tests.
github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. needs:title labels Feb 23, 2026

Copy link
Copy Markdown
Contributor

Hey! Your PR title OpenCode was injecting reasoningSummary for GPT-5 and forwarding it through the openai-compatible chat adapter, which broke OpenAI-compatible /chat/completions requests with Unknown parameter: reasoningSummary. This keeps reasoning enabled (reasoningEffort) while blocking reasoningSummary for openai-compatible providers and adds regression tests. doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

ayaz changed the title OpenCode was injecting reasoningSummary for GPT-5 and forwarding it through the openai-compatible chat adapter, which broke OpenAI-compatible /chat/completions requests with Unknown parameter: reasoningSummary. This keeps reasoning enabled (reasoningEffort) while blocking reasoningSummary for openai-compatible providers and adds regression tests. fix: OpenCode was injecting reasoningSummary for GPT-5 and forwarding it through the openai-compatible chat adapter Feb 23, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

github-actions Bot removed needs:issue needs:compliance This means the issue will auto-close after 2 hours. labels Feb 23, 2026

Copy link
Copy Markdown
Contributor

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

ayaz marked this pull request as ready for review February 23, 2026 12:39

Copy link
Copy Markdown

Looking forward to this one. Let me know how I can help.

ayaz commented Feb 25, 2026

Copy link
Copy Markdown
Author

Thanks @shahrin014 I'm just waiting for what the next step will be. The PR is ready otherwise.

Copy link
Copy Markdown

@ayaz
Firstly I am not sure how PRs get accepted for merge in this project but this test seems to be failing.
https://github.com/anomalyco/opencode/actions/runs/22306293891/job/64526408292?pr=14783
It seems to be completely unrelated to your change.

Not sure if the issue is intermittent and rerunning the test will work. I don't have authorization to rerun it either because I am not a contributor. 🙏

ayaz requested a review from adamdotdevin as a code owner February 26, 2026 04:14

ayaz commented Feb 26, 2026

Copy link
Copy Markdown
Author

Looks like these are due to regressions in the Windows unit and e2e tests introduced outside this PR (and before this PR was created). I have tried to patch them, and while I was able to fix the Windows unit test, the Windows e2e test has more issues that fail it.

ayaz force-pushed the ayaz/openai-reasoning-bug branch from d46838a to a9608ad Compare February 26, 2026 05:25

ayaz commented Feb 26, 2026

Copy link
Copy Markdown
Author

I reverted my test-fix changes back to the original scope of the PR. The failing Windows tests, which aren't caused by this PR, will have to be fixed separately.

Copy link
Copy Markdown

@ayaz
Hmm, I just checked actually,
https://opencode.ai/docs/providers/#custom-provider
There is no other way to set a custom provider apart from using openai-compatible.

Some providers serve anthropic models, which actually support this parameter. The only way (workaround?) is to use openai-compatible

What are your thoughts in making this configurable?
Any other suggestions?

shahrin014 commented Feb 26, 2026
edited
Loading

Copy link
Copy Markdown

Just to add as well judging by the documentation:
https://opencode.ai/docs/providers/#optional-configs

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "helicone": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Helicone",
      "options": {
        "baseURL": "https://ai-gateway.helicone.ai",
      },
      "models": {
        "gpt-4o": {
          // Model ID (from Helicone's model directory page)
          "name": "GPT-4o", // Your own custom name for the model
        },
        "claude-sonnet-4-20250514": {
          "name": "Claude Sonnet 4",
        },
      },
    },
  },
}

Would this change break helicone's claude service?

CC: @dailyherold

ayaz commented Feb 26, 2026

Copy link
Copy Markdown
Author

@shahrin014 As far as I understand it, OpenCode makes use of OpenAI ChatCompletions API for servicing these requests, and does the conversion between formats (such as from OpenAI to Anthropic) behind the scenes. I don't see anything in the code that suggest this would cause any issues if a Claude model is used with Helicone.

I think the reason they use openai-compatible as the custom provider is because it's the format that's popularly used across, so it'd have made sense to support it this way. Every other gateway/middleman provider I have used generally follows a similar approach of providing an OpenAI compatible interface, and taking care of translations behind the scenes if non-OpenAI compatible models are being invoked.

vbuccigrossi pushed a commit to vbuccigrossi/opencode that referenced this pull request Mar 7, 2026
, anomalyco#15183, anomalyco#14783)

- anomalyco#13502: Retry on timeout errors instead of failing — DOMException
  TimeoutError now marked as retryable
- anomalyco#12585: Generate fallback tool call IDs for providers (NVIDIA NIM,
  GLM, Bedrock, Chutes) that omit the id field in streaming responses
- anomalyco#15183: Prevent literal NUL file creation on POSIX — redirects to
  /dev/null instead of writing "nul" files
- anomalyco#14783: Block reasoningSummary injection for GPT-5 through
  openai-compatible adapter (keeps reasoningEffort, strips summary)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

scratchmex commented Mar 7, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

Checking for != Openai compatible doesn't seem to be the behaviour we want, just a hack for "not chat API". We should detect "chat API" or "responses API" usage in other way

Dulani commented Mar 17, 2026

Copy link
Copy Markdown

My agent and I have been running a local build with a nearly identical fix for about a month, routing four gpt-5 models (nano, mini, 5.2, 5.2-codex) through an @ai-sdk/openai-compatible provider pointed at an Azure OpenAI gateway. This PR's approach works correctly in practice — reasoningSummary is suppressed for chat completions, and reasoningEffort (which Chat Completions does support) is preserved.

Re @scratchmex's point about detecting the wire API type rather than checking the npm package: I think that's a good direction for a follow-up enhancement — something like making transform.ts aware of the existing useResponses option so it can distinguish chat from responses providers explicitly. But checking api.npm is consistent with how sdkKey(), textVerbosity, and the copilot SDK routing already work in this codebase. Making the perfect the enemy of the good here means people keep hitting this bug — it's been reported since September 2025 (#2387, #5421, #12113, #13546) and affects users on LiteLLM, Azure gateways, and Helicone.

The second defense layer in the chat model class (the UNSUPPORTED_CHAT_COMPLETIONS_OPTIONS set) is a nice touch — even if transform.ts misses a case in the future, the model class itself strips unsupported options before sending.

Would be happy to help with a useResponses-aware enhancement as a separate PR after this lands.

Disclosure: This comment was drafted with AI assistance and reviewed/edited by a human before posting.

Copy link
Copy Markdown

any fix regarding this issue guys? i still face sam issue

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Custom OpenAI-compatible provider errors with "Unknown parameter: 'reasoningSummary'" for GPT-5 series models

5 participants


Back | FazBrowse Home | New Git URL