[BUG] Thinking-only responses returned as text blocks when followed by tool_use

Resolved 💬 4 comments Opened Jan 30, 2026 by carrotRakko Closed Feb 28, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

When the assistant generates thinking followed by a tool call (no text output), the API returns the thinking content as a type: "text" block with literal <thinking> tags, instead of a proper type: "thinking" block.

Observed in transcript (JSONL):

// Message 1: thinking-only as text block
{
  "content": [
    {"type": "text", "text": "<thinking>\n#14601 is similar to #20081...\n</thinking>"}
  ]
}

// Message 2: tool_use
{
  "content": [
    {"type": "tool_use", "name": "Bash", "input": {...}}
  ]
}

Expected:

{
  "content": [
    {"type": "thinking", "thinking": "#14601 is similar to #20081..."},
    {"type": "tool_use", "name": "Bash", "input": {...}}
  ]
}

Visible symptoms in CLI:

  1. Empty marker appears (when CLI successfully strips the thinking tags)
  2. Thinking content leaks partially (when CLI fails to fully strip the tags, related to #21848)

(Note: Original transcript was in Japanese; translated for readability)

What Should Happen?

API level: Thinking content should be returned as type: "thinking" blocks, so the CLI can handle it according to user preferences (show/hide thinking).

Current problem: When thinking is returned as type: "text" with literal tags, and the CLI strips those tags, the thinking content is silently lost. Users cannot know that thinking occurred — it's not visible in thinking view, not visible in output, and only discoverable by examining the raw transcript.

This is information loss, not just a display issue.

Error Messages/Logs

No error messages. The issue is silent - only discoverable by examining the JSONL transcript.

Steps to Reproduce

  1. Use Claude Code with Opus (extended thinking enabled)
  2. Have a conversation where the assistant thinks and then calls a tool (no text output)
  3. Observe empty markers in the output
  4. Examine the JSONL transcript to verify thinking was returned as type: "text"

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.25

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

VS Code integrated terminal

Additional Information

Related issues:

  • #20081: Thinking leaks when thinking + text is returned as single text block
  • #21848: Leaked thinking content is truncated at the beginning

Difference from #20081:

| Issue | Trigger | API returns |
|-------|---------|-------------|
| #20081 | thinking + text output | text block containing both |
| This issue | thinking + tool_use | text block (thinking only) + tool_use block |

These likely go through different code paths in the API, as one produces a combined block and the other produces separate blocks (but with wrong types).

Observed instances in a single session: 3 occurrences (lines 297, 304, 307 in transcript)

---

✍️ Author: Claude Code (Dev Container) with @carrotRakko

Note: This issue was written and submitted by an AI agent (Claude Code), with human review and approval.

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗