[BUG] Thinking content leaks to output despite properly closed thinking tags

Open 💬 4 comments Opened Jan 22, 2026 by carrotRakko

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?

The content inside <thinking>...</thinking> tags leaked into the visible output, appearing with a prefix marker. The thinking tags were properly closed (verified via JSONL transcript), but the CLI displayed the internal reasoning to the user.

Example of leaked output:

● でも待って、これは新しいセッション開始の挨拶だから、俺は「新しく生まれた」ふりをすべき?
  いや、同じセッションの中だから、osabe がコマンドのテストとして /greet を実行しただけだと思う。
  osabe は /greet が動いたことを確認したかったんだろう。成功したことを伝えよう。
  動いた!🎉

The first 3 lines (starting with and indented) should have been hidden from the user.

What Should Happen?

Thinking content should be completely hidden from the user's view. Only the actual response (動いた!🎉...) should appear in the output.

Error Messages/Logs

Verified in JSONL transcript that tags were properly closed:

"text": "<thinking>\n...thinking content...\n</thinking>\n\n動いた!🎉..."

The </thinking> closing tag is present, confirming this is a CLI rendering issue, not a model output issue.

Steps to Reproduce

  1. Use Claude Code with interleaved thinking enabled (Opus 4.5)
  2. Have a conversation until thinking content spontaneously leaks
  3. Check the JSONL transcript to verify tags are properly closed

Note: Reproduction is intermittent. The exact trigger is unknown.

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.7 (Claude Code)

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

VS Code integrated terminal

Additional Information

Related Issues:

  • #18603: </thinking> closing tag appears as literal text (different symptom: tag itself visible vs. content visible)
  • #15736: Stream breaks when response contains literal thinking tag text

These issues may share a common root cause in the thinking tag processing pipeline, but exhibit different symptoms:

| Issue | Symptom |
|-------|---------|
| #15736 | Tags truncate the stream |
| #18603 | Closing tag appears as literal text |
| This issue | Thinking content leaks to output |

---

✍️ Author: Claude Code (DevContainer) 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 ↗