Repository navigation
fix(agent): refuse a call to a tool the turn did not offer (#4316) - #4322
Merged
Merged
Conversation
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
mstomar125
force-pushed
the
issue-4316-offered
branch
from
November 20, 2026 11:59
c317fe9 to
2885508
Compare
This was referenced Nov 20, 2026
Closed
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.
Closes #4316 (the turn's scoped surface is not checked at dispatch). Lands with the confirmation card (#4321, merged): a remote tool the gate offers is only callable if THIS turn offered it.
Agent lane. Touches
packages/agent(Michael's lane). The user's sign-off for the #4291 remote-tool build stands in for Michael's.The gap
The executor gates what exists (
RemoteToolHost::eligible(): enabled, approved, a runner, a confirmer where needed). A skill'stool_whitelist, the lookup rules and the offered-types hold narrow what the model is SHOWN on a turn. Nothing checked a call against what the turn showed: a model call to an approved remote tool this turn's whitelist scoped out was dispatched (after the confirmation, for a tool that needs one). Built-in tools behaved the same.The fix
In the agent loop, at the point a model's call goes to the executor: a call whose tool name is not in the turn's offered list (
tools, the surface the inference request carried) is refused before the executor, whatever the tool is, with an error resulttool_not_offered. The message names the tool the model asked for and carries nothing of its arguments. A warning logs the session, iteration and tool name only.All 1,066 existing agent-loop tests pass unchanged, so no existing behaviour relied on calling a tool that was not offered.
Tests
A scoped executor that can run
visibleandhidden_remotebut offers onlyvisible:tool_not_offered, it names the tool, and the arguments (a marker string) appear nowhere in what the model sees;get_node) is refused the same way;Mutants (5): check removed, check inverted, tool name dropped from the message, arguments leaked into the message, result not marked as an error. Each killed by a named test (
agent_loop::a_built_in_tools_result_is_unchangedis a pre-existing flake undercargo testthat shows up in some runs' failure lists; it passes under nextest).🤖 Generated with Claude Code