Permissions
Tools gave the model hands. Some of what it asks for is harmless, such as reading a file. Some is not: running a command, changing a file, or reaching the web. A person can't read every call, and shouldn't have to. So who decides which calls run, and how does an agent wait for you without stopping everything else?
The idea
In agents generally
Before a tool call runs, the program asks one question: may it? There are three answers:
- Allow. It runs at once.
- Ask. A person decides, and the agent waits.
- Deny. It does not run, and the model reads why, so it can try something else.
The answer comes from rules. A rule names a tool, and can narrow it: a command that starts with pytest, or any path that ends in .env. Rules are read in order, and the first one that fits decides. Defaults sit at the end of the list. Reading is usually allowed, because it changes nothing, and everything else asks.
Asking is the expensive answer. Every question interrupts you, and a person who is asked too often starts to say yes without reading. So a good agent asks rarely, and lets one answer cover more: "allow this for the rest of the chat", or "always allow this exact command".
How agents usually do it
| Approach | How it works | Good at | Costs |
|---|---|---|---|
| Ask every time | Every call that changes something waits for a yes | Nothing happens without you | You get tired, and start saying yes without reading |
| Modes | One switch for the whole chat: read-only, ask, or allow everything | Easy to understand | Too coarse: one risky tool forces the strictest mode |
| Rules | Allow, ask, or deny per tool, subject, and path, first match wins | Precise, and the rules can be shared | Rules take effort to write, and a wrong one is silent |
| A model as judge | A second model reads each call and decides | Few questions | It can be fooled, and costs a model call per tool call |
Most agents mix these: rules, with defaults that ask, and answers that become rules.
Every version has to answer the same questions:
- Who may write the rules. A rule file inside a project travels with the repository. A cloned repository should not be able to allow itself to run commands.
- What one yes covers. This call only? The same command? The same tool on any file?
- How to wait. A question can stay open for hours. Holding the run in memory loses it when the program restarts.
- What the model reads. A denied call should come back with a reason, not a crash.
How golem does it
In golem
golem uses rules, checked in one order, and a question for anything the rules leave open. The check runs in the tools node, before any call runs (Tools).
One call, in the order it is checked:
- The project's rules, in
.golem/policy.toml. They come first, so a repository can say "never readsecrets/" for everyone who works in it. Theirallowrules count only when you list the folder intrusted_projects. - Your rules, in
~/.golem/config.toml. - The defaults. Read-only tools and internal ones, such as
todo_write, are allowed. The session's permission mode may allow more (ADR-047). Everything else asks. - The first match decides.
allowruns the call.denyfails it with the rule's name, and the model reads why. - An ask runs at once if you already allowed the same call for this session. Otherwise the run pauses with
approval.needed, and the TUI shows the question. - Your answer is one key: allow once, for the session, always (which writes a rule), edit the arguments, or deny.
Here is a real run, recorded against a throwaway home with qwen3-coder:30b on a local Ollama. The project's .golem/policy.toml has one rule, read_file on **/.env is deny. The message was First run `python3 app.py` with the shell tool. Then read the file .env with read_file.
seq event data
6 tool.requested shell python3 app.py
7 tool.requested read_file .env
8 approval.needed shell python3 app.py built-in default
9 approval.resolved allow_session
10 tool.started shell
12 tool.completed exit 0
13 tool.failed read_file: the project's rule 1
81 message.completed "…I can try using the shell tool…"
82 tool.requested shell python3 app.py && cat .env
83 approval.needed shell built-in default
84 approval.resolved deny
85 tool.failed the user denied this tool call
187 run.completedThe reply at line 6 asks for two calls. The node decides about both first: the shell command asks, and read_file .env is denied. Nothing runs until the answer at line 9. Then the shell runs, and only after it is the denial reported. Line 13's full message is read_file is denied by /private/tmp/g.vn5G/proj/.golem/policy.toml rule 1.
The model then tried to read the file another way, with cat in the shell. That command is not the one allowed for the session, so it asked again, and the answer was no. One rule, and one question, kept the file closed.
Where it lives in the code:
packages/daemon/golem/permissions/engine.py:check,matches, andsession_allows. No I/O.packages/daemon/golem/permissions/policy.py:Policy, which reads the rule files and builds the list in order, andexplain.packages/daemon/golem/graphs/tools_node.py:_decide, which asks the policy, then the session, then you.packages/daemon/golem/sessions/approvals.py:pending_approval, the call a run waits on, read from its events.
Why this way
First match wins, and a project cannot allow itself (ADR-012). "The most specific rule wins" is hard to define and hard to predict. The first match is the order you read in the file. The project comes first, so its deny rules hold even when you allow more. But a project's allow counts only in a trusted folder, or a cloned repository could ship tool = "*", action = "allow".
An approval is an interrupt, and the waiting run has no task (ADR-013). Keeping a task alive to wait for you would lose the question on a restart, and hold memory for every waiting run. So the run stops in the checkpoint and the event log, and a new task resumes it when you answer. It can wait for days.
Decide every call first, then run them. A resumed node runs again from its first line. If it had run one call before asking about the next, the resume would run it twice. So nothing runs, and nothing is reported, before the last answer.
One yes covers one exact call. "For the session" and "always" cover the same tool on the same subject: one command, one file, one host. A command that differs by one character asks again, as cat .env did above.
Try it
Open the chat with
golem tuiin a project folder, and type/debug wire.Ask:
Run ls in the shell.The approval band showsAllow shell ls?, the rule that asked, and the keys. Presss, then ask forlsagain: it runs without asking.Add a rule to the project, in
.golem/policy.toml:toml[[rule]] tool = "read_file" path = "**/.env" action = "deny"Then ask the model to read
.env. The panel showstool.failedwith the rule's name, and no question.Type
/permissionsto see every rule in the order it is checked, and what this chat allows.golem config showprints the same in a shell.
The details
For contributors: the reference for the rule order, approvals, and edited arguments.
The order rules are checked in
Tool rules are checked in this order, and the first one that matches decides (ADR-012):
<session folder>/.golem/policy.toml, which holds only[[rule]]entries. Itsallowrules count only when the folder is intrusted_projects. Itsaskanddenyrules always apply. A file that does not validate makes every call in that folder ask.[[rule]]in~/.golem/config.toml. A file that stops validating keeps its last good rules.- The defaults: read-only tools and internal ones (
todo_write) are allowed, and everything else asks. The permission mode (careful,balanced,autopilot) adds tools to the allowed ones (ADR-047). EachToolnames the first mode that allows it inallow_from, withoffline_onlyforshell, whichautopilotallows only while[shell] networkis off, andPolicy.rules(root, registry, mode)builds the defaults for the mode, with the sourcebuilt-in default (<mode>). The mode is[permissions] modeinconfig.tomlunless the session set its own withsession.set_mode, which storessession.mode.changedand keeps the value insessions.permission_mode.config.getreportsdefault_permission_mode, andpermission_modefor the session it was asked about.
Both files are read again when they change. A deny ends the call in tool.failed, without tool.started, and the model reads why. An ask waits for you (below). golem config show prints the settings and the rules for the folder it runs in, in that order, through config.get.
What a rule matches (golem/permissions/engine.py):
| Field | Matches | How |
|---|---|---|
tool | The tool's name | A glob. * is every tool, mcp__git__* every tool of one server |
match | The tool's subject: a shell command, a search pattern, a web host | A glob, with | between alternatives |
path | The resolved absolute path the call touches | * stays in one folder, ** crosses folders, ~ is the home folder, and a relative glob starts at the session folder |
A rule written for one exact call escapes its subject, so *, ?, [, and | in a command mean themselves.
Approvals
A call a rule asks about pauses the run (ADR-013).
The pause. The tools node decides about every call of the reply first, and calls interrupt() for the first one that asks. The run's task ends after approval.needed, and the run row is waiting. Nothing is in memory, so closing the TUI or restarting the daemon loses nothing. session.list reports the session as waiting.
The answer. approval.respond names the session, the call, and allow, allow_session, allow_always, or deny.
- Edited arguments. With
allowit may carry editedargs: the daemon checks them against the tool and the rules first (-32011when refused, and the run keeps waiting), records them inapproval.resolved, and the call runs once with them, its result starting with a note to the model. - The resume. The daemon reads the pending call from the run's events, stores
approval.resolved, and starts a new task that resumes the graph withCommand(resume=...), which carries the decision and the diffapproval.neededshowed. - From the top. The node runs again from its first line. Earlier answers come back from LangGraph, the next call that asks pauses again, and only after the last answer does any call run. So no call runs twice, and no event is repeated.
For the session. allow_session also allows the same call for the rest of the session, without asking again. The key is the tool and its subject (shell with git status), or the tool alone when it has no subject, and it is stored in sessions.allowed_tools. A deny rule still wins over it. A denied call ends in tool.failed, and the model reads the user denied this tool call.
Always. allow_always writes an allow rule for exactly this call, first in ~/.golem/config.toml with tomlkit so comments stay: the tool with its subject as match (escaped, so *, ?, [, and | mean themselves), else its resolved path, else the tool alone. approval.resolved names the rule. Only the daemon writes it, and only for an answer you gave.
Order on resume. LangGraph matches answers to interrupts by their order in the node. A rule written while the run waited could make an asked call skip its interrupt and hand its answer to the next one. So the resume passes the call ids this run already asked about, those calls always interrupt again and get their own answer, and a call before the last asked one that would ask only because the rules changed fails with the rules changed while the run waited.
While it waits. message.send answers SESSION_BUSY. run.cancel, Ctrl-C, or session.close ends the run: each open call fails with cancelled before it was approved, then run.cancelled. A daemon stopping leaves a waiting run as it is.
Edited arguments
e in the approval band opens the call's arguments as JSON in the composer's place. Enter sends approval.respond with decision: "allow" and args, and Esc goes back to the question (ADR-015).
- Only a real edit counts. Arguments sent back unchanged are not an edit: the TUI does not send them, and the daemon drops them.
- Once only. An edited call is not one you have seen before, so it does not become a session allowance or a rule.
- No diff check. You approved the arguments you typed, not the diff shown for the old ones, so an edited file change is applied as planned when it runs.
Files
| File | What it does |
|---|---|
packages/daemon/golem/permissions/engine.py | Rule, Call, Decision, check, matches, exact_match, session_allows |
packages/daemon/golem/permissions/policy.py | Policy: the rule files, trusted_projects, [shell] and [web], and explain |
packages/daemon/golem/graphs/tools_node.py | _decide, Answer, and the interrupt |
packages/daemon/golem/sessions/approvals.py | pending_approval: the call a run waits on |
packages/daemon/golem/config_edit.py | Writes "always allow" rules, and /permissions changes, with tomlkit |
Read more
- Next: Sandboxes, what a command you allowed can still not do.
- Before: Tools.
- Tools and permissions, the user's guide to rules and the approval band.
- The overview: the whole system on one page.