Skip to content

fix(commandcode): strip thinking suffix from params.model - #3408

Open
naufalmalikr wants to merge 1 commit into
decolua:masterfrom
naufalmalikr:fix/commandcode-thinking-suffix
Open

fix(commandcode): strip thinking suffix from params.model#3408
naufalmalikr wants to merge 1 commit into
decolua:masterfrom
naufalmalikr:fix/commandcode-thinking-suffix

Conversation

@naufalmalikr

Copy link
Copy Markdown

Problem

Requests to the CommandCode provider fail with a 403 when the client sends a thinking-level suffix on the model id:

HTTP 403: [commandcode/gpt-5.6-luna(max)] [403]: {"success":false,"error":{"code":"FORBIDDEN","status":403,"message":"Model/provider not recognized: anthropic:gpt-5.6-luna(max)"}}

The upstream /alpha/generate API reads the model from params.model and rejects unknown ids — a gpt-5.6-luna(max) is not a valid upstream model, so the gateway falls back to an anthropic: family guess and 403s.

Root cause

  • getModelUpstreamId (providerModels.js) intentionally re-appends the client's thinking suffix (max) so applyThinking can consume it.
  • chatCore.js strips the suffix from the top-level translatedBody.model before dispatch.
  • But the commandcode translator copies the model into the nested params.model verbatim — the suffix leaks to the wire.

Proof from a real failing request (requestDetails):

"params": { "model": "gpt-5.6-luna(max)" },   // leaked suffix
"model":  "gpt-5.6-luna"                        // stripped (top-level only)

Fix

Strip the thinking suffix when setting params.model in openaiToCommandCodeRequest (reusing stripThinkingSuffix from thinkingUnified.js). The suffix is still consumed by applyThinking for the thinking override; only the wire model is cleaned.

Verified: plain gpt-5.6-luna succeeds upstream; gpt-5.6-luna(max) was the only difference.

Tests

  • 3 new unit tests in tests/unit/openai-to-commandcode.test.js (suffix stripped for plain and family-prefixed ids, plain ids untouched).
  • npx vitest run unit/openai-to-commandcode.test.js → 14/14 pass.
  • Related suites (commandcode-to-openai, thinking-unified, thinking max-clamp, gemini-cursor-commandcode bugs) → no regressions (5 expected fails are pre-existing it.fails).
  • npx eslint clean.

Upstream reads params.model and rejects unknown ids. The client thinking
suffix "model(level)" was copied verbatim into params.model (chatCore
strips only the top-level model field), so requests like
gpt-5.6-luna(max) failed with 403 "Model/provider not recognized:
anthropic:gpt-5.6-luna(max)".

Strip the suffix in the commandcode translator; applyThinking still
consumes the suffix for the thinking override before the body is sent.
afandiaziz added a commit to afandiaziz/9router that referenced this pull request Aug 20, 2026
afandiaziz added a commit to afandiaziz/9router that referenced this pull request Aug 20, 2026
…/security/providers

Verified via trial-merge + per-PR tests (84 pass/0 fail), OAuth baseline
identical, providers baseline additive-only (+reasonix/ovh/joycode/openmodel).

PRs: decolua#3411 decolua#3370 decolua#3369 decolua#3368 decolua#3393 decolua#3366 decolua#3395 decolua#3382 decolua#3359 decolua#3408 decolua#3357
     decolua#3379 decolua#3380 decolua#3381 decolua#3396 decolua#3338

Co-Authored-By: Claude <noreply@anthropic.com>
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.

1 participant