Skip to content

Commit 888cf76

Browse files
authored
Merge pull request #2241 from trungutt/feat/global-permissions
docs: document global permissions from user config
2 parents d6f7884 + 03e961b commit 888cf76

3 files changed

Lines changed: 70 additions & 2 deletions

File tree

docs/configuration/overview/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ providers:
5353
base_url: https://api.example.com/v1
5454
token_key: MY_API_KEY
5555

56-
# 7. Permissions — global tool permission rules (optional)
56+
# 7. Permissions — agent-level tool permission rules (optional)
57+
# For user-wide global permissions, see ~/.config/cagent/config.yaml
5758
permissions:
5859
allow: ["read_*"]
5960
deny: ["shell:cmd=sudo*"]

docs/configuration/permissions/index.md

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,18 @@ Permissions provide fine-grained control over tool execution. You can configure
1919

2020
</div>
2121

22-
## Configuration
22+
## Permission Levels
23+
24+
Permissions can be defined at two levels:
25+
26+
| Level | Location | Scope |
27+
| ----- | -------- | ----- |
28+
| **Agent-level** | Agent YAML config (`permissions:` section) | Applies to that specific agent config |
29+
| **Global (user-level)** | `~/.config/cagent/config.yaml` under `settings.permissions` | Applies to every agent you run |
30+
31+
Both levels use the same `allow`/`ask`/`deny` pattern syntax. When both are present, they are **merged** at startup -- patterns from both sources are combined into a single checker. See [Merging Behavior](#merging-behavior) for details.
32+
33+
## Agent-Level Configuration
2334

2435
```yaml
2536
agents:
@@ -42,6 +53,42 @@ permissions:
4253
- "dangerous_tool"
4354
```
4455
56+
## Global Permissions
57+
58+
Global permissions let you enforce rules across **all** agents, regardless of which agent config you run. Define them in your user config file:
59+
60+
```yaml
61+
# ~/.config/cagent/config.yaml
62+
settings:
63+
permissions:
64+
deny:
65+
- "shell:cmd=sudo*"
66+
- "shell:cmd=rm*-rf*"
67+
allow:
68+
- "read_*"
69+
- "shell:cmd=ls*"
70+
- "shell:cmd=cat*"
71+
```
72+
73+
This is useful for setting personal safety guardrails that apply everywhere -- for example, always blocking `sudo` or always auto-approving read-only tools -- without relying on each agent config to include those rules.
74+
75+
### Merging Behavior
76+
77+
When both global and agent-level permissions are present, they are merged into a single set of patterns before evaluation. The merge works as follows:
78+
79+
- **Deny patterns from either source block the tool.** A global deny cannot be overridden by an agent-level allow, and vice versa.
80+
- **Allow patterns from either source auto-approve the tool** (as long as no deny pattern matches).
81+
- **Ask patterns from either source force confirmation** (as long as no deny or allow pattern matches).
82+
83+
The evaluation order remains the same after merging: **Deny > Allow > Ask > default Ask**.
84+
85+
<div class="callout callout-tip">
86+
<div class="callout-title">Example: Global deny + agent allow
87+
</div>
88+
<p>If your global config denies <code>shell:cmd=sudo*</code> and an agent config allows <code>shell:cmd=sudo apt update</code>, the deny wins. Deny patterns always take priority regardless of source.</p>
89+
90+
</div>
91+
4592
## Pattern Syntax
4693

4794
Permissions support glob-style patterns with optional argument matching:

docs/guides/tips/index.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,26 @@ permissions:
232232
docker-agent run --sandbox agent.yaml
233233
```
234234

235+
### Set Global Permission Guardrails
236+
237+
Use [global permissions]({{ '/configuration/permissions/' | relative_url }}#global-permissions) in your user config to enforce safety rules across every agent:
238+
239+
```yaml
240+
# ~/.config/cagent/config.yaml
241+
settings:
242+
permissions:
243+
deny:
244+
- "shell:cmd=sudo*"
245+
- "shell:cmd=rm*-rf*"
246+
- "shell:cmd=git push --force*"
247+
allow:
248+
- "read_*"
249+
- "shell:cmd=ls*"
250+
- "shell:cmd=cat*"
251+
```
252+
253+
These rules merge with any agent-level permissions. Deny patterns from your global config cannot be overridden by agent configs, so you can trust that dangerous commands stay blocked regardless of which agent you run.
254+
235255
### Use Hooks for Audit Logging
236256

237257
Log all tool calls for compliance or debugging:

0 commit comments

Comments
 (0)