Skip to main content
Mirage judges every action an agent takes before it reaches a service: each command, each file call, including those a Python program makes, and each variable write. This example gives an analyst agent one profile and the workspace one coded policy, and walks through what the agent sees.

The policy script

The script reads the command as JSON, opens the files it names through the workspace, and refuses a Python script whose code deletes files:
guard.py
The script reads the code as text, so it stops the usual calls, not every way Python can delete a file. A rule that must always hold belongs in a coded policy, which judges each file call itself, as WritesOnlyToOut below does for writes.

The workspace

What the agent sees

  • Hidden files are absent, not refused. aws.txt and server.pem read as missing, and ls leaves server.pem out. secrets stays listed only because README.md is shown back inside it.
  • Hidden variables read as unset. $AWS_SECRET_ACCESS_KEY expands to nothing; $TEAM is untouched.
  • Denied commands exit 126 with Permission denied, the same wording a shell gives. The reason stays with the host.
  • The script reads the file before it runs. python3 clean.py is refused because clean.py calls os.remove. A script that only reads runs.
  • The coded policy sees every file call. The write from echo and the write from Python’s open() both reach pre_vfs, and both are refused outside /data/out.
  • An ask goes to the host. rm out/notes.txt matches the ask rule, so approve answers it before the line runs. Without on_ask, the line returns pending until the host answers.
The profile applies only to sessions under analyst. The coded policy applies to every session of the workspace, so the host’s own writes outside /data/out are refused as well.

Learn more

  • Agent profiles: every profile key and how rules match.
  • Policies: the eight methods and their answers.
  • Scripts: what a policy script reads and prints.
  • Explain: check a line against the rules before it runs.