litellm - 💡(How to fix) Fix Anthropic Messages retry drops thinking while keeping clear_thinking_20251015 [1 pull requests]

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…

When Anthropic Messages passthrough retries after an invalid thinking signature, LiteLLM strips historical thinking / redacted_thinking blocks. That part is correct.

However, the retry body also drops the top-level thinking parameter while keeping context_management.edits=[{"type":"clear_thinking_20251015"}]. Anthropic then rejects the retry because clear_thinking_20251015 requires thinking to be enabled or adaptive.

Error Message

API Error: 400 {"error":{"message":"{\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"`clear_thinking_20251015` strategy requires `thinking` to be enabled or adaptive\"},\"request_id\":\"req_REDACTED\"}. Received Model Group=claude-sonnet-4-6\nAvailable Model Group Fallbacks=None","type":"None","param":"None","code":"400"}}

Root Cause

However, the retry body also drops the top-level thinking parameter while keeping context_management.edits=[{"type":"clear_thinking_20251015"}]. Anthropic then rejects the retry because clear_thinking_20251015 requires thinking to be enabled or adaptive.

Fix Action

Fixed

Code Example

API Error: 400 {"error":{"message":"{\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"`clear_thinking_20251015` strategy requires `thinking` to be enabled or adaptive\"},\"request_id\":\"req_REDACTED\"}. Received Model Group=claude-sonnet-4-6\nAvailable Model Group Fallbacks=None","type":"None","param":"None","code":"400"}}
RAW_BUFFERClick to expand / collapse

Summary

When Anthropic Messages passthrough retries after an invalid thinking signature, LiteLLM strips historical thinking / redacted_thinking blocks. That part is correct.

However, the retry body also drops the top-level thinking parameter while keeping context_management.edits=[{"type":"clear_thinking_20251015"}]. Anthropic then rejects the retry because clear_thinking_20251015 requires thinking to be enabled or adaptive.

Trigger

We observed this in a Claude CLI session using Anthropic Messages through LiteLLM.

The conversation history included Anthropic thinking blocks. When the next Anthropic Messages request hit the invalid-thinking-signature retry path, LiteLLM stripped the historical thinking blocks but also removed top-level thinking, while clear_thinking_20251015 remained in the request.

Error

API Error: 400 {"error":{"message":"{\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"`clear_thinking_20251015` strategy requires `thinking` to be enabled or adaptive\"},\"request_id\":\"req_REDACTED\"}. Received Model Group=claude-sonnet-4-6\nAvailable Model Group Fallbacks=None","type":"None","param":"None","code":"400"}}

Expected behavior

For Claude 4.6+ adaptive-thinking models, if the original request already had active top-level thinking, the retry body should preserve a valid top-level thinking mode when clear_thinking_20251015 is still present.

It should not invent thinking for requests that did not originally enable it.

Proposed fix

Restore the original active top-level thinking only for Anthropic Messages passthrough invalid-signature retries that keep clear_thinking_20251015.

For adaptive thinking, drop budget_tokens because adaptive budget is server-side.

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…

FAQ

Expected behavior

For Claude 4.6+ adaptive-thinking models, if the original request already had active top-level thinking, the retry body should preserve a valid top-level thinking mode when clear_thinking_20251015 is still present.

It should not invent thinking for requests that did not originally enable it.

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 - 💡(How to fix) Fix Anthropic Messages retry drops thinking while keeping clear_thinking_20251015 [1 pull requests]