feat(agents): per-subagent permission sets#187
Merged
emal-avala merged 1 commit intomainfrom Apr 23, 2026
Merged
Conversation
Subagents can now be launched with their own allow/deny/ask rules,
independent of the parent session's global permissions config.
Agent markdown files (`.agent/agents/<name>.md`) may declare
permission fields in their frontmatter:
---
name: search-only
description: Read-only searcher
include_tools: [Grep, Glob, FileRead]
permission_mode: deny
allow: ["Grep", "Glob", "FileRead(src/**)"]
deny: ["Bash(rm *)"]
ask: ["Bash(git *)"]
---
Entries are parsed as `Tool(pattern)` — bare tool names bypass the
pattern. The collected `PermissionsConfig` is serialised to a temp
TOML file and handed to the spawned subagent as
`--permissions-overlay <path>`, which replaces the child's effective
permissions wholesale.
The overlay flag is gated by `security.disable_bypass_permissions`
so a locked-down host cannot be loosened by passing a file path.
Closes ROADMAP 5.5.
Tests: 8 new unit tests in coordinator_tests, 1 smoke test for the
new --permissions-overlay flag appearing in --help.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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
Subagents spawned via the coordinator can now declare their own allow / deny / ask permission rules — independent of the parent session's global permissions config. This closes roadmap item 5.5.
Why
The coordinator already supports custom agent types (
.agent/agents/<name>.md) and a coarseread_onlyflag that forwards--permission-mode plan. But there was no way to say "this subagent may rungit *but neverrm" without either:Per-agent overlays let the coordinator hand each child its own scoped rule set while reusing the existing
PermissionsConfig/PermissionCheckerpipeline end-to-end.How it works
Agent markdown files can now carry permission fields in their YAML frontmatter:
Tool(pattern)syntax; bare tool names yield(tool, None)patternpermission_modedefaults toaskpermissions: None(and inherit the parent's config, as before)When the coordinator spawns the subagent:
permissionsisSome, serialise it to a temp TOML at$TMPDIR/agent-code-perms-<uuid>.toml--permissions-overlay <path>to the child commandconfig.permissions(not merges — semantics match/profile loadon config replacement)The overlay flag is gated by
security.disable_bypass_permissions, so a locked-down host can't be loosened by passing a file path.API surface changes
AgentDefinitiongainspermissions: Option<PermissionsConfig>(#[serde(default)], backwards compatible)services::coordinator::permissions_to_toml(&PermissionsConfig) -> Result<String, String>--permissions-overlay <path>on theagentbinaryTest plan
cargo fmt --all— cleancargo clippy --workspace --all-targets -- -D warnings— cleancargo test -p agent-code-lib --lib services::coordinator— 15/15 pass (8 new)cargo test -p agent-code --test smoke— 4/4 pass (new:permissions_overlay_flag_appears_in_help)agent --help | grep permissions-overlay— flag documentedcat > /tmp/p.toml <<EOF ... EOF; agent --permissions-overlay /tmp/p.toml --dump-system-prompt— overlay read without panicPre-existing
sandbox::tests::auto_detect_off_macos_is_noopfailure on Linux is unrelated (environment-dependent cfg test that fails on main too).