mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-28 19:52:02 +00:00
feat(subagents): add disallowedTools field to agent definitions (#3064)
* feat(subagents): add disallowedTools field to agent definitions Add a `disallowedTools` blocklist to agent frontmatter, letting agents specify tools they should not have access to. Supports exact tool names, MCP server-level patterns (e.g., `mcp__slack`), and display name aliases. Applied as a post-filter in AgentCore.prepareTools() after the existing `tools` allowlist. Persisted through serialize/parse roundtrips. * docs: document disallowedTools and MCP tool behavior for subagents Add Tool Configuration section to sub-agents docs explaining: - tools allowlist and disallowedTools blocklist - How MCP tools follow the same allowlist/blocklist rules - MCP server-level patterns in disallowedTools * fix(subagents): validate disallowedTools in SubagentValidator Reuse the existing validateTools() method to validate disallowedTools entries at config validation time, catching non-string and empty entries before they reach runtime. * test: remove flaky BaseSelectionList scroll test on Windows
This commit is contained in:
parent
35420b03bc
commit
8d74a0cf0a
13 changed files with 285 additions and 48 deletions
|
|
@ -103,6 +103,8 @@ approvalMode: auto-edit # Optional: default, plan, auto-edit, yolo
|
|||
tools: # Optional: allowlist of tools
|
||||
- tool1
|
||||
- tool2
|
||||
disallowedTools: # Optional: blocklist of tools
|
||||
- tool3
|
||||
---
|
||||
|
||||
System prompt content goes here.
|
||||
|
|
@ -150,6 +152,55 @@ You are a code reviewer. Analyze the code and report findings.
|
|||
Do not modify any files.
|
||||
```
|
||||
|
||||
#### Tool Configuration
|
||||
|
||||
Use `tools` and `disallowedTools` to control which tools a subagent can access.
|
||||
|
||||
**`tools` (allowlist):** When specified, the subagent can only use the listed tools. When omitted, the subagent inherits all available tools from the parent session.
|
||||
|
||||
```
|
||||
---
|
||||
name: reader
|
||||
description: Read-only agent for code exploration
|
||||
tools:
|
||||
- read_file
|
||||
- grep_search
|
||||
- glob
|
||||
- list_directory
|
||||
---
|
||||
```
|
||||
|
||||
**`disallowedTools` (blocklist):** When specified, the listed tools are removed from the subagent's tool pool. This is useful when you want "everything except X" without listing every permitted tool.
|
||||
|
||||
```
|
||||
---
|
||||
name: safe-worker
|
||||
description: Agent that cannot modify files
|
||||
disallowedTools:
|
||||
- write_file
|
||||
- edit
|
||||
- run_shell_command
|
||||
---
|
||||
```
|
||||
|
||||
If both `tools` and `disallowedTools` are set, the allowlist is applied first, then the blocklist removes from that set.
|
||||
|
||||
**MCP tools** follow the same rules. If a subagent has no `tools` list, it inherits all MCP tools from the parent session. If a subagent has an explicit `tools` list, it only gets MCP tools that are explicitly named in that list.
|
||||
|
||||
The `disallowedTools` field supports MCP server-level patterns:
|
||||
|
||||
- `mcp__server__tool_name` — blocks a specific MCP tool
|
||||
- `mcp__server` — blocks all tools from that MCP server
|
||||
|
||||
```
|
||||
---
|
||||
name: no-slack
|
||||
description: Agent without Slack access
|
||||
disallowedTools:
|
||||
- mcp__slack
|
||||
---
|
||||
```
|
||||
|
||||
#### Example Usage
|
||||
|
||||
```
|
||||
|
|
@ -532,7 +583,7 @@ Always follow these standards:
|
|||
|
||||
## Security Considerations
|
||||
|
||||
- **Tool Restrictions**: Subagents only have access to their configured tools
|
||||
- **Tool Restrictions**: Use `tools` to limit which tools a subagent can access, or `disallowedTools` to block specific tools while inheriting everything else
|
||||
- **Permission Mode**: Subagents inherit their parent's permission mode by default. Plan-mode sessions cannot escalate to auto-edit through delegated agents. Privileged modes (auto-edit, yolo) are blocked in untrusted folders.
|
||||
- **Sandboxing**: All tool execution follows the same security model as direct tool use
|
||||
- **Audit Trail**: All Subagents actions are logged and visible in real-time
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue