Skip to content

Commit 0facc44

Browse files
committed
Force thinking off until the gateway accepts Claude Code's adaptive mode
Recent Claude Code sends `thinking: {type: "adaptive"}`; the gateway's Anthropic surface accepts only enabled|disabled, so the FIRST request of a fresh install 400s — verified live on this machine, on the default model. MAX_THINKING_TOKENS=0 is FORCED, not defaulted: an inherited value from the user's shell re-enables thinking and reproduces the 400 (also verified). Set in both launchers and in the --global env block. Remove once qbraid-api maps adaptive -> enabled (fix built and tested on branch feat/ai-system-role-messages there).
1 parent 281fdb2 commit 0facc44

4 files changed

Lines changed: 21 additions & 1 deletion

File tree

‎install.ps1‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,9 @@ if ($Global) {
357357
$envObj | Add-Member -NotePropertyName ANTHROPIC_AUTH_TOKEN -NotePropertyValue $ApiKey -Force
358358
$envObj | Add-Member -NotePropertyName ANTHROPIC_MODEL -NotePropertyValue $Model -Force
359359
$envObj | Add-Member -NotePropertyName ANTHROPIC_SMALL_FAST_MODEL -NotePropertyValue $Model -Force
360+
# The gateway rejects Claude Code's adaptive-thinking parameter; see the
361+
# launcher for the full note. Remove when the gateway accepts "adaptive".
362+
$envObj | Add-Member -NotePropertyName MAX_THINKING_TOKENS -NotePropertyValue '0' -Force
360363
$cfg | Add-Member -NotePropertyName env -NotePropertyValue $envObj -Force
361364
}
362365
Write-RawText $Settings ($cfg | ConvertTo-Json -Depth 100)

‎install.sh‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,8 @@ write_settings() {
481481
"ANTHROPIC_BASE_URL": "$GATEWAY_URL",
482482
"ANTHROPIC_AUTH_TOKEN": "$API_KEY",
483483
"ANTHROPIC_MODEL": "$MODEL",
484-
"ANTHROPIC_SMALL_FAST_MODEL": "$MODEL"
484+
"ANTHROPIC_SMALL_FAST_MODEL": "$MODEL",
485+
"MAX_THINKING_TOKENS": "0"
485486
},
486487
"statusLine": { "type": "command", "command": "'$statusline_cmd'" }
487488
}
@@ -510,6 +511,9 @@ if os.environ["QC_GLOBAL"] == "1":
510511
env["ANTHROPIC_AUTH_TOKEN"] = os.environ["QC_TOKEN"]
511512
env["ANTHROPIC_MODEL"] = os.environ["QC_MODEL"]
512513
env["ANTHROPIC_SMALL_FAST_MODEL"] = os.environ["QC_MODEL"]
514+
# The gateway rejects Claude Code's adaptive-thinking parameter; see the
515+
# launcher for the full note. Remove when the gateway accepts "adaptive".
516+
env["MAX_THINKING_TOKENS"] = "0"
513517
tmp = path + ".qbraid-code.tmp"
514518
with open(tmp, "w") as fh:
515519
json.dump(data, fh, indent=2)

‎qbraid-code‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,14 @@ command -v claude >/dev/null 2>&1 || {
128128
# accepts. ANTHROPIC_API_KEY would work too, but it makes Claude Code ask the
129129
# user to approve a custom API key on first run — a prompt with no good answer
130130
# for someone who just wants to start working.
131+
#
132+
# MAX_THINKING_TOKENS=0: recent Claude Code sends `thinking: {type: "adaptive"}`,
133+
# which the gateway's Anthropic surface rejects (it accepts enabled|disabled —
134+
# qbraid-api ai-request.validators.ts), turning every request into a 400.
135+
# FORCED, not defaulted: an inherited MAX_THINKING_TOKENS from the user's
136+
# shell re-enables thinking and turns every request into that 400. Remove the
137+
# whole line once the gateway accepts "adaptive".
138+
MAX_THINKING_TOKENS=0 \
131139
ANTHROPIC_BASE_URL="$BASE_URL" \
132140
ANTHROPIC_AUTH_TOKEN="$TOKEN" \
133141
ANTHROPIC_MODEL="$MODEL" \

‎qbraid-code.cmd‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ rem ANTHROPIC_AUTH_TOKEN sends `Authorization: Bearer <key>`, which the gateway
5050
rem accepts. ANTHROPIC_API_KEY would work too, but it makes Claude Code ask the
5151
rem user to approve a custom API key on first run - a prompt with no good answer
5252
rem for someone who just wants to start working.
53+
rem MAX_THINKING_TOKENS=0: recent Claude Code sends thinking type "adaptive",
54+
rem which the gateway rejects (accepts enabled/disabled only) - every request
55+
rem would 400. Forced: an inherited value re-enables thinking and breaks every
56+
rem request. Remove once the gateway accepts adaptive.
57+
set "MAX_THINKING_TOKENS=0"
5358
set "ANTHROPIC_BASE_URL=%QBRAID_CODE_BASE_URL%"
5459
set "ANTHROPIC_AUTH_TOKEN=%QBRAID_CODE_TOKEN%"
5560
set "ANTHROPIC_MODEL=%QBRAID_CODE_MODEL%"

0 commit comments

Comments
 (0)