Skip to the content

Lock an agent down for production

Turn 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.

Steps marked preview rely on a package that has not passed its release gate.

A shipped pack watches; a strict policy stops. It keeps your keys out of the agent's reach and out of its model's context, denies sending after reading a secret, and lets the agent reach only the sites you list. Start it recording, watch a week of what it would stop, then enforce it.

1. Write the strict policy, recording first

agentgarm policy init <agent> --strict writes the agent's pack in its strict form. It lists the sites the agent may reach: your project's package registries and its git remote's host, found without a network call (--no-detect skips that), and each --allow. Model calls go through AgentGarm's proxy and need no site entry; the policy refuses model names that the catalog knows have moved, and with --from-use it also lists the model makers this machine's records show the agent calling (agentgarm models shows them). Before it writes, it shows the sites and why each is there, the models block, what changes from the shipped pack, the mode, and the release it needs: a strict policy needs AgentGarm 0.5.0 or later. --yes skips its question once agentgarmd has answered; when it cannot be reached, the command says what it could not check and asks in your terminal even with --yes. --dry-run prints the YAML instead.

Add --audit-first, which writes mode: audit. The policy then records what it would stop and stops nothing, except one thing: secrets in requests to the model are replaced in either mode (on_model_request: redact), because that changes what the model sees, not what the agent may do. An existing policy file is replaced only with --force; a file you edited by hand loses your edits, so print the strict lines with --dry-run and merge them in instead.

agentgarm policy init claude-code --strict --audit-first --no-detect --allow github.com --yes
agentgarm policy init claude-code --strict --audit-first --no-detect --allow github.com --dry-run
systemctl --user restart agentgarmd
sudo 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, macOS

Checked by the walk: this command ran as written on a no-root Linux install, and the output showed mode: audit and on_model_request: redact.

The dashboard's Policy screen: secret protections, what enforce would change, and each policy file with its state

2. Put the agent's keys in the broker

preview

A strict policy hands the agent its provider keys from the broker, never from your shell, so enrol each key the agent uses before its first launch: sudo agentgarmd broker secret set <provider> on a root install, or with --user on a no-root one. Then take the key out of your shell profile and the project's .env files. agentgarm doctor reads the project's .env files (--project names another directory) and its workspace secrets check names the variables that still hold a secret, never their values, with the move for each. The dashboard's Policy screen shows the same five protections, in its Secret protections card, as on, recorded only or off.

sudo agentgarmd broker secret set openai          # root install
agentgarmd broker secret set openai --user        # no-root install
agentgarm doctor --project .

3. Watch a week of what it would stop

Work as usual with agentgarm run. On the dashboard's Policy screen, What enforce would change counts the last seven days' actions the policy would have stopped, rule by rule, and each decision it would have denied reads Would deny · audit wherever it shows. Activity's Would change filter lists them all. A connection to a site the policy does not list is recorded the same way. For each one, decide whether the agent needs it.

agentgarm run -- claude
agentgarm ui --open
The dashboard's Activity screen: filters and a search, then the recorded decisions with their outcomes

4. Add a site the agent needs

agentgarm policy allow-endpoint <host[:port]> adds an exact host to the policy's list of sites, and to the names it may resolve, shows the change and asks before writing. Without --policy or --agent it changes the one policy that lists sites. Restart agentgarmd afterwards, as in the first step.

Some sites are never added, each with the reason: direct DNS and DNS-over-HTTPS resolvers, model providers and subscription backends (their calls already go through the proxy), local, private and cloud metadata addresses. Once enforced, a tunnel to a site that is not listed is refused, and the dashboard's Alerts screen says Nothing reached the site, with this command to copy.

agentgarm policy allow-endpoint pypi.org --yes
systemctl --user restart agentgarmd

5. Enforce it

When What enforce would change shows only what you mean to stop, run agentgarm policy enforce claude-code (the card shows it with the agent's name), which changes mode: audit to mode: enforce in place, shows the change and asks, then restart agentgarmd. It keeps every other line: policy init --strict --force would write the shipped pack's strict form afresh and drop the sites allow-endpoint added. The Secret protections card then reads Strict, and the policy denies a call that carries a secret it recognises and a send after a secret was read. Both are detections, not proof: a secret in a form the rules do not know, or one the agent transforms first, can still leave (Keep secrets and card numbers out of prompts). A models list written with --from-use --models-audit keeps recording after this: agentgarm policy enforce claude-code --models enforces it on its own, and the Policy screen's Models card shows which (Limit an agent to the models you approve).

systemctl --user restart agentgarmd
sudo 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, macOS

See also

Watch your agent for a week, then enforce

Start a policy in audit mode, see what enforcing it would have blocked in your own history, fix the rules that get in the way, then switch it to enforce.