Repository navigation
fix(tool): name missing paths in file_read_diff not-found error - #1836
lizhengfeng101 merged 3 commits into
Conversation
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 1 selected item(s). |
|
The scan scenario described here doesn’t match the current implementation. The scan entry point already excludes The empty-map test bypasses that initialization, so it doesn’t reproduce the reported scan issue. This leaves the scan-specific rationale unsupported. Improving missing-path feedback during ordinary reviews could still be useful, but please scope the change around that behavior and remove the scan claims and assumptions that contradict the existing implementation. |
During a review, `file_read_diff` answers with one sentence for every path it
cannot serve:
Error: diff not found for the requested paths
That sentence is the same whether the path is wrong or the diff simply is not
part of the change set, so nothing in it lets the model correct the request.
Its only remaining move is to re-read the same file under another spelling, and
nothing in the tool output can stop that.
The message now names the paths it could not serve and lists the paths that do
have diffs, so the model can pick one instead of guessing again:
Error: diff not found for: src/db/queries.go
Diffs exist for: src/api/handler.go, src/db/models.go
Use one of those paths, or file_read for a file outside the reviewed set.
The list is capped at 10 paths with a count for the rest, since it exists to be
read in one glance. A call where some paths hit still returns the diffs it
found and names only the ones it could not serve, and an empty request keeps
its own message (`Error: no files found`).
Scope is the review path. `ocr scan` hides `file_read_diff` from the tool
definitions (`cmd/opencodereview/scan_cmd.go`) and scan initialization fills
the provider with full file contents (`internal/scan/agent.go`,
`injectScanContentMap`), so a scan run never reaches this message and the
message does not try to tell the two modes apart: when the snapshot holds no
paths it says only that, and offers `file_read`.
Adds `DiffMap.Paths` (sorted, so the message reads the same on every run) and
tests for a wrong path, partial hits, the list cap, the unchanged empty-request
message, an empty snapshot, and snapshot replacement.
92d4132 to
4a9ee87
Compare
|
You're right on all three points. I re-checked them in the tree instead of relying on my earlier reading:
Rescoped to the review path only:
Red/green re-run on the rescoped tests: forcing To be explicit about what I did not verify: the "model re-reads the same file under different spellings" symptom comes from reading the code path, not from a captured review transcript — I have not run this against a live provider. If you'd rather see evidence from a real run before this lands, I'm happy to park it; the diff is small. |
|
I reviewed the latest revision with open-code-review (
The full |
Review feedback on alibaba#1836: the tests did not fail if a served path was reported as missing or if the file_read guidance was dropped, and the tools.md translations still described the old behaviour. - TestFileReadDiffReportsPartialHits now asserts the error line names exactly the missing paths and that the served diff is returned in full, not just its header. - New TestFileReadDiffAllPathsFoundHasNoError: a fully served request carries no error line at all. - The file_read guidance is asserted in both cases: the non-empty snapshot message must tell the model how to reach a file outside the change set, and the empty-snapshot message must name file_read. - All five translations of tools.md now describe the missing-path message, the available-path list, and the file_read guidance instead of "silently omitted" plus the old generic error. Verified the new assertions bite: re-introducing either behaviour the reviewer demonstrated (served paths in the missing list, guidance removed) turns four tests red; with the current implementation all of internal/tool passes. Full suite: 25 packages OK. -race was not run locally (no cgo toolchain on this machine); the reviewer already ran the full suite with race detection successfully.
|
All three points are addressed in ec17692.
I re-did your overlay check as a regression step: re-introducing both behaviours you demonstrated (served paths appended to the missing list, both guidance lines removed) turns four tests red; with the current implementation |
Description
During a review,
file_read_diffanswered with one sentence for every path it could not serve:That sentence is the same whether the path is wrong or the diff simply is not part of the change set, so nothing in it lets the model correct the request. Its only remaining move is to re-read the same file under another spelling.
The message now names the paths it could not serve and lists the paths that do have diffs:
The list is capped at 10 paths with
(and N more)for the remainder, since it exists to be read in one glance. A call where some paths hit still returns the diffs it found and names only the ones it could not serve; an empty request keeps its own message (Error: no files found).Scope is the review path.
ocr scanhidesfile_read_difffrom the tool definitions (cmd/opencodereview/scan_cmd.go,excludeToolDef), and scan initialization fills the provider with full file contents (internal/scan/agent.go,injectScanContentMap), so a scan run never reaches this message. The message therefore does not try to tell the two modes apart: with no paths in the snapshot it says only that, and points atfile_read.Also adds
DiffMap.Paths(sorted, so the message reads the same on every run). Diff is 248 insertions, 0 deletions.Type of Change
How Has This Been Tested?
New tests in
internal/tool/file_read_diff_missing_test.goandinternal/tool/diffmap_test.gocover the wrong-path case, partial hits, the 10-path cap, the unchanged empty-request message, an empty snapshot (asserting the message names no mode), and snapshot replacement.I verified the tests fail without the fix rather than passing vacuously. Forcing
notFoundMessageback to the previous single-sentence behaviour and re-running:With the fix restored, all of them pass, including the pre-existing
TestFileReadDiffProvider_Executecases (single path, multiple paths, missing path, empty and nilpath_array), which are unchanged.Full suite:
go test ./internal/... ./cmd/...-- 25 packages OK, 0 failures.go build ./...,go vet ./internal/tool/,gofmt -lon the changed files,scripts/verify-license.shandscripts/verify-english-only.go(796 files) all pass.make testpasses locallyNo manual run against a live LLM provider: the change is confined to the string the tool returns for paths it cannot serve, which the unit tests cover directly. The "model re-spells the path" symptom that motivates the change comes from reading the code path, not from a captured review transcript -- if evidence from a real run is wanted before this lands, say so.
Checklist
go fmt,go vet)AI disclosure: This PR was produced with AI/LLM assistance (WorkBuddy agent, Claude model). I reviewed every line myself, verified the red/green behaviour above by hand, and will answer maintainer questions and review comments from my own understanding. No commits are attributed to AI.
Related Issues
None. I found this by reading how
file_read_diffanswers a path that is not in the change set; I did not see an open issue covering it.