Bug: <persisted-output> tool results are written to session JSONL at full size, causing session resume to hang

Resolved 💬 3 comments Opened Feb 7, 2026 by CatalanCabbage Closed Feb 11, 2026

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

  1. Start a Claude Code session
  2. Run a Bash command that produces very large output (e.g., grep on a large minified JS file — in this case, a 4.8MB webpack bundle)
  3. 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):
...
```

  1. Bug: Despite the "Output too large" message, the JSONL line for this tool_result still contains the full 5.2MB of content, not just the preview.
  2. Exit the session and try to /resume it — 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 containing tool_result content
  • Both were 5,244,945 and 5,245,153 bytes respectively
  • The corresponding tool-results/*.txt files also exist at 4.9MB each, confirming the output was saved externally and duplicated in the session
  • The specific tool_use IDs: toolu_01TV61RJnJvVAhZXL8ZnVFfF and toolu_014hD6eeBkffWJHgoEScYySw
  • Both were Bash tool calls running grep on a large .webpack/main/index.js file

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 | head

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗