[RFC] devtools: add tool calling support to review-patch.py
Aaron Conole
aconole at redhat.com
Wed Sep 9 16:10:16 CEST 2026
David Marchand <david.marchand at redhat.com> writes:
> On Tue, 9 Jun 2026 at 20:26, Aaron Conole <aconole at redhat.com> wrote:
>>
>> Add an iterative tool-use loop to review-patch.py for the Anthropic
>> and OpenAI providers. The reviewer can now look up additional context
>> from the DPDK source tree when the patch alone is insufficient,
>> rather than having to guess at surrounding code, API contracts, or
>> function signatures.
>>
>> Tool calling is enabled by default with a limit of 10 rounds. Pass
>> '--tool-rounds 0' to disable it and restore the previous single-shot
>> behavior. The round limit prevents runaway cost on large patches
>> that when reached will force the model to deliver a final judgement.
>>
>> Initial tool set:
>> - grep Searches for regex across the file system with
>> optional path restrictions and case-insensitive
>> matches.
>> - file_read Line range read of a specific path.
>>
>> Both tools are limited to the repository root to prevent path
>> traversal. Path outputs are relative to the repo root.
>>
>> The system prompt is extended when tool calling is active to
>> encourage the model to use tools only when genuinely needed,
>> keeping unnecessary round trips and token costs under control
>> and to a minimum.
>>
>> Internally, _common.py gains send_request_raw() (returning the
>> raw response dict) so the tool-calling loops can inspect
>> stop_reason / finish_reason before extracting text.
>>
>> Signed-off-by: Aaron Conole <aconole at redhat.com>
>
> - I got a strange comment that a (valid) sha1 (from a Fixes: tag) was
> unknown to the grep tool.
>
>
> - Are those tools returning results on the current working directory?
> If so, the result may differ depending on whether you applied the series or not.
>
> Did you consider wrapping around "git grep $pattern origin/main" /
> "git show origin/main:$file" ?
> (determining the correct git reference may be hard..)
I'll post a new revision. I've been testing with expended tools. Some
of the errors are a result of not having the git log / git show / awk /
sed commands available (model tool usage is *very* sensitive). I've
added some safe versions and did quite a bit more testing. The result
is quite a bit more promising.
More information about the dev
mailing list