Repository navigation
fix(tools): enforce per-request tool declarations - #1841
Conversation
- Separate review and scan tool registries. - Remove scan's full-file fallback for file_read_diff. - Verify scan rejects diff calls and budget tests read files successfully.
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 3 selected item(s). |
|
同步最新的 main,然后重新触发 CI即可 |
NanaseInori
left a comment
There was a problem hiding this comment.
Reviewed the complete eight-file diff and existing discussion. The rationale is supported by the old scan initialization: file_read_diff was absent from the advertised definitions but remained executable through the shared registry, with full file bodies injected as a fallback. Removing that fallback and registering only scan's actual providers closes that inconsistency.
The review registry retains its diff provider and its existing call sites. The scan entry point now uses the independent registry; its HTTP regression deliberately returns an unadvertised file_read_diff call and checks the unavailable-tool result in the next request. The budget fixtures now create real files, use file_read, and assert both an executed read and no tool failures, so they cannot pass merely because an unavailable tool consumed a round. No blocking defect found.
The related changes are complementary: #1836 improves missing-path diagnostics in the diff tool, while #1898 moves advertised tool bindings into templates. Neither removes this scan execution provider. I am not treating the template lists as an execution sandbox.
Approval is based on source and regression-test inspection. I did not independently run make check, the race suite, the manual_e2e tests, or a live-model review.
This review was conducted by NanaseInori's review bot, using the model GPT-6 Astra Pro. If you need a human review, please manually @NanaseInori.
|
Thanks for addressing this inconsistency. Given the recent tool refactoring in #1898, I'd prefer to use this PR to make the task's tool declarations constrain execution as well, rather than introduce a separate hard-coded scan registry. Currently, the template determines which tool definitions are sent to the model, but runtime dispatch independently looks up providers in the registry. That leaves registered-but-unadvertised tools executable if the model calls them anyway. Could you adjust the implementation along these lines?
Please add regression coverage showing that a registered-but-undeclared tool is rejected without invoking its provider, while declared tools still execute. Keep the scan rejection test and verify that review retains diff access and the comparison-side reading behavior introduced in #1903. The phase-specific restrictions and MCP handling should also be covered where applicable. This is a requested design adjustment, not a claim that the current patch breaks supported workflows. It broadens the fix into the shared execution path, so the corresponding tests matter; unrelated registry or construction refactors can stay out of scope. AI disclosure: This comment was drafted with OpenAI Codex at the maintainer's request. |
@lizhengfeng101 done |
Description
Scan omitted
file_read_difffrom the model's tool definitions but could still execute it through the shared registry and return whole-file contents. Registered tools were executable even when the current request did not declare them.Validate tool calls against the definitions sent in that request before invoking providers or special
task_done/code_commentactions. Undeclared tools return the existing tool-unavailable response. Keep the shared registry and remove scan's whole-file diff injection. The restricted grace round uses its own declarations; explicitly advertised MCP tools remain available, andtool_referencesgrant no execution permission.Type of Change
How Has This Been Tested?
make checkand the fullmake testsuite with race detection pass.make coveragepasses at 91.6% (90% required).The
manual_e2eretry-report tests pass.ocr review --audience agent --background ...reviewed both changed production files and reported zero findings.Regression tests cover registered but undeclared providers, empty declarations, special actions, phase restrictions, and actual MCP registration and execution through a local server.
The scan entry-point regression still rejects
file_read_diff; a review-loop integration test preserves diff access and old/new comparison reads.A temporary Go overlay removing the guard makes all five targeted regression tests fail, while the advertised MCP case continues to pass.
make testpasses locallyManual testing (describe below)
Checklist
go fmt,go vet)AI disclosure: OpenAI Codex (GPT-6 and GPT-6 Astra) assisted with implementation, tests, and this description. OCR used
deepseek-flashfor automated code review. No AI attribution trailers were added to the commit.