Persisted-output files with long lines can't be chunked by Read offset/limit

Resolved 💬 4 comments Opened Mar 30, 2026 by loganrosen Closed May 3, 2026

Problem

When a tool (e.g., Bash, MCP tool) produces output that exceeds the inline limit, Claude Code saves it to a temp file via the persisted-output path. The agent then uses the Read tool with offset/limit to chunk through the file.

The issue is that persisted-output saves the raw output as-is, with no line splitting. Many tool outputs — especially JSON (e.g., API responses, structured logs, serialized data) — are a single massive line or have very long lines. Since Read's offset/limit parameters are line-based, the agent can't seek into the middle of a long line. A 50KB JSON blob on one line means offset=1 limit=1 returns the entire 50KB.

This makes it effectively impossible for the agent to incrementally process large structured outputs that aren't already line-delimited.

Expected behavior

The agent should be able to incrementally read through large persisted output regardless of line structure. Some options:

  1. Split long lines when writing persisted-output files (e.g., at 500 chars) so line-based offset/limit works
  2. Add character-offset support to the Read tool (e.g., char_offset / char_limit)
  3. Pretty-print JSON in persisted-output when the content is detected as JSON

Workaround

We're currently working around this by intercepting tool output before it reaches the persisted-output path, truncating it inline, and saving the full output to our own temp file with long lines pre-split at 500 chars. This works but adds complexity that should live in the harness.

Reproduction

  1. Run a command that outputs a large single-line JSON blob (e.g., curl an API that returns 50KB+ of minified JSON)
  2. Output gets saved to persisted-output file
  3. Try Read with offset=1 limit=10 — returns the entire blob since it's one line
  4. Agent has no way to read just a portion of the output

View original on GitHub ↗

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