diff --git a/install.ps1 b/install.ps1 index e8d89d8..0884242 100644 --- a/install.ps1 +++ b/install.ps1 @@ -357,6 +357,9 @@ if ($Global) { $envObj | Add-Member -NotePropertyName ANTHROPIC_AUTH_TOKEN -NotePropertyValue $ApiKey -Force $envObj | Add-Member -NotePropertyName ANTHROPIC_MODEL -NotePropertyValue $Model -Force $envObj | Add-Member -NotePropertyName ANTHROPIC_SMALL_FAST_MODEL -NotePropertyValue $Model -Force + # The gateway rejects Claude Code's adaptive-thinking parameter; see the + # launcher for the full note. Remove when the gateway accepts "adaptive". + $envObj | Add-Member -NotePropertyName MAX_THINKING_TOKENS -NotePropertyValue '0' -Force $cfg | Add-Member -NotePropertyName env -NotePropertyValue $envObj -Force } Write-RawText $Settings ($cfg | ConvertTo-Json -Depth 100) diff --git a/install.sh b/install.sh index c20dec9..8a4e663 100755 --- a/install.sh +++ b/install.sh @@ -481,7 +481,8 @@ write_settings() { "ANTHROPIC_BASE_URL": "$GATEWAY_URL", "ANTHROPIC_AUTH_TOKEN": "$API_KEY", "ANTHROPIC_MODEL": "$MODEL", - "ANTHROPIC_SMALL_FAST_MODEL": "$MODEL" + "ANTHROPIC_SMALL_FAST_MODEL": "$MODEL", + "MAX_THINKING_TOKENS": "0" }, "statusLine": { "type": "command", "command": "'$statusline_cmd'" } } @@ -510,6 +511,9 @@ if os.environ["QC_GLOBAL"] == "1": env["ANTHROPIC_AUTH_TOKEN"] = os.environ["QC_TOKEN"] env["ANTHROPIC_MODEL"] = os.environ["QC_MODEL"] env["ANTHROPIC_SMALL_FAST_MODEL"] = os.environ["QC_MODEL"] + # The gateway rejects Claude Code's adaptive-thinking parameter; see the + # launcher for the full note. Remove when the gateway accepts "adaptive". + env["MAX_THINKING_TOKENS"] = "0" tmp = path + ".qbraid-code.tmp" with open(tmp, "w") as fh: json.dump(data, fh, indent=2) diff --git a/qbraid-code b/qbraid-code index 7df53d0..6be6a31 100755 --- a/qbraid-code +++ b/qbraid-code @@ -128,6 +128,14 @@ command -v claude >/dev/null 2>&1 || { # accepts. ANTHROPIC_API_KEY would work too, but it makes Claude Code ask the # user to approve a custom API key on first run — a prompt with no good answer # for someone who just wants to start working. +# +# MAX_THINKING_TOKENS=0: recent Claude Code sends `thinking: {type: "adaptive"}`, +# which the gateway's Anthropic surface rejects (it accepts enabled|disabled — +# qbraid-api ai-request.validators.ts), turning every request into a 400. +# FORCED, not defaulted: an inherited MAX_THINKING_TOKENS from the user's +# shell re-enables thinking and turns every request into that 400. Remove the +# whole line once the gateway accepts "adaptive". +MAX_THINKING_TOKENS=0 \ ANTHROPIC_BASE_URL="$BASE_URL" \ ANTHROPIC_AUTH_TOKEN="$TOKEN" \ ANTHROPIC_MODEL="$MODEL" \ diff --git a/qbraid-code.cmd b/qbraid-code.cmd index 7073698..e8ae7b9 100644 --- a/qbraid-code.cmd +++ b/qbraid-code.cmd @@ -50,6 +50,11 @@ rem ANTHROPIC_AUTH_TOKEN sends `Authorization: Bearer `, which the gateway rem accepts. ANTHROPIC_API_KEY would work too, but it makes Claude Code ask the rem user to approve a custom API key on first run - a prompt with no good answer rem for someone who just wants to start working. +rem MAX_THINKING_TOKENS=0: recent Claude Code sends thinking type "adaptive", +rem which the gateway rejects (accepts enabled/disabled only) - every request +rem would 400. Forced: an inherited value re-enables thinking and breaks every +rem request. Remove once the gateway accepts adaptive. +set "MAX_THINKING_TOKENS=0" set "ANTHROPIC_BASE_URL=%QBRAID_CODE_BASE_URL%" set "ANTHROPIC_AUTH_TOKEN=%QBRAID_CODE_TOKEN%" set "ANTHROPIC_MODEL=%QBRAID_CODE_MODEL%"