Repository navigation
refactor(coderd/x/chatd): replace executeTools and executeSingleTool with toolBatch - #30938
Draft
ibetitsmike wants to merge 1 commit into
Draft
ibetitsmike wants to merge 1 commit into
ibetitsmike wants to merge 1 commit into
Conversation
…with toolBatch ExecuteLocalTools unpacked its options into a 20-parameter executeTools, which forwarded 15 of them to executeSingleTool. Both are now methods on an unexported toolBatch built once from ExecuteLocalToolsOptions, and the 12 internal test call sites set only the options they use. executeTools also re-filtered provider-executed calls that ExecuteLocalTools had already removed; that duplicate filter is gone. The runOne metric defer calls recordToolResultMetrics instead of repeating its body.
ibetitsmike
added this pull request to stack #30940
October 18, 2026 15:19
This was referenced Oct 18, 2026
Collaborator
Author
|
@codex review
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
This branch has not been deployed
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.
Replaces the 20-parameter
executeToolsand the 15-parameterexecuteSingleToolinchatloopwith methods on an unexportedtoolBatch.newToolBatchbuilds it once fromExecuteLocalToolsOptions,runreplacesexecuteTools, andrunOnereplacesexecuteSingleTool. The 12 internal test calls set only the options they use instead of up to 20 positional arguments.It also deletes two copies:
executeToolsfiltered out provider-executed calls thatExecuteLocalToolshad already removed. Only theExecuteLocalToolsfilter remains.runOnemetric defer repeated the body ofrecordToolResultMetrics. It now calls that function.Why it is safe
newToolBatchbuilds the tool, runner, and metadata maps with the linesexecuteToolsused, and the byte budget asExecuteLocalToolsdid.rundrops the empty-batch returns:ExecuteLocalToolsreturns before it when no local call is left.recordToolResultMetricslabels byresult.ToolName, whichrunOnesets totc.ToolNameand never changes. It skips a nilMetrics. Production never passes one, becauseExecuteLocalToolssetsNopMetrics()first; only the direct test calls, which omitMetrics, use that path.ProviderExecutedfilter failsTestExecuteLocalTools_ProviderToolRunner(test(coderd/x/chatd/chatloop): cover provider tool runners in ExecuteLocalTools #30937). The other four mutants from test(coderd/x/chatd/chatloop): cover provider tool runners in ExecuteLocalTools #30937 still fail it here.git grep 'executeTools\|executeSingleTool'finds one comment, inchatd_test.go, which this PR updates.Review focus
The metric defer stays a closure so that it reads
resultwhenrunOnereturns.Validation
go test -race -count=1 ./coderd/x/chatd/chatloop/passes on test(coderd/x/chatd/chatloop): cover provider tool runners in ExecuteLocalTools #30937 and here, including the 16 tests that reach this code:TestExecuteTools*(5),TestExecuteSingleTool_*(5),TestExecuteLocalTools*(6).TestActiveServer_ToolErrorRecordsMetric,TestActiveServer_ToolExecutionAndPolicy, andTestProcessChatPanicRecoveryin./coderd/x/chatd/pass on test(coderd/x/chatd/chatloop): cover provider tool runners in ExecuteLocalTools #30937 and here.golangci-lint run ./coderd/x/chatd/chatloop/...reports 0 issues, and the pre-commit hook passed.Stack
This stack replaces the 20-parameter
executeToolsand the 15-parameterexecuteSingleToolinchatloopwith methods on onetoolBatchtype, and resolves tool name aliases in one place. Production behavior does not change.ExecuteLocalToolsexecuteToolsandexecuteSingleToolwithtoolBatchtoolBatchmethod