Skip to content

[codex] Cap persisted Claude tool-result reads - #1293

Open
alexkreidler wants to merge 1 commit into
kenn-io:mainfrom
alexkreidler:codex/cap-persisted-tool-results
Open

[codex] Cap persisted Claude tool-result reads#1293
alexkreidler wants to merge 1 commit into
kenn-io:mainfrom
alexkreidler:codex/cap-persisted-tool-results

Conversation

@alexkreidler

Copy link
Copy Markdown

Closes #1292.

Claude Code can persist oversized tool output in a sidecar under a session's tool-results directory. AgentsView previously loaded that sidecar with os.ReadFile and embedded the complete value into the reconstructed message. A multi-gigabyte sidecar therefore produced several multi-gigabyte allocations during parsing and JSON marshaling, eventually exceeded SQLite's value-size limit, left startup sync incomplete, and could trigger an operating-system SIGKILL during retry.

This change reads persisted tool-result sidecars through a 16 MiB limit. Larger results retain their bounded prefix and gain an explicit truncation marker, keeping the archive searchable and the truncation visible without allowing one sidecar to exhaust process memory.

The regression test uses a sparse oversized sidecar and verifies both the cap and marker. I also validated the change against the original failure shape: the affected session synced in under a second with roughly 202 MiB maximum RSS instead of reaching roughly 26 GiB, and a full archive resync completed successfully.

Validation: go test ./internal/parser -count=1.

@roborev-ci

roborev-ci Bot commented Jul 28, 2026

Copy link
Copy Markdown

roborev: Combined Review (e10f587)

No issues found.


Reviewers: 2 done | Synthesis: codex | Total: 1m46s

@alexkreidler
alexkreidler marked this pull request as ready for review July 28, 2026 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Claude persisted tool-result sidecars can cause unbounded memory use and SIGKILL

1 participant