feat: enforce tool permissions on agent tool calls#2465
Open
lulululu-debug wants to merge 1 commit into
Open
Conversation
lulululu-debug
force-pushed
the
feat/tool-permission-enforce
branch
9 times, most recently
from
July 23, 2026 16:19
35cf2b6 to
3f1c41d
Compare
lulululu-debug
force-pushed
the
feat/tool-permission-enforce
branch
from
July 23, 2026 17:20
3f1c41d to
4f0e2ec
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.
What
Enforce the configured tool-permission policies on every agent tool call — the piece that makes issue #2462 functional end to end.
mcp/toolset.go— add an optionalCheckPermissionhook onToolSet; nil means checks are disabled (tools run unchanged).object/tool_guard.go—BuildToolPermissionCheckerbuilds aguard.CasbinGuardfrom the store'sToolPolicyrows and returns the check closure. Exec/shell calls are decided per program (viashellcmd) so chaining/subshell/sudo wrappers can't smuggle a denied program past a whole-string match. Returns nil (zero overhead) when a store has no policies.object/merge_agent_tools.go— attach the checker to the merged tool set.model/mcp.go— consult the checker before executing a tool; a denial short-circuits and is surfaced to the model as an error tool result instead of silently proceeding.Non-breaking: the guard defaults to allow, so stores without policies behave exactly as before. Builds on #2463 (guard engine) and #2464 (policy management).
Tests
go build ./...andgo test ./guard/... ./shellcmd/...Fix: #2462