Skip to content

Fix Claude CLI reasoning effort fallback#6

Open
suninrain086 wants to merge 2 commits into
Menci:mainfrom
suninrain086:bug/fix-claude-cli-reasoning-effort
Open

Fix Claude CLI reasoning effort fallback#6
suninrain086 wants to merge 2 commits into
Menci:mainfrom
suninrain086:bug/fix-claude-cli-reasoning-effort

Conversation

@suninrain086
Copy link
Copy Markdown

@suninrain086 suninrain086 commented Apr 18, 2026

Problem

Using Claude CLI against the gateway initially failed with the following upstream Copilot error:

say hello in one sentence
  ⎿  API Error: 400 {"type":"error","error":{"type":"api_error","message":"Copilot API error: 400
     {\"error\":{\"message\":\"output_config.effort \\\"xhigh\\\" is not supported by model claude-opus-4.7; supported values:
     [medium]\",\"code\":\"invalid_reasoning_effort\"}}\n"}}

The root cause is that native /v1/messages requests can forward Claude CLI reasoning effort settings that Copilot rejects for a given model, and the gateway previously surfaced that 400 directly back to the client.

Summary

  • accept xhigh in Anthropic output_config.effort typing
  • detect native /v1/messages invalid_reasoning_effort responses from Copilot
  • retry the request with the nearest supported effort instead of surfacing a 400 back to Claude CLI
  • add regression coverage for the xhigh to medium fallback path

Testing

  • deno test
  • Result: 187 passed / 0 failed
  • Passed test suites:
    • src/app-control_test.ts
    • src/lib/models-cache_test.ts
    • src/lib/probe_test.ts
    • src/lib/sse-reassemble_test.ts
    • src/lib/translate/anthropic-to-responses-stream_test.ts
    • src/lib/translate/chat-to-messages_test.ts
    • src/lib/translate/messages-to-chat-stream_test.ts
    • src/lib/translate/messages-to-chat_test.ts
    • src/lib/translate/responses-request_test.ts
    • src/middleware/usage_test.ts
    • src/routes/chat-completions_test.ts
    • src/routes/count-tokens_test.ts
    • src/routes/data-transfer_test.ts
    • src/routes/messages_test.ts
    • src/routes/responses_test.ts
    • src/ui/dashboard_test.ts

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