Repository navigation
fix(coderd/x/chatd): drop blocked tools from Explore sub-agent turns - #30911
Open
ibetitsmike wants to merge 1 commit into
Open
ibetitsmike wants to merge 1 commit into
ibetitsmike wants to merge 1 commit into
Conversation
Explore sub-agents limited their tools only through the active tool list. The tools the Explore allowlist blocks, such as write_file and edit_files, stayed registered, and chatloop reads an empty active list as every registered tool. Any change that emptied ActiveTools before the model call would then offer and run them. Explore children now also drop blocked tools from the toolset, the way plan mode filters it, with the same allowlist predicate that builds the active list. The tools an Explore sub-agent is offered and can call are unchanged. Root Explore chats still rely on the active list alone.
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. |
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.
Explore sub-agents enforced their tool limit in one place.
buildTurnEnvironmentset the turn's active tool list fromallowedExploreToolNames, butwrite_file,edit_files,attach_file,process_list, andprocess_signalstayed registered. chatloop reads an empty active list as every registered tool (isToolActive), and that check decides both which tools the model is offered and which calls run. So a change that dropped or emptiedActiveToolsbefore the model call would give those tools to every Explore sub-agent. #30868 lists that change as the one mutant only its removed end-to-end tests caught. Plan mode does not have the gap, becausefilterToolsForTurnalso removes blocked tools from the registered set.This PR turns the Explore allowlist into one predicate,
exploreToolAllowed. Explore children now drop the tools it blocks right after the plan-mode filter, andallowedExploreToolNamesstill builds the active list from the same predicate. Thefalseentries in the old map were no-ops, so the predicate lists only the five allowed built-ins. An Explore sub-agent is offered and can call the same tools as before. Root Explore chats and plan mode are unchanged; root Explore chats still rely on the active list alone.Tools that join after the filter keep their current behavior:
appendDynamicToolsreturns early for Explore chats,find_toolsfrom the deferred MCP search stays active and defers only MCP tools that already pass the allowlist, provider tools are a separate list that is already cut toweb_searchfor Explore children, and computer use exists only in computer-use chats.Refs #30867
Testing
TestBuildTurnEnvironmentToolPolicynow requires every tool registered for an Explore child to be offered. Without the production change,ExploreChildandExploreChildAfterMCPReplacementfail withShould be empty, but was [write_file edit_files attach_file process_list process_signal]. With it, all rows pass.write_fileand thenedit_files, withActiveToolsset to nil for Explore chats at the chatloop handoff:ActiveToolsset to nilwrite_file,edit_files,attach_file,process_list, andprocess_signalread_file,execute, andprocess_output{"ok": true}Tool not found, and the agent gets no write or editgo test ./coderd/x/chatd/...,go test ./coderd/ -run '(?i)chat|explore|plan|mcp',go test ./enterprise/coderd/ -run '(?i)chat|explore|plan|mcp', and golangci-lint oncoderd/x/chatdpass.