Skip to content

Grant the base tool for scoped agent tools, and warn about a rejection once - #420

Merged
ilovepixelart merged 6 commits into
ilovepixelart:mainfrom
ahammond:subagent-widen-scoped-grants
Nov 4, 2026
Merged

ilovepixelart merged 6 commits into
ilovepixelart:mainfrom
ahammond:subagent-widen-scoped-grants

Conversation

@ahammond

@ahammond ahammond commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

An agent whose tools: carries an argument scope such as Bash(pnpm tsx tools/ff/fetch-flags.ts --name:*) is rejected at discovery today. Claude Code loads the same file. This aligns the grant with Claude Code and prints each discovery warning once per process.

Scoped entries in tools:

Measured on Claude Code 2.1.318 in default permission mode. The subagent docs cover the Agent(...) case, where the type list "is ignored" in a subagent definition, and do not cover the others.

tools: Claude Code Before After
Bash(touch a.txt), Bash(*) Bash, each call prompts Rejected bash
Bash() Bash, the call prompts Rejected bash
Read(src/**) Read, reads a path outside the scope Rejected read
WebFetch(domain:example.com) WebFetch, prompts for another domain Rejected web_fetch
Agent(worker), Task(worker), Agent() Agent Rejected subagent
Read(), Grep(), WebSearch(foo) That tool Rejected That tool
Read, Bash(foo Read only Rejected read
Bash(, Bash(foo, Read Launch refused, naming the entry Rejected Launch refused, naming the entry
  • Each scoped entry grants its base tool. The tool's scope is not checked on calls.
  • An entry whose scope does not close is unrecognized. It is dropped beside a valid entry, because a comma inside it would otherwise split into a real tool in the child's --tools.
  • A tools: field that does not parse is still rejected. A scoped disallowedTools entry still denies the whole tool.
  • README.md, SECURITY.md and docs/subagents.md describe the new behavior.

Warnings

Discovery runs on every subagent call and every /agents, so a rejected file repeated the same warning. warnOnce prints each distinct message once per process. The set lives in a sharedSlot, so /reload and new sessions do not reset it.

Behavior change

Agents rejected before now load with the whole tool after upgrading. Nothing else changes for agents that already loaded.

Verification

  • Biome, tsc, knip and vitest with coverage pass on macOS: 3351 passed, 5 skipped.
  • In pi 1.5.0 with a local model, a Bash(touch a.txt) agent ran touch b.txt, and a Bash( agent failed with no entry in [Bash(] resolves to a tool.

ahammond and others added 4 commits November 3, 2026 15:08
A scope in an agent's tools: does not limit the agent in Claude Code
2.1.318: the agent has the base tool and each call goes through the
permission flow. Rejecting these agents, and the variable that opted out
of the rejection, have no counterpart there.

- Load scoped entries with the base tool, including Bash() and Agent()
- Remove PI_CODE_SUBAGENT_SCOPED_TOOLS and the empty-scope rejection
- Treat an entry whose scope does not close as unrecognized: dropped
  beside a valid entry, launch refused and named when nothing else
  resolves
- Keep rejecting a tools: field that does not parse
@ilovepixelart ilovepixelart changed the title Let users widen argument-scoped agent tool grants, and warn about a rejected agent once Grant the base tool for scoped agent tools, and warn about a rejection once Nov 4, 2026
@ilovepixelart ilovepixelart added the enhancement New feature or request label Nov 4, 2026
A Read inside the working directory ran with no prompt on Claude Code 2.1.318, so "prompts for each call" overstated it.
…-grants

# Conflicts:
#	docs/subagents.md
#	tests/agents.test.ts
@ilovepixelart
ilovepixelart merged commit e013885 into ilovepixelart:main Nov 4, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants