claude-code - 💡(How to fix) Fix Assistant text blocks not persisted to transcript JSONL when followed by interleaved thinking (regression ~2.1.159–2.1.162)

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Since ~v2.1.162 (still present on 2.1.165), assistant text blocks are silently dropped from the session transcript (~/.claude/projects/…/<session>.jsonl) whenever the model emits another (interleaved) thinking block after the text in the same turn:

generated turnpersisted to JSONL
[thinking, text, tool_use…][thinking, text, tool_use…]
[thinking, text] (final reply)[thinking, text]
[thinking, text, thinking, tool_use…][thinking, thinking, tool_use…] ❌ text gone

The prose is rendered on screen but appears nowhere in the file — not as text, not inside thinking, not in any other line type. The two persisted thinking blocks carry distinct signatures (both genuine); only the sandwiched text vanishes. v2.1.158 transcripts from the same machine/model persist every text block.

Root Cause

Since ~v2.1.162 (still present on 2.1.165), assistant text blocks are silently dropped from the session transcript (~/.claude/projects/…/<session>.jsonl) whenever the model emits another (interleaved) thinking block after the text in the same turn:

generated turnpersisted to JSONL
[thinking, text, tool_use…][thinking, text, tool_use…]
[thinking, text] (final reply)[thinking, text]
[thinking, text, thinking, tool_use…][thinking, thinking, tool_use…] ❌ text gone

The prose is rendered on screen but appears nowhere in the file — not as text, not inside thinking, not in any other line type. The two persisted thinking blocks carry distinct signatures (both genuine); only the sandwiched text vanishes. v2.1.158 transcripts from the same machine/model persist every text block.

RAW_BUFFERClick to expand / collapse

Summary

Since ~v2.1.162 (still present on 2.1.165), assistant text blocks are silently dropped from the session transcript (~/.claude/projects/…/<session>.jsonl) whenever the model emits another (interleaved) thinking block after the text in the same turn:

generated turnpersisted to JSONL
[thinking, text, tool_use…][thinking, text, tool_use…]
[thinking, text] (final reply)[thinking, text]
[thinking, text, thinking, tool_use…][thinking, thinking, tool_use…] ❌ text gone

The prose is rendered on screen but appears nowhere in the file — not as text, not inside thinking, not in any other line type. The two persisted thinking blocks carry distinct signatures (both genuine); only the sandwiched text vanishes. v2.1.158 transcripts from the same machine/model persist every text block.

Environment

  • claude 2.1.165 (also observed on 2.1.162); v2.1.158 unaffected
  • macOS (Darwin 25.5.0), native installer
  • Model: claude-opus-4-8 (1M context) — Opus thinks between text and tool calls constantly, so it's hit hardest

Evidence (two sessions analyzed line-by-line)

Session A (2.1.165, 35 API turns): every turn shaped thinking+text+tool_use… kept its text (10/10); every turn shaped thinking+thinking+tool_use… (15) corresponds to an on-screen prose message that is absent from the JSONL — verified by grepping the raw file for exact on-screen sentences (0 hits). Session B (2.1.162, 217 turns): 41 double-thinking turns, 48 kept texts, and — the tell — zero persisted …text→thinking… shapes across both sessions, a shape that is routine in interleaved-thinking output.

Per-turn grouping confirmed via shared requestId on the JSONL lines; the dropped turns are single API messages whose text block was never written between the two thinking lines.

Note: {"thinking":"","signature":"…"} (empty thinking, signature-only) is normal and appears in healthy 2.1.158 transcripts too — that is NOT the bug; only the text loss is.

Repro

  1. On ≥2.1.162, run any multi-step task with an Opus model that produces prose followed by more reasoning before tool calls ("investigate X" style tasks reproduce within a few turns).
  2. Note an assistant prose message on screen, then grep the session JSONL for its exact text.
  3. The message is missing whenever the turn's persisted shape is [thinking, thinking, tool_use…].

Impact

  • --resume / session-restore rebuilds context from the transcript → the model loses its own mid-task explanations and any in-band content in them
  • Every transcript consumer (analytics, observability tools, transcript viewers, custom tooling reading ~/.claude/projects) sees roughly half the assistant prose missing in tool-heavy Opus sessions
  • Hook-style integrations that rely on in-band assistant text (e.g. progress markers) silently break

Happy to provide redacted JSONL excerpts of broken turns (thinking/thinking/tool_use with matching requestIds) on request.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING