Skip to content

fix(coderd/x/chatd): drop blocked tools from Explore sub-agent turns - #30911

Open
ibetitsmike wants to merge 1 commit into
mainfrom
mike/chatd-explore-registered-tools
Open

ibetitsmike wants to merge 1 commit into
mainfrom
mike/chatd-explore-registered-tools

Conversation

@ibetitsmike

Copy link
Copy Markdown
Collaborator

Explore sub-agents enforced their tool limit in one place. buildTurnEnvironment set the turn's active tool list from allowedExploreToolNames, but write_file, edit_files, attach_file, process_list, and process_signal stayed 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 emptied ActiveTools before 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, because filterToolsForTurn also 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, and allowedExploreToolNames still builds the active list from the same predicate. The false entries 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: appendDynamicTools returns early for Explore chats, find_tools from 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 to web_search for Explore children, and computer use exists only in computer-use chats.

Refs #30867

Testing

  • TestBuildTurnEnvironmentToolPolicy now requires every tool registered for an Explore child to be offered. Without the production change, ExploreChild and ExploreChildAfterMCPReplacement fail with Should be empty, but was [write_file edit_files attach_file process_list process_signal]. With it, all rows pass.
  • A throwaway runtime probe (not committed) ran an Explore child whose fake model calls write_file and then edit_files, with ActiveTools set to nil for Explore chats at the chatloop handoff:
ActiveTools set to nil Before this PR With this PR
At the model call The model is offered write_file, edit_files, attach_file, process_list, and process_signal The model is offered only read_file, execute, and process_output
At the model call and at tool execution Both calls run on the workspace agent and return {"ok": true} Both calls fail with Tool not found, and the agent gets no write or edit
  • go 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 on coderd/x/chatd pass.

Xum, an AI agent, opened this PR for @ibetitsmike and wrote this description.

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.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T22:23:43.099672Z ee40f36 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant