Skip to main content
Policy decides what an agent may do in the virtual terminal: the commands it runs, the files it reads and writes, and the connections it opens. A policy is a class with a pair of methods for each thing an agent does, or programs a profile names for those methods: A pre_ method runs before the action executes; a post_ method runs afterward with the execution result. A policy decision can permit, refuse, request host approval, bound the output, or select the target machine. No policy can permit what another refuses. Policies evaluate in sequence: built-in checks first (mount modes, path restrictions, machine routing), followed by the session profile, and finally the workspace policies in the order they were added.

Why not a tool-call check

A harness’s tool-call check, such as Claude Code’s PreToolUse or an SDK’s can_use_tool, sees one tool call: a tool name and a string such as cat $(ls /data | head -1). A Mirage policy runs inside the shell and the filesystem, so it sees what that string only implies.

In this section

  • Policies: write one: its methods, what each can answer, and asks.
  • Scripts: write one as a program that runs sandboxed on monty or Python on wasm, with the same context as JSON.
  • Explain: what the agent sees of policy, and how it asks what a line would do before running it.
  • Route Machine: choose the machine for a line, from a script.
  • Route Network: send a connection to one address to another, per workspace and per session.