Per-Tool Session Permissions #1309
Merged
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.
This PR introduces granular per-tool permission settings at the session level, complementing the existing pattern-based Allow/Deny rules.
Summary
Toolsmap toPermissionsConfigfor per-tool controlenabled(true/false) andmode("ask" / "always_allow")Permission Evaluation Order
Toolsmap) — most specific, checked first--yoloflag /ToolsApproved)API Examples
Enable YOLO mode for a session
curl -X POST http://localhost:8080/api/sessions/{id}/tools/toggleConfigure per-tool permissions
curl -X PATCH http://localhost:8080/api/sessions/{id}/permissions \ -H "Content-Type: application/json" \ -d '{ "permissions": { "tools": { "think": { "enabled": true }, "shell": { "enabled": true, "mode": "ask" }, "filesystem": { "enabled": true, "mode": "always_allow" }, "dangerous": { "enabled": false } } } }'Mixed: per-tool settings with pattern fallback
curl -X PATCH http://localhost:8080/api/sessions/{id}/permissions \ -H "Content-Type: application/json" \ -d '{ "permissions": { "tools": { "shell": { "enabled": true, "mode": "ask" } }, "allow": ["read_*", "think"], "deny": ["exec_*"] } }'In this example:
shellrequires confirmation (per-tool setting)read_file,read_directory,thinkare auto-approved (pattern match)exec_commandis blocked (deny pattern)Code Examples
New Types
Testing
Added comprehensive tests for:
always_allowmode auto-approvesaskmode requires confirmationenabled: falserejects toolToolsmap fall through to pattern-based rules