Back to Home
LiteLLM error: Expected thinking or redacted_thinking but found tool_use
Troubleshooting7 min readSource: Admesh Engineering

LiteLLM error: Expected thinking or redacted_thinking but found tool_use

Why thinking models with tools fail with Expected thinking or redacted_thinking but found tool_use, and how to fix the assistant message history.

The symptom

You run a chat client or agent against a thinking-enabled Claude model through a LiteLLM proxy. The first turn works. Once the model calls a tool and the client sends the tool result back, the next request fails with a 400. The error body is an invalid_request_error whose message reads: messages.1.content.0.type: Expected thinking or redacted_thinking, but found tool_use. When thinking is enabled, a final assistant message must start with a thinking block (preceeding the lastmost set of tool_use and tool_result blocks).

LiteLLM wraps this as litellm.BadRequestError, and the provider prefix changes with the route: BedrockException for Bedrock model groups, AnthropicException for the direct Anthropic API. Some reporters see the same shape with found text instead of found tool_use, which is the same rule failing on a different block type. The index in the message (messages.1.content.0) tells you which turn the API rejected.

  • Status: 400 invalid_request_error, not a 5xx or a timeout.
  • Trigger: thinking enabled, tools present, at least one completed tool call in the history.
  • Provider-independent: reported on Bedrock and on the native Anthropic endpoint.
  • Client-independent: reported from LibreChat, Open WebUI, and a Python SDK caller.

Why it happens

Ranked by how well the thread supports each, with the check that separates them.

  • 1. Thinking blocks were dropped from earlier assistant turns (most likely). The API requires that the last assistant message before the tool_result set begins with a thinking or redacted_thinking block. Clients and proxies often rebuild history from text and tool blocks only, discarding reasoning content. Confirm: log the exact JSON body sent on the failing request and inspect the assistant message at the index named in the error. If its content array starts with tool_use or text, this is your cause.
  • 2. Native tool calling path bypasses the thinking-preserving code path. One reporter notes the error only appears with native tool calling and that the default tool-calling mode works. Confirm: switch the client to its non-native tool mode and resend the same conversation. If it succeeds, the native path is not forwarding thinking blocks.
  • 3. The client reorders content blocks. Even when thinking blocks survive, placing them after tool_use or text violates the ordering rule. Confirm: check whether content[0].type is thinking in the failing assistant turn; ordering is visible in the same request log.
  • 4. A thinking block was redacted or truncated in transit. Redacted blocks must be passed back as-is. Confirm: look for redacted_thinking entries in the original response and compare them with what the next request sends.

How to fix it

The durable fix is to make the client or proxy replay the assistant turn exactly as the model produced it, including reasoning blocks, in the original order.

  1. Capture the failing request body. Enable verbose request logging on the proxy or client and dump the JSON for the turn named in the error message.
  2. Compare that assistant message against the original model response. The content array should open with a thinking (or redacted_thinking) block, then text, then tool_use. If the thinking block is missing, your client is stripping it.
  3. Stop stripping reasoning content. In the client or middleware, persist the full assistant content array from the response and send it back unchanged on the next turn instead of reconstructing it from text and tool calls.
  4. If you cannot preserve thinking blocks, disable thinking for tool-using conversations. The API error text itself recommends this, and reporters confirm it as a workaround.
  5. If you depend on native tool calling, try the client's default tool-calling mode while the history handling is fixed. One reporter found this avoided the failure.
  6. Re-run the same multi-turn tool conversation and confirm the request body now starts the assistant turn with a thinking block and the 400 is gone.

When this is not the cause

Several nearby failures look similar but have different fixes.

A plain 400 about tool_use and tool_result pairing, without any mention of thinking, is a malformed tool conversation, not a thinking-block problem. A 401 or 403 points at credentials. A 429 or quota message points at rate limits. A 5xx from the provider is an upstream outage.

If the error appears on the very first turn, before any tool call has completed, thinking-block replay is unlikely to be the cause, because there is no prior assistant turn to replay. Look instead at how the client seeds the system prompt or prefill.

If it only happens on one provider route while the other works, suspect the proxy's provider adapter rather than the client. Verify by sending the identical body to the other route.

If disabling thinking makes it disappear, that confirms the thinking-block rule is involved, but it does not by itself prove which component dropped the blocks. Use the request-body check above to pin that down.

How to apply this with Admesh

Admesh exposes an Anthropic-compatible endpoint at https://api.admesh.ai/v1/messages alongside an OpenAI-compatible base URL at https://api.admesh.ai/v1, with one API key and one balance across model families. That means you can route the same conversation to different model families while debugging this class of error without juggling separate credentials.

Point your client's Anthropic-style base URL at https://api.admesh.ai/v1/messages and keep your existing request shape. Because the thinking-block rule is enforced by the model API rather than by the gateway, the request-body check from the fix section still applies: log the outgoing JSON and confirm the assistant turn at the failing index begins with a thinking block.

If you want to isolate whether the problem is client-side history handling or model-side, replay the identical captured body against a non-thinking model through the OpenAI-compatible base URL. If that succeeds, the request shape is fine and the thinking-block replay is the culprit.

Check the model catalog and pricing at https://admesh.ai/models for the current model list, manage keys at https://console.admesh.ai, and see https://docs.admesh.ai for endpoint details. Do not hardcode model identifiers from this article; confirm them in the live catalog.

Admesh API docs →

FAQ

Does this error only happen on AWS Bedrock?
No. Reporters hit the same message on the native Anthropic API and on Bedrock, and one reply concludes it affects Claude reasoning models generally rather than a single provider. Treat it as a message-history rule, not a Bedrock quirk.
Will turning off thinking permanently fix it?
It removes the error because the rule no longer applies, and the API's own error text suggests it as an escape hatch. But you lose reasoning quality. Preserving thinking blocks in the replayed assistant turn is the real fix.
Why does the error mention messages.1?
That index identifies which message in the array failed validation. Open your logged request body and inspect that entry; it is almost always the assistant turn that precedes the tool result.
Is this a LiteLLM bug or a client bug?
The thread does not settle it. The error originates from the model API, but which layer drops the thinking blocks varies by setup. The request-body comparison is the only reliable way to attribute it in your stack.

References

Call these models through one gateway

Admesh provides a unified OpenAI-compatible API: one Base URL and one key for Claude, GPT, DeepSeek and more. New accounts get trial credit that never expires.