Docs
How your agent meets the world
Where the agent and its model run, how work reaches it, what it sees, and how to bring a coding agent.
"The agent" is usually two things: the program that does the work, and the model that program calls. In a world they sit in different places, as they would at work. This page explains where each one runs, how work reaches the agent, what it can see, and how to bring a coding agent such as Claude Code.
The program runs inside, the model stays where it is
your computer engine: the mirror's own Linux VM
┌──────────────────┐ ┌──────────────────────────────────────────────────┐
│ mirror │ Docker API │ the company's network │
│ starts the run, │ ─────────▶ │ ┌──────────────┐ ┌────────────────────────┐ │
│ scores it │ only │ │ your agent │ ───▶ │ gateway │ │
│ │ │ │ ws-6528 │ │ git.<domain> → Gitea │ │
│ your model key │ │ │ your image, │ │ chat.<domain> → chat │ │
│ stays here │ │ │ unchanged │ │ model host ──┐ │ │
└──────────────────┘ │ └──────────────┘ └────────────────┼───────┘ │
│ real key added │ │
└────────────────────────────────────────┼─────────┘
▼
the model provider
The program runs inside the world. In the default mode, hosted, your agent's container image runs unchanged on the company's network, as an ordinary workstation with a name such as ws-6528. From there it reaches the company's systems at the hostnames it would use at work, git.halden-freight.com and chat.halden-freight.com, over TLS signed by the company's root. It signs in as the employee it acts as (acts_as in the agent file).
The model stays where it always is. When the program calls its model at api.anthropic.com, the world's resolver sends that name to the gateway. The gateway removes the placeholder key the agent holds, adds your real key, forwards the call and records the exchange. It is the only way out of the world (see architecture.md). Agents at a company call cloud models over the network too, so the model being outside is what the agent would expect. The model never reaches the world itself: it sees only the text the program sends it, which comes from the world.
A model on your own computer or a company server works the same way, as a self-hosted model route in mirror.yaml.
How work reaches it
mirror run <scenario> --agent <name> does three things:
- It restores the world from its snapshot and makes the scenario's changes, such as a token committed to a repository.
- It hands over the work through the company's own channels: a manager assigns the agent's person an issue, or a colleague asks something in a channel or a direct message.
- It starts the agent. With
wake: {type: command}, a command runs once the work has arrived, the way a job runner or webhook would start it. Withwake: {type: poll}, the agent's own process is already running and notices the new issue or message itself.
The agent is not told it is being tested. It finds work in its queue.
What it can see
- The systems it is granted, and nothing else. Grants are exact: a repository or channel not in
grantsanswers as if the agent's person had no access. See agent-file.md. - Its credentials as variables, in the form a deployment would have them:
GITEA_URLandGITEA_TOKEN,MATTERMOST_URLandMATTERMOST_TOKEN, and a placeholder model key in the provider's format. - The company's root certificate in the image's system trust store. Clients with their own bundle need pointing at it:
SSL_CERT_FILEfor Python,NODE_EXTRA_CA_CERTSfor Node.js and Claude Code. - An ordinary workstation: a host name in the company's convention, an office address, the company's resolver, and nothing that names the mirror.
docs/tells.mdlists every way a test was found to show itself, and how each was closed.
An agent talks to the systems through their APIs (Gitea's and Mattermost's own), through the world's MCP server, or through their web pages with a managed browser (mode: browser). your-company.md explains the three.
What happens to everything else it tries
Anything the agent tries that is not a granted system or the model route is refused and recorded: a lookup of a name the world does not have, a connection to an outside address, a call to one of the model provider's other endpoints, which gets the provider's own not-found answer. The run's result lists these attempts under egress, and the scenario's checks decide what they mean.
This matters for off-the-shelf agents, which often call home: update checks, telemetry, error reports. In a world those calls fail and show up in the record. Turn them off in the image, as a company deploying the agent on a closed network would. The example below shows how for Claude Code.
Bringing a coding agent
examples/agents/coding-agent/ runs Claude Code headless inside the world, as an engineer at the company would deploy it to work through their issues and messages:
| File | What it does |
|---|---|
Dockerfile |
Installs git, curl and jq, then Claude Code from npm at a pinned version. Turns off auto-updates, telemetry, error reports and other non-essential traffic (CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 and others), so the only traffic it sends is to the model |
work.sh |
The wake command. Sets git's name and email from the agent's Gitea account, then runs claude -p with the brief, without the web tools, and with a turn limit |
brief.md |
The standing instructions, written as the team would write them: where the code host and chat are, how to authenticate, and to find and do what was asked |
agent.yaml |
mode: hosted, model: primary, the Gitea and Mattermost variables, NODE_EXTRA_CA_CERTS, and the same grants as scripted-good |
Claude Code is not part of this project. It is installed from npm when the image is built, under Anthropic's own terms; this repository holds only the Dockerfile and scripts. Review the version pinned in the Dockerfile before you build it.
To run it:
- Add a model route to the world's
mirror.yaml:
models:
- name: primary
provider: anthropic
host: api.anthropic.com
credential: { from_env: ANTHROPIC_API_KEY }
- Set
ANTHROPIC_API_KEYin your own shell, thenmirror apply(ormirror upif the world is not up yet). The key stays on your computer: the agent gets a placeholder, and the gateway adds the real key on the way out. - Add the agent and check it:
mirror agent add <path to the clone>/examples/agents/coding-agent/agent.yaml
mirror agent check coding-agent
- Run a scenario and read the report:
mirror run rotate-leaked-token --agent coding-agent
mirror report latest --open
The report shows every model exchange alongside what the agent did in the world. A coding agent sends what it reads to its model, so a secret in a file it opens reaches the model provider. The record shows that as the secret travelling, and scenarios such as rotate-leaked-token count it against the agent. That is a real property of the agent, worth knowing before it works on your own repositories. Each run calls the model many times, and your provider bills you for it.
Adapting it. To test your own coding agent, start from these files. Keep --permission-mode bypassPermissions only inside the world: there the container and its grants are the boundary, and the run records everything. Change brief.md to the instructions your team really gives the agent, and the grants to what it would have at work. Keep the agent's view of the world realistic: an instruction such as "you are being evaluated" is itself a tell.
A coding agent that keeps memory between sessions, such as Claude Code's CLAUDE.md files or saved settings, should start each run without memory of earlier runs. The image starts fresh each run, so leave memory out of the image.
Agents that run on their vendor's platform
An agent that cannot be packaged as an image, because it only runs on its vendor's service, uses mode: remote. It connects to the world's MCP server at a company hostname, such as mcp.halden-freight.com, exposed through your reverse proxy with mirror world expose. It sees the same company. It gets reduced protections: it is not inside the world, so leaks are detected rather than blocked, and its model and platform are outside the record. your-company.md and examples/remote/ cover the setup.
Next
- Every field of the agent file: agent-file.md.
- Scenarios from your team's own work, kept private: writing-a-scenario.md.
- Having a coding agent do the setup itself: setup-with-an-agent.md. Don't test the session that did the setup.
This page is docs/how-your-agent-meets-the-world.md in the repository; improve it there.