fix(agents): gate skill-folded external MCP tools behind the approval prompt#478
Merged
Merged
Conversation
… prompt An admin's needs_approval=True flag was silently bypassed in skills mode: the flagged tool runs behind the skill_executor meta-tool, so the approval hook's selected_tool lookup resolved nothing and the tool_use name never matched. Mirror the OAuth consent fold fix — an optional tool_use-based second-chance lookup resolves the folded target via the SkillRegistry, checks it against the owning client's needs_approval set, and raises the same tool_approval_required interrupt with the inner tool's name + args so the dialog describes the real tool, not the executor. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
3b872ca to
a37504a
Compare
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.
Summary
Closes the skills-mode counterpart of the approval gate the same way #477 closed the OAuth consent gap.
MCPExternalApprovalHookgatesneeds_approval=Trueexternal MCP tools viaapproval_names_lookup(event.selected_tool), which only resolves when the selected tool is a StrandsMCPAgentTool. In skills mode (the server default), a skill-bound external MCP tool executes through theskill_executormeta-tool — so the lookup returned an empty set,tool_use["name"]was"skill_executor"so the name match could never fire either, and an admin'sneeds_approval=Trueflag was silently bypassed: the tool ran with no user approval prompt.How
Mirrors the fold-aware second-chance lookup from #477:
tool_approval.py— optionaltool_use_approval_lookupon the hook; when the direct path doesn't fire, it resolves the folded target from the rawtool_useand raises the sametool_approval_requiredinterrupt. The interrupt'stoolName/toolInputdescribe the inner tool (e.g.gmail_sendand its args fromtool_use.input.tool_input), not the executor, so the frontend dialog is meaningful;toolUseIdstays the executor's so the frontend correlates it with the streamed tool_use block. Decline cancels with the inner tool's name.mcp_binding.py— shared_resolve_folded_toolextracted from the provider lookup; newmake_folded_tool_approval_lookupchecks the folded tool's agent-facing name againstapproval_names_for_client(client)(same name the direct path matches when the tool is enabled outside a skill).base_agent.py/skill_agent.py—_build_tool_use_approval_lookupextension point (None in base, registry-backed inSkillAgent), mirroring_build_tool_use_provider_lookup.Stacked on #477
Base is
fix/skills-oauth-consent-foldso the diff shows only this change (it reuses that PR's fold-resolution infrastructure). Retargets todevelopwhen #477 merges.Test plan
TestApprovalHookSkillFoldedTools(hook),TestFoldedToolApprovalLookup(resolver),TestToolUseApprovalLookupWiring(SkillAgent wiring) — modeled on fix(agents): raise OAuth consent interrupt for skill-folded external MCP tools #477'sTestOAuthConsentHookSkillFoldedTools.🤖 Generated with Claude Code