Persisted-output files with long lines can't be chunked by Read offset/limit
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:
- Split long lines when writing persisted-output files (e.g., at 500 chars) so line-based offset/limit works
- Add character-offset support to the Read tool (e.g.,
char_offset/char_limit) - 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
- Run a command that outputs a large single-line JSON blob (e.g.,
curlan API that returns 50KB+ of minified JSON) - Output gets saved to persisted-output file
- Try
Readwithoffset=1 limit=10— returns the entire blob since it's one line - Agent has no way to read just a portion of the output
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗