#21285: fix(auto-reply): parse toolCall read paths in post-compaction audit
size: M
Cluster:
Error Handling Improvements
## Summary
Fixes a false-positive in post-compaction read auditing for OpenAI/Codex-style transcripts.
`extractReadPaths()` previously only recognized legacy `tool_use` blocks. In current session JSONL records, read calls are commonly stored as `toolCall` blocks with `arguments.path` or `arguments.file_path`, so the audit could incorrectly warn that required startup files were not read.
## What changed
- Update `extractReadPaths()` in `src/auto-reply/reply/post-compaction-audit.ts` to support strict `read` extraction from:
- `tool_use` (`input.path` / `input.file_path`)
- `toolCall` (`arguments.path` / `arguments.file_path`, with guarded `input` fallback)
- Add malformed-input guards (non-object blocks/args, non-string/blank paths).
- Deduplicate extracted paths in first-seen order.
- Add focused regression coverage:
- `src/auto-reply/reply/post-compaction-audit.test.ts`
- schema matrix for `tool_use` + `toolCall`
- malformed input cases
- dedupe behavior
- `src/auto-reply/reply/agent-runner.runreplyagent.test.ts`
- no warning when required reads are present via `toolCall`
- warning still appears when required reads are missing
## Why this is scoped this way
- Root-cause evidence points to `toolCall` parsing gaps.
- Kept matching strict to `name === "read"` to avoid widening behavior.
- Did not add `toolResult`-based inference to keep semantics deterministic and blast radius low.
## Validation
- `pnpm vitest src/auto-reply/reply/post-compaction-audit.test.ts`
- `pnpm vitest src/auto-reply/reply/agent-runner.runreplyagent.test.ts`
## Notes
- Local tracking: `BUG-045` (agent-runtime)
- AI-assisted: yes
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Fixed false-positive warnings in post-compaction read auditing by adding support for `toolCall` blocks in addition to legacy `tool_use` blocks. The implementation correctly extracts file paths from both `arguments.path`/`arguments.file_path` and falls back to `input` fields when needed, adds comprehensive malformed-input guards, and deduplicates paths in first-seen order. The change is well-tested with focused regression coverage including schema matrix tests, malformed input cases, and integration tests verifying both success and failure scenarios.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The implementation is focused, well-tested, and addresses a specific false-positive bug. The logic is straightforward with appropriate guards for edge cases. Test coverage is comprehensive including unit tests for all schema variations and integration tests verifying the fix works end-to-end. The change maintains backward compatibility with legacy `tool_use` blocks while adding support for newer `toolCall` blocks.
- No files require special attention
<sub>Last reviewed commit: 2679472</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#22711: fix: post-compaction audit skips non-existent required files
by taw0002 · 2026-02-21
80.0%
#21195: fix: suppress orphaned tool_use/tool_result errors after session co...
by ruslansychov-git · 2026-02-19
78.4%
#19094: Fix empty tool_call_id and function names in provider transcript pa...
by yxshee · 2026-02-17
78.1%
#12487: fix(agents): strip orphaned tool_result when tool_use is sanitized ...
by skylarkoo7 · 2026-02-09
78.0%
#14328: fix: strip incomplete tool_use blocks from errored/aborted messages...
by Kropiunig · 2026-02-12
77.7%
#22124: fix(agents): remove non-existent WORKFLOW_AUTO.md from post-compact...
by lailoo · 2026-02-20
77.6%
#22087: Preserve assistant reply when exec fails under suppressToolErrors
by graysurf · 2026-02-20
77.3%
#4852: fix(agents): sanitize tool pairing after compaction and history tru...
by lailoo · 2026-01-30
77.3%
#21166: fix(agents): sanitize tool names in session transcript repair (#8595)
by dinakars777 · 2026-02-19
77.2%
#6687: fix(session-repair): strip malformed tool_use blocks to prevent per...
by NSEvent · 2026-02-01
77.2%