Commit 222ee0e
authored
[codex] Cap persisted Claude tool-result reads (#1293)
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`.
Co-authored-by: Alex Kreidler <alexkreidler@users.noreply.github.com>1 parent 9762387 commit 222ee0e
2 files changed
Lines changed: 42 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
33 | | - | |
34 | | - | |
35 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
| |||
1944 | 1946 | | |
1945 | 1947 | | |
1946 | 1948 | | |
1947 | | - | |
| 1949 | + | |
1948 | 1950 | | |
1949 | 1951 | | |
1950 | 1952 | | |
| 1953 | + | |
| 1954 | + | |
| 1955 | + | |
| 1956 | + | |
| 1957 | + | |
| 1958 | + | |
| 1959 | + | |
| 1960 | + | |
| 1961 | + | |
1951 | 1962 | | |
1952 | 1963 | | |
1953 | 1964 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1431 | 1431 | | |
1432 | 1432 | | |
1433 | 1433 | | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
1434 | 1461 | | |
1435 | 1462 | | |
1436 | 1463 | | |
| |||
0 commit comments