Securing a Persistent AI Agent

How to let an AI agent work on its own without handing it the keys: OpenAI's five safeguards explained, and how I apply them to my own agents.

Article Created Updated Also in German: Einen dauerhaft laufenden KI-Agenten absichern

Reviewed by adrian on

A chat agent waits for my question. A persistent agent does not: it runs all the time, starts work on its own and may write any code it needs to reach a goal. AI agents such as Hermes Agent can work like that. Kevin S Lin has described on the OpenAI developer blog how OpenAI runs hundreds of such agents safely (the post). This article retells it in plain words, gives a checklist and applies it to my own Hermes Agent.

Why OpenAI does this

After its internal OpenClaw pilot, OpenAI saw productivity and use jump, in technical and non-technical teams alike. More than 500 agents now work in the background there, for example opening pull requests from product feedback or running data experiments on new features all the time. At the same time there are no established best practices yet, which makes many companies hesitate to use such agents. The post shares what OpenAI has learned to close that gap.1

The core idea: trusted and untrusted

The biggest risk of such an agent is not only an attacker from outside. It is the agent itself doing something nobody wanted, because it misunderstood the task or because something it read steered it. So everything is split into two parts:1

  • Trusted: the parts that do exactly what they are configured to do, without judgment of their own: the network, identities, the sandbox and the component that configures the agent.
  • Untrusted: the agent, the environment it works in and every piece of code it writes.

Everything else follows from one rule: the untrusted part must never be able to change the trusted part.

1. Keep the control apart from the agent

OpenAI separates the gateway, which sets up and configures the agent, from the harness, where the agent works and runs code. They run in separate containers, at OpenAI even in separate clusters.1 If the agent breaks out of its sandbox, it finds nothing there that controls it.

The question for my own setup: can the agent edit its own configuration or its own permissions? If it can, these two parts are not separated yet.

2. Hard boundaries around the agent

The sandbox draws four boundaries:1

  • Network: the agent may only reach an allowlist of hosts that its task needs. A blocklist on top names what must never be reached. That covers paste sites and webhook catchers, which are handy for carrying data out. It also covers the cloud metadata address 169.254.169.254, where a cloud server hands out its credentials. A proxy enforces this, and the agent's own configuration cannot extend the list.
  • Files: the agent writes only in its workspace. Reference material is read-only, and the SSH keys (~/.ssh) are off limits.
  • Processes: commands run in an operating-system sandbox. Only the modes "read-only" and "write in the workspace" are allowed; full access is switched off by the administrator.
  • Secrets: the agent never sees them. A credential broker inserts them where they are needed, and tokens such as GH_TOKEN are removed from the environment of every command the agent runs. Removing them from the environment does not hide a key that lies in a readable file.

The configuration has two layers: an administrator file sets the limits, and the agent's configuration can only move within them, never widen them. Web search uses a cached index instead of the live web, and connections to other apps, including destructive operations, are off unless switched on.

3. A second model checks the actions

With auto-review, a second agent watches the first and approves its actions. OpenAI enforces it for every action of its OpenClaw agents.1 The gain: nobody has to click "allow" a hundred times a day and stop reading what they allow. People only look at the decisions that really matter. The post does not say which actions still go to a human.

4. The agent gets its own identity

The agent does not use my login. It has an identity of its own with its own key for the model, at OpenAI a service account.1 That brings three things:

  • The logs show whether I or the agent did something.
  • I can switch the agent off without locking myself out.
  • It gets exactly the access it needs, through service accounts linked to its identity.

Two IETF drafts are meant to standardize this: WAG for access in the agent's own name, XAA for acting on a person's behalf through OAuth delegation. Both are drafts, not finished standards.

5. Log everything, but protect the logs

Every change of the configuration and every step of the agent is logged. Only a small security group may read these logs, because the agent's steps can contain sensitive data.1

What the post leaves open

Memory, prompt injection, vetting skills and plugins, updates and what to do after an incident are not covered. For a ready-made setup, OpenAI points to OpenClaw Enterprise, an open-source control plane whose standard preset contains many of these safeguards. It is in a pilot, with version 1.0 planned by the end of the year.1

My checklist

These are my conclusions for agents I run myself, not statements of the post. One question sums them up: if the agent were confused or manipulated, what could it reach?

  1. Its own key: every agent gets an API key of its own, which I can revoke without touching anything else.
  2. No secrets in reach: no .env files, SSH keys or tokens in the folders the agent can read. Hiding variables is not enough if the key sits in a file.
  3. Writes only in its own folder: everything else is read-only or invisible to it.
  4. Limited network: at least no way into my own network or to the metadata address; better an allowlist of the hosts the task needs.
  5. No access to its own rules: configuration and permissions are files the agent cannot change.
  6. Approval for what cannot be undone: deleting, pushing, sending messages or paying needs a yes from me or from a second model.
  7. Logs: keep a record of what the agent did, and treat it as sensitive.

My knowledge base already follows point 6: agents only write drafts, and only my review publishes them.

Applied to my Hermes Agent

My Hermes Agent runs in Docker on my server. On 2026-11-15 I checked it against the checklist, read-only and from inside the container, as the user that runs the agent's commands.

In place:

  • The container is not privileged, has no Docker socket and sees only its data folder. Inside it, Hermes runs as its own user hermes, not as root.
  • The dashboard is reachable only through the WireGuard tunnel, and a firewall rule keeps the container away from my devices in the tunnel.
  • By default Hermes asks before commands it considers dangerous, and writes to its instruction files such as SOUL.md always need my approval (point 6, in part). Its web extraction refuses private and cloud metadata addresses.

Not met:

  • Points 2 and 5, secrets and its own rules: Hermes runs commands with the terminal backend local, in the same container and as the same user as the gateway. That user can read and change .env with the OpenRouter key, auth.json and config.yaml, and the dashboard password is in the gateway's environment. Gateway and agent are not separated.
  • Point 4, network: everything on the internet is open, paste sites and webhook catchers included. My provider's metadata service at 169.254.169.254 answers from the container; only the web tool skips it, a command in the terminal does not. The container also reaches the SSH ports of the server.
  • Point 1, its own key: whether the OpenRouter key is used by Hermes alone cannot be seen on the server.

What I will change, from little to more effort (a plan, not done yet):

  1. Block the metadata address for the container in the same DOCKER-USER chain as the tunnel, and the server's own SSH ports in its INPUT chain, since traffic to the host itself does not pass DOCKER-USER.
  2. Give Hermes an OpenRouter key of its own with a low spending limit, so that a stolen key costs little and can be revoked alone.
  3. Add config.yaml, .env and auth.json to security.protected_instruction_extra_patterns, so that writing them needs my approval like SOUL.md. Reading stays possible; that only ends with a sandbox for the commands outside the gateway's container.
  4. Later: an outbound proxy with an allowlist (OpenRouter, Exa) and a terminal backend that runs commands apart from the gateway.
  5. Sessions and logs lie in the data folder next to the keys; whoever can read one can read the other, so they are as sensitive (point 7).

The plan for a hosted MCP server already follows several of these points: remotely only reading and drafts, its own container, and short-lived tokens instead of a fixed key.

Open point: Hermes must not reach its own keys and rules

Status: proposal, open. To look at more closely before I change anything.

The most important lesson of the post for my setup is its first rule: the untrusted part must never be able to change the trusted part. On my Hermes Agent exactly this is not met. Its commands run as the same user as the gateway and can read and change the OpenRouter key, the login data and the configuration. In my assessment, a single page with hidden instructions that the agent reads would be enough to carry the key out or to loosen the approvals in its own configuration.

The proposal, in two steps:

  1. Soon, little effort: writing config.yaml, .env and auth.json needs my approval (security.protected_instruction_extra_patterns), and Hermes gets an OpenRouter key of its own with a low spending limit. That does not stop reading, but it limits the damage and makes the key easy to revoke.
  2. To examine: run the agent's commands apart from the gateway, so that they cannot see its files at all. Hermes knows other terminal backends besides local (its configuration has settings for Docker and Modal). Which one fits without giving the container the Docker socket, and what it costs in effort and money, is the open question.

Based on

More on this

Topic

  • AI Agents AI apps whose language model calls tools to get work done, such as Claude Code and Claude Desktop, and how to run them safely.

Sources

Mentioned

  • Hermes Agent Open-source AI agent by Nous Research with a web dashboard, desktop app, tools, skills and memory. Runs on your own server, for example in Docker.
  • Kevin S Lin Works at OpenAI and builds tools for humans and agents. Founder of the open-source note-taking tool Dendron.

See also

  • Hermes Agent on a VPS Behind WireGuard Guide: Hermes Agent in Docker on the VPS yaksha, dashboard behind Caddy and reachable only through WireGuard, container cut off from the tunnel network.
  • Securing a Hosted MCP Server Plan for a hosted MCP server for the knowledge base that claude.ai on the web and on mobile can use, while nobody else can.

Show in the graph view