Skip to content

fix byok-opencode: route non-OpenAI openai-protocol hosts to @ai-sdk/openai-compatible - #5344

Merged
AmyShang-alt merged 1 commit into
nexu-io:mainfrom
JackChen-me:fix/byok-opencode-deepseek-responses
Jul 10, 2026
Merged

fix byok-opencode: route non-OpenAI openai-protocol hosts to @ai-sdk/openai-compatible#5344
AmyShang-alt merged 1 commit into
nexu-io:mainfrom
JackChen-me:fix/byok-opencode-deepseek-responses

Conversation

@JackChen-me

Copy link
Copy Markdown
Contributor

Fixes #5338

Why

Hit this myself using Open Design with a DeepSeek key: the built-in DeepSeek BYOK preset (Settings β†’ Execution mode β†’ BYOK) 404s on the first run. The daemon's OpenCode BYOK path maps protocol openai straight to @ai-sdk/openai, which calls the OpenAI Responses API ({baseURL}/responses). DeepSeek (and other OpenAI-compatible providers) only serve /chat/completions, so the request 404s. The web path already treats these as OpenAI-compatible via isOpenAICompatible(...); the OpenCode path didn't, so the two disagreed. Full trace in #5338.

What users will see

BYOK custom models on the openai protocol pointed at a non-api.openai.com endpoint (the DeepSeek preset, vLLM, and other OpenAI-compatible chat-completions hosts) now work instead of failing with Not Found. Real OpenAI (api.openai.com) is unchanged.

Surface area

  • Default behavior change β€” for the openai BYOK protocol, non-api.openai.com hosts now use @ai-sdk/openai-compatible (/chat/completions) instead of @ai-sdk/openai (/responses). This fixes DeepSeek and also switches vLLM / local OpenAI-compatible servers to the chat-completions package (which is what they actually serve). api.openai.com keeps using @ai-sdk/openai.

Screenshots

n/a β€” no UI.

Bug fix verification

  • Test path that reproduces the bug: apps/daemon/tests/runtimes/byok-opencode.test.ts β†’ routes OpenAI-protocol BYOK with a non-OpenAI base URL to the OpenAI-compatible provider package
  • Did the test go red on main and green on this branch? yes β€” on main the DeepSeek case returns @ai-sdk/openai; after the fix it returns @ai-sdk/openai-compatible. The existing vLLM test is updated to match (it is openai-compatible by nature β€” the test is even named that).

Validation

Ran under Node 24 / pnpm 10.33.2:

  • pnpm --filter @open-design/daemon exec vitest run -c vitest.config.ts tests/runtimes/byok-opencode.test.ts β†’ 13/13 pass (new test red before the source change, green after).
  • pnpm --filter @open-design/daemon run typecheck β†’ pass.
  • pnpm guard β†’ 78/78 pass.

Note: connection-test.test.ts / chat-route.test.ts have a few pre-existing failures on a clean main in my local sandbox β€” flaky withFakeAgent process-spawn flows, unrelated to this change (which only affects buildProviderEntry's provider-package selection). Left to CI.

Optional follow-ups (kept out of this PR for one-concern): (1) the proxy path normalizes DeepSeek to /v1/chat/completions; this path resolves to /chat/completions (both are served by DeepSeek) β€” happy to add a /v1 normalization for parity if preferred; (2) surfacing the actual failing request URL instead of a bare Not Found.

…openai-compatible

The BYOK OpenCode path mapped protocol "openai" straight to @ai-sdk/openai (Responses API /responses) for every host, so providers that only serve /chat/completions (DeepSeek, vLLM, etc.) 404 on /responses. Route non-api.openai.com openai-protocol hosts to @ai-sdk/openai-compatible; real OpenAI stays on @ai-sdk/openai. Adds a DeepSeek regression test and corrects the vLLM test to openai-compatible.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@lefarcen
lefarcen requested a review from nettee July 9, 2026 08:29
@lefarcen lefarcen added size/S PR changes 20-100 lines risk/high High risk: apps/desktop, daemon, auth, migration, workflows, package deps type/bugfix Bug fix labels Jul 9, 2026
@lefarcen lefarcen added the needs-validation Runtime change detected; needs human or /explore agent validation. label Jul 9, 2026
@lefarcen

lefarcen commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Hey @JackChen-me β€” thanks for the sharp write-up and the tight repro here.

Because this changes a live BYOK runtime path that users hit directly, I’m marking it for QA once the PR is merge-ready. Nothing needed from you right now; we’ll follow up here after validation.

@nettee nettee left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JackChen-me I reviewed the BYOK OpenCode provider routing change and the updated daemon regression coverage. The split keeps api.openai.com on @ai-sdk/openai while moving non-OpenAI openai protocol hosts, including the corrected vLLM case, onto @ai-sdk/openai-compatible, which matches the existing product behavior and directly covers the DeepSeek 404 reported in #5338. Nice focused fix.

πŸ” Powered by Looper Β· runner=reviewer Β· agent=codex Β· An autonomous AI dev team for your GitHub repos.

@lefarcen
lefarcen requested a review from AmyShang-alt July 9, 2026 08:40
@AmyShang-alt

Copy link
Copy Markdown
Contributor

QA validation passed for PR #5344 at head e674e44.\n\nEvidence checked:\n- Focused daemon regression test passed: tests/runtimes/byok-opencode.test.ts 13/13.\n- Daemon typecheck passed.\n- pnpm guard passed: 78/78.\n- Local PR runtime launched via tools-dev: web on 127.0.0.1:17545, daemon on 127.0.0.1:17544.\n- BYOK OpenCode with official OpenAI model gpt-5.5 succeeded, confirming the real OpenAI path is unchanged.\n- BYOK OpenCode with non-OpenAI OpenAI-compatible provider via OpenRouter + deepseek/deepseek-chat succeeded, confirming the fixed compatible-provider path works in a real run.\n- Additional local mock endpoint validation showed non-OpenAI host requests went to /chat/completions and did not hit /responses.\n\nConclusion: acceptance passed. The previous needs-validation risk is covered; this PR is ready from QA.

@AmyShang-alt AmyShang-alt added validated Runtime change validated (via /explore Pass or manual QA). and removed needs-validation Runtime change detected; needs human or /explore agent validation. labels Jul 10, 2026

@AmyShang-alt AmyShang-alt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved after QA validation. Automated checks passed, local PR runtime validation succeeded for official OpenAI BYOK, and non-OpenAI OpenAI-compatible BYOK via OpenRouter + deepseek/deepseek-chat succeeded.

@AmyShang-alt
AmyShang-alt added this pull request to the merge queue Jul 10, 2026
Merged via the queue into nexu-io:main with commit afec21a Jul 10, 2026
31 checks passed
@open-design-bot

Copy link
Copy Markdown
Contributor

πŸŽ‰ πŸ“‘ You just leveled up to Giotto

Giotto card for @JackChen-me

πŸ“‘ ✨ Sending steady signals.

πŸ™Œ Your contributions are sending a clear signal across the network: you care about making Open Design better. Keep transmitting.

πŸ’› Thanks for helping Open Design move forward. Keep building in the open. πŸš€


πŸ“Š Rank #111 among 400+ contributors

πŸ”— Share on X (English) Β· εˆ†δΊ«εˆ° XοΌˆδΈ­ζ–‡οΌ‰

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk/high High risk: apps/desktop, daemon, auth, migration, workflows, package deps size/S PR changes 20-100 lines type/bugfix Bug fix validated Runtime change validated (via /explore Pass or manual QA).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Built-in "DeepSeek" BYOK option 404s out of the box: openai protocol hits the Responses API, DeepSeek only serves /chat/completions

4 participants