litellm - ✅(Solved) Fix [Bug]: complexity router not working for claude code after auto model switching from GLM-5 to Anthropic models [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
BerriAI/litellm#26005Fetched 2026-04-19 15:06:23
View on GitHub
Comments
0
Participants
1
Timeline
6
Reactions
0
Author
Participants
Timeline (top)
labeled ×4cross-referenced ×1referenced ×1

Error Message

⎿  API Error: 400 {"error":{"message":"{"type":"error","error":{"type":"invalid_request_error","message":"messages.1.content.0.thinking.signature.str: Input should be a valid string"},"request_id":"req_vrtx_011CaB4qJPWdYMoM8yyQUQ5C"}. Received Model Group=claude-sonnet-4-6\nAvailable Model Group Fallbacks=['claude-sonnet-4-6-asia-southeast1', 'claude-sonnet-4-6-europe-west1', 'claude-sonnet-4-6-us-east5']\nError doing the fallback: {"type":"error","error":{"type":"invalid_request_error","message":"messages.1.content.0.thinking.signature.str: Input should be a valid string"},"request_id":"req_vrtx_011CaB4tJa1Wbc6fK5efVVc4"}","type":"None","param":"None","code":"400"}}

Fix Action

Fixed

PR fix notes

PR #26059: fix(anthropic): detect invalid thinking signatures from Vertex AI error format

Description (problem / solution / changelog)

When the complexity router switches from a non-Anthropic model (e.g. Gemini) to a Claude model via Vertex AI, the Anthropic API returns a 400 error about invalid thinking.signature fields. The existing retry mechanism in is_anthropic_invalid_thinking_signature_error did not detect this error because it required the keyword "block" which is absent from the Vertex AI error format.

Root cause: The error detection function matched the direct Anthropic API format (Invalid \signature` in `thinking` block) but not the Vertex AI format (messages.N.content.M.thinking.signature.str: Input should be a valid string`). Without detection, the automatic retry that strips thinking blocks never fired.

Fix: Remove the "block" keyword requirement. The combination of "invalid" + "signature" + "thinking" is already specific enough — no other Anthropic 400 errors combine all three.

Fixes #26005

Changed files

  • litellm/llms/anthropic/common_utils.py (modified, +3/-3)
  • tests/test_litellm/llms/anthropic/test_anthropic_common_utils.py (modified, +14/-0)

Code Example

- model_name: smart-router
        litellm_params:
          model: auto_router/complexity_router
          complexity_router_config:
            tiers:
              SIMPLE: vertex_ai/glm-5
              MEDIUM: vertex_ai/glm-5
              COMPLEX: claude-sonnet-4-6
              REASONING: claude-opus-4-6

---

⎿  API Error: 400 {"error":{"message":"{\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"messages.1.content.0.thinking.signature.str: Input
     should be a valid string\"},\"request_id\":\"req_vrtx_011CaB4qJPWdYMoM8yyQUQ5C\"}. Received Model Group=claude-sonnet-4-6\nAvailable Model Group
     Fallbacks=['claude-sonnet-4-6-asia-southeast1', 'claude-sonnet-4-6-europe-west1', 'claude-sonnet-4-6-us-east5']\nError doing the fallback:
     {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"messages.1.content.0.thinking.signature.str: Input should be a valid
     string\"},\"request_id\":\"req_vrtx_011CaB4tJa1Wbc6fK5efVVc4\"}","type":"None","param":"None","code":"400"}}

---

▐▛███▜▌   Claude Code v2.1.114
▝▜█████▛▘  Opus 4.6 · API Usage Billing
  ▘▘ ▝▝    /opt/nihao/gcp/ai49-gitops

❯ which mode you are using

I'm using default mode with the model vertex_ai/glm-5.

  This is a standard conversational mode - not plan mode, fast mode, or any other specialized mode. I have full access to all tools (read, write, bash, agents, etc.) and can
  execute tasks directly.

 /model claude-opus-4-6
Set model to Opus 4.6

❯ hi
  ⎿  API Error: 400 {"error":{"message":"{\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"messages.1.content.0.thinking.signature.str: Input
     should be a valid string\"},\"request_id\":\"req_vrtx_011CaB5f86yMgvCwsTLU3wzW\"}. Received Model Group=claude-opus-4-6\nAvailable Model Group
     Fallbacks=['claude-opus-4-6-asia-southeast1']\nError doing the fallback:
     {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"messages.1.content.0.thinking.signature.str: Input should be a valid
     string\"},\"request_id\":\"req_vrtx_011CaB5f9WZ8ARH9CYnA9bcz\"}","type":"None","param":"None","code":"400"}}
RAW_BUFFERClick to expand / collapse

Check for existing issues

  • I have searched the existing issues and checked that my issue is not a duplicate.

What happened?

we configured complexity_router with following

      - model_name: smart-router
        litellm_params:
          model: auto_router/complexity_router
          complexity_router_config:
            tiers:
              SIMPLE: vertex_ai/glm-5
              MEDIUM: vertex_ai/glm-5
              COMPLEX: claude-sonnet-4-6
              REASONING: claude-opus-4-6

it works fine when using glm-5 model, however when litellm auto switch to anthropic models when need more complex reasoning, we get errors

  ⎿  API Error: 400 {"error":{"message":"{\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"messages.1.content.0.thinking.signature.str: Input
     should be a valid string\"},\"request_id\":\"req_vrtx_011CaB4qJPWdYMoM8yyQUQ5C\"}. Received Model Group=claude-sonnet-4-6\nAvailable Model Group
     Fallbacks=['claude-sonnet-4-6-asia-southeast1', 'claude-sonnet-4-6-europe-west1', 'claude-sonnet-4-6-us-east5']\nError doing the fallback:
     {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"messages.1.content.0.thinking.signature.str: Input should be a valid
     string\"},\"request_id\":\"req_vrtx_011CaB4tJa1Wbc6fK5efVVc4\"}","type":"None","param":"None","code":"400"}}

Steps to Reproduce

  1. claude --model vertex_ai/glm-5
  2. start a conversation
  3. switch to anthropic models /model claude-opus-4-6
  4. get the error
<img width="1398" height="405" alt="Image" src="https://github.com/user-attachments/assets/21e2ad12-4ff9-4754-afd9-dfc2951f583b" />

Relevant log output

▐▛███▜▌   Claude Code v2.1.114
▝▜█████▛▘  Opus 4.6 · API Usage Billing
  ▘▘ ▝▝    /opt/nihao/gcp/ai49-gitops

which mode you are using

⏺ I'm using default mode with the model vertex_ai/glm-5.

  This is a standard conversational mode - not plan mode, fast mode, or any other specialized mode. I have full access to all tools (read, write, bash, agents, etc.) and can
  execute tasks directly.

❯ /model claude-opus-4-6
  ⎿  Set model to Opus 4.6

❯ hi
  ⎿  API Error: 400 {"error":{"message":"{\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"messages.1.content.0.thinking.signature.str: Input
     should be a valid string\"},\"request_id\":\"req_vrtx_011CaB5f86yMgvCwsTLU3wzW\"}. Received Model Group=claude-opus-4-6\nAvailable Model Group
     Fallbacks=['claude-opus-4-6-asia-southeast1']\nError doing the fallback:
     {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"messages.1.content.0.thinking.signature.str: Input should be a valid
     string\"},\"request_id\":\"req_vrtx_011CaB5f9WZ8ARH9CYnA9bcz\"}","type":"None","param":"None","code":"400"}}

What part of LiteLLM is this about?

Proxy

What LiteLLM version are you on ?

v1.82.3

Twitter / LinkedIn details

No response

extent analysis

TL;DR

The issue is likely due to an invalid input string being passed to the claude-opus-4-6 model, and a workaround may involve adjusting the input or configuration for this model.

Guidance

  • Verify that the input being passed to the claude-opus-4-6 model is a valid string, as the error message suggests an invalid_request_error due to an invalid input string.
  • Check the complexity_router_config and ensure that the claude-opus-4-6 model is properly configured and compatible with the input being passed.
  • Consider testing the claude-opus-4-6 model with a simple input string to isolate the issue and determine if it's specific to the model or the input.
  • Review the available model group fallbacks, such as claude-opus-4-6-asia-southeast1, to see if using a different region or fallback resolves the issue.

Example

No code example is provided as the issue seems to be related to model configuration and input validation rather than code syntax.

Notes

The issue may be specific to the claude-opus-4-6 model or the input being passed, and further testing and debugging may be required to determine the root cause.

Recommendation

Apply a workaround by adjusting the input or configuration for the claude-opus-4-6 model, as the error message suggests an issue with the input string.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

litellm - ✅(Solved) Fix [Bug]: complexity router not working for claude code after auto model switching from GLM-5 to Anthropic models [1 pull requests, 1 participants]