Bug: <persisted-output> tool results are written to session JSONL at full size, causing session resume to hang
Summary
When a Bash tool result exceeds the size threshold, Claude Code correctly saves the full output to a separate file under tool-results/ and wraps the content in <persisted-output> tags with a "Preview (first 2KB)" message. However, the full output is still serialized into the session JSONL file, making the session unloadable on resume.
Impact
The session JSONL grew to 12MB (728 lines), with two tool_result lines at ~5.2MB each. Attempting to /resume this session caused Claude Code to hang indefinitely.
Reproduction
- Start a Claude Code session
- Run a Bash command that produces very large output (e.g.,
grepon a large minified JS file — in this case, a 4.8MB webpack bundle) - Claude Code correctly triggers the persisted-output path:
- Saves full output to
~/.claude/projects/<project>/<session-id>/tool-results/<tool-use-id>.txt - The tool_result content starts with:
```
<persisted-output>
Output too large (4.8MB). Full output saved to: .../<tool-use-id>.txt
Preview (first 2KB):
...
```
- Bug: Despite the "Output too large" message, the JSONL line for this
tool_resultstill contains the full 5.2MB of content, not just the preview. - Exit the session and try to
/resumeit — it hangs.
Evidence
- Session file:
~/.claude/projects/-Users-dvsj/0153f518-29ff-486c-a353-8cf4333f10db.jsonl - Two offending lines (240 and 385) were
type: "user"messages containingtool_resultcontent - Both were 5,244,945 and 5,245,153 bytes respectively
- The corresponding
tool-results/*.txtfiles also exist at 4.9MB each, confirming the output was saved externally and duplicated in the session - The specific tool_use IDs:
toolu_01TV61RJnJvVAhZXL8ZnVFfFandtoolu_014hD6eeBkffWJHgoEScYySw - Both were
Bashtool calls runninggrepon a large.webpack/main/index.jsfile
Expected behavior
When a tool result triggers the <persisted-output> path, the JSONL session file should only contain the truncated preview (first 2KB), not the full output. The full output is already saved to tool-results/<id>.txt.
Actual behavior
The JSONL session line contains the full multi-MB output despite the message claiming it was "saved to" an external file. This makes the session file grow to 10MB+ and causes /resume to hang.
Environment
- Claude Code version: 2.1.17
- Model: claude-opus-4-5-20251101
- Platform: macOS (Darwin 24.5.0)
Workaround
Manually delete the offending lines from the .jsonl session file using sed -i '' '<line_number>d'. Identify large lines with:
awk '{print NR, length}' <session-file>.jsonl | sort -k2 -nr | headThis issue has 3 comments on GitHub. Read the full discussion on GitHub ↗