mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-20 10:10:56 -07:00
feat(core): refactor subagent tool to unified invoke_subagent tool (#24489)
This commit is contained in:
@@ -521,6 +521,24 @@ field.
|
||||
}
|
||||
```
|
||||
|
||||
#### Safety policies (TOML)
|
||||
|
||||
You can restrict access to specific subagents using the CLI's **Policy Engine**.
|
||||
Subagents are treated as virtual tool names for policy matching purposes.
|
||||
|
||||
To govern access to a subagent, create a `.toml` file in your policy directory
|
||||
(e.g., `~/.gemini/policies/`):
|
||||
|
||||
```toml
|
||||
[[rule]]
|
||||
toolName = "codebase_investigator"
|
||||
decision = "deny"
|
||||
deny_message = "Deep codebase analysis is restricted for this session."
|
||||
```
|
||||
|
||||
For more information on setting up fine-grained safety guardrails, see the
|
||||
[Policy Engine reference](../reference/policy-engine.md#special-syntax-for-subagents).
|
||||
|
||||
### Optimizing your subagent
|
||||
|
||||
The main agent's system prompt encourages it to use an expert subagent when one
|
||||
|
||||
@@ -438,6 +438,33 @@ decision = "ask_user"
|
||||
priority = 10
|
||||
```
|
||||
|
||||
### Special syntax for subagents
|
||||
|
||||
You can secure and govern subagents using standard policy rules by treating the
|
||||
subagent's name as the `toolName`.
|
||||
|
||||
When the main agent invokes a subagent (e.g., using the unified `invoke_agent`
|
||||
tool), the Policy Engine automatically treats the target `agent_name` as a
|
||||
virtual tool alias for rule matching.
|
||||
|
||||
**Example:**
|
||||
|
||||
This rule denies access to the `codebase_investigator` subagent.
|
||||
|
||||
```toml
|
||||
[[rule]]
|
||||
toolName = "codebase_investigator"
|
||||
decision = "deny"
|
||||
priority = 500
|
||||
deny_message = "Deep codebase analysis is restricted for this session."
|
||||
```
|
||||
|
||||
- **Backward Compatibility**: Any rules written targeting historical 1:1
|
||||
subagent tool names will continue to match transparently.
|
||||
- **Context differentiation**: To create rules based on **who** is calling a
|
||||
tool, use the `subagent` field instead. See
|
||||
[TOML rule schema](#toml-rule-schema).
|
||||
|
||||
## Default policies
|
||||
|
||||
The Gemini CLI ships with a set of default policies to provide a safe
|
||||
|
||||
Reference in New Issue
Block a user