anthropics / anthropics/claude-code

[BUG] 2.1.270: session transcript JSONL omits most assistant text written before a tool call (interactive CLI)

Aperta
#94,251 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
area:core area:hooks bug has repro platform:macos regression
Lingua principale
Python
Stelle
145k
Fork
23.1k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

## What happens

Since upgrading from 2.1.267 to 2.1.270, the session transcript (`projects//.jsonl`) is missing most assistant `text` blocks that come before a `tool_use` in the same response. The text is shown in the terminal as normal. `thinking` and `tool_use` rows are still written, the latter with full input. End-of-turn text is affected much less.

The text is not elsewhere in the file: a phrase from a reply shown in the UI appears only inside later tool inputs that quote it.

## Measurements

All assistant rows over six days on one machine, one model (`claude-opus-5`), all `entrypoint: cli`, split by the two `CLAUDE_CONFIG_DIR` profiles used here:

| version | profile | assistant rows | rows with a `text` block | share |
|---|---|---:|---:|---:|
| 2.1.267 | A | 6,712 | 1,771 | 26.4% |
| 2.1.267 | B | 12,427 | 3,427 | 27.6% |
| 2.1.270 | A | 1,970 | 253 | 12.8% |
| 2.1.270 | B | 2,536 | 74 | 2.9% |

- Text rows with `stop_reason: tool_use`, as a share of tool calls: 51.7% → 13.6% in profile A and 53.7% → 1.9% in profile B, 2.1.267 → 2.1.270.
- One session resumed across the upgrade went from 372 text blocks in 1,262 assistant rows (2.1.263) to 3 in 40 (2.1.270).
- Haiku sessions that never call tools record text on every response, on both versions.
- Both profiles share `settings.json`. Profile B signs in with `forceLoginMethod: "claudeai"` to an organisation account; I have not established whether that is why it is worse.

## Why it matters

Hooks that read `transcript_path` to check what the model said before a tool call can no longer see it, and the PreToolUse payload carries no assistant text. A PreToolUse hook here that requires a written marker before certain commands became impossible to satisfy on 2.1.270.

## Related

#65051 (daemon sessions, 2.1.161) and #76668 (desktop app) describe the same shape on other entrypoints; this is the interactive CLI.

**Environment:** Claude Code 2.1.270, macOS 26.5 (Darwin 25.5.0), zsh, iTerm2.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Reproduce the issue through the interactive CLI using the reported version range, then inspect how transcript_path records assistant responses before tool_use and how the PreToolUse payload is formed. Compare a working 2.1.267 session with 2.1.270; done means assistant text before tool calls is retained in the session JSONL and is available to the hook.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
cli
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Attiva
Chiarezza
Da chiarire
Idoneità per principianti
38/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.