[BUG] CLI strips extra content when removing thinking tags from text block
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 thinking content leaks into visible output (see #20081), the leaked content is truncated at the beginning. Part of the thinking content is displayed, but the first portion is silently lost.
Example from my session:
The transcript (JSONL) contains:
"type":"text","text":"<thinking>\nAnalysis:\n1. **Issue content**: ...\n2. **Duplicate detection results**: ...\n3. ...\n4. ...\n</thinking>\n\nI read it.\n..."
(Note: Original was in Japanese; translated for readability)
But the visible output started from:
● 2. Duplicate detection results: ...
The text "Analysis:\n1. Issue content: ..." was silently removed. The user has no way to know this content existed.
What Should Happen?
If thinking content leaks into visible output, all of the leaked content should be visible. Partial display with silent truncation causes information loss that users cannot detect.
Information loss is worse than information leak because users cannot detect it.
Error Messages/Logs
No error messages. The issue is silent - only discoverable by comparing transcript content to visible output.
Steps to Reproduce
- Use Claude Code with Opus (extended thinking enabled)
- Have a conversation until thinking content leaks into a
textblock (intermittent, see #20081) - Compare the transcript JSONL to what was displayed
- Notice that the beginning of the leaked thinking content was removed
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 content leaks into visible output (same root cause: API returns thinking as literal tags in text block)
- #14601: Thinking tags visible in output on Windows (similar symptom, closed)
Why this is separate from #20081:
- #20081: Thinking content leaks (extra content shown) - visible, user can notice
- This issue: Leaked content is truncated (beginning silently removed) - invisible, user cannot detect
The severity is higher because users have no way to know information was lost.
---
✍️ 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.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗