Guide 17 of 81 · Writing policy
Limit an agent to the models you approve
See which models your agents call, list the makers you approve, record the list, then enforce it, on one machine or across a fleet in Central's console.
An agent can call any model its key reaches. A model list in its policy names the makers, and the models by name, that it may call; AgentGarm refuses the rest before the request leaves the machine and tells the agent why. Start from what the agent already uses, record the list first, then enforce it: on one machine with the command line, or for a fleet from Central's console.
1. See which models your agents call
agentgarm models lists the models each agent called on this machine in the last 7 days (--days up to 35, --agent for one agent): the model, who trained it, who served it, how many calls, and what the policy in force makes of it. With no model rules it reads allowed (no model rules); with no records it says No model calls recorded in the last 7 days.
agentgarm models why explains one name: who trained it (Trained by), whether the name is pinned or pinning not verified, whether the catalog lists it, every spelling a rule matches, and the verdict under the agent's policy with its rule. A model AgentGarm cannot identify is one the catalog does not list yet; a floating name is one the provider can point at different weights.
agentgarm modelsagentgarm models --agent claude-code --days 30agentgarm models why --provider openai --model example-modelChecked by the walk: these commands ran as written on a no-root Linux install, and the output showed Trained by.
2. Build a list in a copy of the policy
agentgarm policy allow-model adds one entry to a policy's models section in place, shows the change and what it would have admitted or refused in the last 7 days, and asks before writing: a maker (its models at any provider; with --provider, at that one), a provider, one model by exact name at a provider (--model), or a provider whose requests may name no model (--unnamed). The first maker or provider starts the list, so it needs --start-list and says This starts the list: every model no rule names is then refused.
Try it on a copy first. --policy names the file; --agent names the policy in force (agents.d/<agent>.yaml). A model allowed by name is admitted whatever the list and the switches say; a deny rule still wins.
agentgarm policy init claude-code --dir models-trialagentgarm policy allow-model --policy models-trial/claude-code.yaml --start-list anthropic --yesagentgarm policy allow-model --policy models-trial/claude-code.yaml openai --yesagentgarm policy allow-model --policy models-trial/claude-code.yaml --provider openai --model ft:example-model:acme::abc --yes
agentgarm policy allow-model --policy models-trial/claude-code.yaml --provider bedrock --unnamed --yesChecked by the walk: these commands ran as written on a no-root Linux install, and the output showed This starts the list.
3. Read the whole models section
The section lives under security_boundaries. allow is the list; named and unnamed are the exceptions the previous step added. deny_unknown_model: true refuses models AgentGarm can't identify, which includes any model newer than this AgentGarm's catalog until the catalog is updated. deny_floating: true refuses the floating names the catalog knows have moved; most names are not verified either way. on_internal_error: fail_closed refuses a call AgentGarm could not check in time, and the agent retries.
For OpenRouter, routing: pinned refuses a request that lets OpenRouter choose the model or the serving provider, allow_providers names the serving providers it may use, and data_collection: deny requires the request to ask OpenRouter not to keep it. The section's own mode: audit records what the list would refuse while the rest of the policy enforces.
security_boundaries:
models:
mode: audit
allow:
- maker: anthropic
- maker: openai
named:
- { provider: openai, model: "ft:example-model:acme::abc" }
unnamed: [bedrock]
deny_unknown_model: true
deny_floating: true
on_internal_error: fail_closed
openrouter:
routing: pinned
allow_providers: [anthropic, google-vertex]
data_collection: denySee also
Route other model providers through the proxySend Gemini, Bedrock, Vertex, Azure, OpenRouter, Groq, DeepSeek and local-runtime calls through the proxy, accounted, budgeted and checked for secrets.
4. Test the list before it is in force
A replay line can be a model: a provider, a model as the agent asks for it, or "naming": "no_model" for a request that names none (with an unnamed_kind such as router). AgentGarm fills in who trained it from its catalog, as the proxy does. agentgarm policy test compares each line's expect with the enforce verdict and ends with a count such as 4 events, 4 passed, 0 failed; -v prints the rule that decided each line.
echo '# What the models list must admit and refuse.' > model-tests.jsonl
echo '{"model": {"provider": "anthropic", "model": "example-model"}, "expect": "allow"}' >> model-tests.jsonl
echo '{"model": {"provider": "openai", "model": "example-model"}, "expect": "allow"}' >> model-tests.jsonl
echo '{"model": {"provider": "deepseek", "model": "example-model"}, "expect": "deny"}' >> model-tests.jsonl
echo '{"model": {"provider": "openrouter", "naming": "no_model", "unnamed_kind": "router"}, "expect": "deny"}' >> model-tests.jsonlagentgarm policy test models-trial/claude-code.yaml --against model-tests.jsonl -vChecked by the walk: these commands ran as written on a no-root Linux install, and the output showed 4 passed, 0 failed.
See also
Test a policy before you ship itWrite what a policy must allow, ask about and deny as a file of events, replay it before you install the policy, and keep both in your repository.
5. Record the list for a week
On the policy in force, agentgarm policy allow-model --from-use --models-audit --agent claude-code starts a list from this machine's records: every maker the agent called 20 times or more in the last 7 days, with both switches, and it says what it left out. --models-audit writes the section's mode: audit, so a model the list would refuse is let through and recorded while the rest of the policy keeps enforcing. With no maker called 20 times it shows what it found and writes nothing. Restart agentgarmd to load the change.
The dashboard's Policy screen shows the list in its Models card, one block per policy, each row on, recorded only or off, with the last 7 days (2 calls would have been denied) and what holds on this machine. Each recorded refusal reads Would deny · audit in Activity and in the run's timeline, with the sentence the agent would have read, and What enforce would change groups them by rule.
agentgarm policy allow-model --from-use --models-audit --agent claude-codesystemctl --user restart agentgarmdsudo systemctl restart agentgarmd # root install, Linux
sudo launchctl kickstart -k system/com.agentgarm.agentgarmd # root install, macOS
launchctl kickstart -k gui/$(id -u)/com.agentgarm.agentgarmd # no-root install, macOSagentgarm ui --open6. Enforce the list
When the week shows only what you mean to refuse, agentgarm policy enforce claude-code --models changes the section's mode: audit to enforce in place, every other line kept, shows the change and asks; then restart agentgarmd. A refused call never reaches the provider: the agent gets an error that starts A request to the model was stopped: and says why in one sentence, and the dashboard shows the call as Denied in the run's model lane, a burst of retries as one row with a count.
agentgarm policy enforce claude-code --modelssystemctl --user restart agentgarmdsudo systemctl restart agentgarmd # root install, Linux
sudo launchctl kickstart -k system/com.agentgarm.agentgarmd # root install, macOS
launchctl kickstart -k gui/$(id -u)/com.agentgarm.agentgarmd # no-root install, macOS7. Act on a denied model call
Open the row in the run, or in Activity under Model calls: it names the model, who trained it and who served it, the rule and the policy, and the next step for that reason. A maker off the list offers the command that allows this one model by name, and behind it the one that adds the maker. A model refused by name offers agentgarm models why instead, since allowing it would not change that. For a model AgentGarm can't identify, update AgentGarm or allow it by name; for a floating name, ask for a dated version. A request that names no model through a router or a preset needs the model named in the agent's settings.
A call AgentGarm could not check in time shows as an alert; retrying is safe, and agentgarm doctor checks why it happened. When a policy comes from your organisation's Central bundle, the row names no command: ask your AgentGarm admin. Allowing is always a policy change you make outside the agent's task; nothing the agent reads carries a command.
agentgarm policy allow-model --agent claude-code --provider openai --model example-modelagentgarm models why --provider openai --model example-model --agent claude-codeagentgarm doctorSee also
Lock an agent down for productionTurn on all five secret protections for an agent: record what a strict policy would stop for a week, list the sites it needs, then enforce it.
8. See which models run across a fleet
With Central, the console's Models section, in the Fleet group after Inventory, answers which models run on your machines, who trained them and who served them. One sentence above the table gives the totals for the whole range, such as 21 models from 5 makers on 37 hosts · 2 denied somewhere · 1 answered as another model. Each row is a model at a route: the model and who trained it (not in the catalog when Central's catalog does not list the name, and a Floating badge for a name that has pointed to different weights), Served by (the route, and in brackets who served the call behind an aggregator such as OpenRouter, as the provider reports it: not reported when its answer did not say, not recorded for calls from before Central counted it, a date the line Denials and serving providers are counted since gives), the hosts and the calls.
By vN's rules says what the newest published bundle's rules make of the name: Allowed, Refused, Refused by 2 of 6 policies (of those with model rules), Would deny · audit (only policies in audit mode refuse it, so it is recorded and not stopped; beside a refusal it reads would deny by 1 (audit)) or No model rules, then what happened on the machines, such as denied 6× or would deny 16×. It describes the newest bundle, not every machine: one can still be on an older bundle. Filter by range, maker and serving provider, or show only the models denied somewhere or those not in the catalog; the filters are in the page's link. Open a row for the machines that called it, its calls per day and its denials by reason; Export CSV saves every page.
The rules column, the denial counts and the Denied filter need a role that may read policy (owner, admin, security or auditor). A role scoped to a host group sees only its machines (on 9 of your 14 hosts). The index counts by machine and model, not by agent; on a machine, agentgarm models gives each agent's. To look around first, open Models in the console demo.
See also
Tour the fleet console in the demoWalk Central Lite's console on a fictional company's synthetic data: machines, an incident, a kill order, costs, models, outbound inspection and access.
9. Draft the fleet's model rules from what it uses
Draft model rules from this list, under the table, opens a sheet that writes the models section for one agent's policy file. Pick the agent's policy, then the makers its models may come from: every maker the fleet called in the period, most used first, with its calls and hosts by any agent. A maker with fewer than 10 calls is not ticked, and says why; models with no known maker and requests that name no model are listed below, with what the draft would do to them. Two switches, Refuse models AgentGarm can't identify and Refuse floating names, each say what they alone would have refused. Record first, the default, writes the section's mode: audit; Enforce now writes mode: enforce.
As you change it, What this draft would refuse counts the models and calls of the period. Below are the lines, the change against your current file (paste it under Compare with the current file) and the commands that commit and attest it. The console never sends policy text: commit the change to the policy repository, then publish. The draft writes makers and the two switches; a model by name or a provider whose requests may go unnamed is a named or unnamed entry, which agentgarm policy allow-model --policy adds to the file in your checkout.
See also
Roll out policy from git with canariesKeep agents.d policies in git and let Central Lite roll each signed commit out to canaries, then the fleet, halting by itself when machines report trouble.
10. Publish the list and see what it refuses
In Policies and rollouts, Publish from the repository opens the Publish sheet. Beside Compatibility, its Model rules panel compares the bundle's model rules with the fleet's model calls of the last 30 days: This bundle would refuse 2 models that 4 hosts called in the last 30 days, with the list; This bundle refuses no model the fleet has used; or Could not check model use when Central could not read them in time, which never blocks the publication. Published bundles then shows each bundle's Models: Listed in every policy, Listed in 4 of 6 policies or Any model.
A bundle with a models section needs AgentGarm 0.5.0, so a machine on an older release keeps the bundle before it until it is updated. On each machine, a refused call's next step reads Set by your organisation's policy bundle and names no command. When the recorded weeks show only what you mean to refuse, switch the section to enforce in your checkout, commit and publish again.
agentgarm policy enforce --models --policy agents.d/claude-code.yamlSee also
Roll out policy from git with canariesKeep agents.d policies in git and let Central Lite roll each signed commit out to canaries, then the fleet, halting by itself when machines report trouble.