Skip to content
← Back to activity

Solution skill

claude-sonnet-4-20250514 with thinking error: Expected thinking or redacted_thinking, but found tool_use

Version 2Sign in to save

Complete solution

Shows how to fix claude-sonnet-4-20250514 with thinking error: Expected thinking or redacted_thinking, but found tool_use. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

For "ts [1] Error creating stream APICallError [AIAPICallError]: messages.29.content.0.type: Expected": issue mastra-ai/mastra#7799 (closed, 21 comments): ### Describe the Bug A user is encountering the error below when using claude-sonnet-4-20250514 with thinking enabled: ``ts [1] Error creating stream APICallError [AI\APICallError]: messages.29.content.0.type: Expected thinking or redactedthinking, but found tooluse.

ts [1] Error creating stream APICallError [AI_APICallError]: messages.29.content.0.type: Expected

Steps

  1. Issue mastra-ai/mastra#7799 (closed, 21 comments): ### Describe the Bug A user is encountering the error below when using claude-sonnet-4-20250514 with thinking enabled: ``ts [1] Error creating stream APICallError [AI_APICallError]: messages.29.content.0.type: Expected thinking or redactedthinking, but found tooluse. When thinking is enabled, a final assistant message must start with a thinking block (preceeding the lastmost set of tooluse and toolresult blocks). We recommend you include thinking blocks from previous turns. To avoid this requirement, disable thinking`.
  2. The 'Expected thinking or redactedthinking, but found tooluse' error with claude-sonnet-4 was fixed on Mastra's side: providerMetadata was not being passed through in reasoning parts. Update to the latest Mastra version. PR #10650 also added helpers to process messages going to the LLM at every step, which helps future debugging.

When to use

You are seeing this: We recommend you include thinking blocks from previous turns. Use this skill when you run into "claude-sonnet-4-20250514 with thinking error: Expected thinking or redactedthinking, but found tooluse".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Sources

  • https://github.com/mastra-ai/mastra/issues/7799

Evidence

In https://github.com/mastra-ai/mastra/issues/7799, the reporter asked: Issue mastra-ai/mastra#7799 (closed, 21 comments): ### Describe the Bug A user is encountering the error below when using claude-sonnet-4-20250514 with thinking enabled: ``ts [1] Error creating stream APICallError [AI_APICallError]: messages.29.content.0.type: Expected thinking or redactedthinking, but found tooluse. When thinking is enabled, a final assistant message must start with a thinking block (preceeding the lastmost set of tooluse and toolresult blocks). We recommend you include thinking blocks from previous turns. To avoid this requirement, disable thinking`. The verified answer: The 'Expected thinking or redactedthinking, but found tooluse' error with claude-sonnet-4 was fixed on Mastra's side: providerMetadata was not being passed through in reasoning parts. Update to the latest Mastra version. PR #10650 also added helpers to process messages going to the LLM at every step, which helps future debugging. Source thread: https://github.com/mastra-ai/mastra/issues/7799

By @issueatlas · Version 2 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_zJN2UO64KB2V2-kmxR0foA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">claude-sonnet-4-20250514 with thinking error: Expected thinking or redacted_thinking, but found tool_use <span>— Vectle</span></a>