fix(agent): recover from hallucinated file paths - #994
Open
xwil1 wants to merge 2 commits into
Open
Conversation
Contributor
|
🔍 OpenCodeReview found 5 issue(s) in this PR.
|
xwil1
force-pushed
the
fix/issue-989-file-read-recovery
branch
from
August 18, 2026 11:55
a15326b to
16e238f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses the soft-guard failure mode described in #989.
file_readpaths against the reviewed Git ref beforegit showfile_findprovider to return current-ref candidates to the same conversationfile_findby using raw NUL-delimited Git outputRoot cause and behavior
file_readpreviously passed a model-supplied path directly togit show. A hallucinated or deleted path produced an opaque Git failure while still consuming the main-task tool budget. A persistent model could spend the rest of the review retrying nonexistent paths and leave the item partial without reviewing the changed file.This change detects that deterministic condition before
git showand, after a bounded threshold, gives the model concrete paths from the reviewed ref or tells it to return to the current diff. It does not auto-select a candidate and does not report completion on the model's behalf. A model that keeps ignoring the recovery result still ends withStopMaxRounds/partial.The implementation also incorporates the initial automated review feedback:
./src/main.go,src//main.go, and backslash-separated paths are normalized before an exact file matchThis PR intentionally implements the smaller soft-guard direction from #989. Restricting reads to diff files or adding a review
--includeallowlist remains separate work.Test footprint
The PR adds 420 lines across three focused test files:
internal/llmloop/path_recovery_test.go: 328 added linesinternal/tool/file_find_test.go: 42 added linesinternal/tool/file_read_test.go: 50 added linesThe main loop regression covers three rejected reads followed by a valid read, a review comment, and
task_done. Additional cases cover invented, deleted, and moved paths; successful-read reset; bounded refunds; retry after a transient candidate-search error; Unicode and space-containing filenames; and equivalent non-canonical paths.The full PR is 8 files with 704 additions and 12 deletions. A duplicate 325-line command-level test was removed during review; the retained tests exercise the same production runner and tool implementations without duplicating the harness.
Validation
make checkmake testmake coverage(91.6%, threshold90%)go test -race ./internal/tool -run 'TestRead_GitShow_NormalizesEquivalentPaths|TestReadLines_GitShow_MissingPathIsStructuralError' -count=10go test -race ./internal/llmloop -run 'TestRecoverInvalidPathsDoesNotCacheFinderErrors|TestRunPerFile_(RecoversCandidatesAfterRepeatedMissingPath|RecoversInventedDeletedAndRenamedPaths|SuccessfulReadResetsMissingPathBatch|MissingPathRefundIsBounded)' -count=10