Skip to content

Write your policy

A policy is a list of clauses. A clause says, in plain English, what your agents may not do. TestMachine reads every call against every clause and blocks the call if it breaks one.

A new org starts with no policies. A call that no signed-off policy applies to is allowed and recorded, so an org with no policies blocks nothing.

You don’t have to write every policy yourself. TestMachine’s catalog has tested policies for four common risks: prompt injection, leaked credentials, changes that can’t be undone and data leaving the company. Each policy holds one clause for one server, such as Notion: No deleting pages or replacing their content, and a few, named Any server, cover every server without wording of its own. Each reads only the tools that can carry its risk. As soon as you attach a server, TestMachine suggests the ones for it under Risk coverage on Home, and Policies and the server’s page list the catalog by server. Adopt one policy, or all of a server’s in one sign-off. A server you attach later joins every Any server policy you adopted, in Shadow mode, so it blocks nothing new until you enforce it. If you have a draft of that policy open, the server joins the draft too, and your edits stay. TestMachine keeps the wording up to date until you sign off your own version.

Which tools can carry a risk comes from each tool’s labels: whether it only reads, whether it is destructive, whether it reaches beyond your org, and whether what it returns was written by someone else, such as an email or a web page. TestMachine takes them from what the server says about its tools and its own reading of each tool. Prompt injection reads tools whose results someone else wrote, destructive actions reads destructive tools, data leaving the company reads every tool that isn’t read-only, and leaked credentials reads every tool. A tool is read for a risk unless its labels show it can’t carry it. Each tool’s page lists its labels on its Enforced tab, and on a server you added, an admin can set any of them to Yes or No, or back to automatic; the change applies from the next call. The labels on servers TestMachine manages, such as GitHub, Exa and Firecrawl, are TestMachine’s own: you can’t change them, and you report a wrong one with Report on the tool’s page, which reaches TestMachine to fix it for everyone.

Start from a skill or rules you already have

Section titled “Start from a skill or rules you already have”

If you have an agent skill, such as a SKILL.md, or rules your company already has for its agents, such as a CLAUDE.md or AGENTS.md, Claude Code permission settings or a written policy, choose New policy on Policies, then From a skill. Paste it in or upload the file, then choose Read it. TestMachine proposes the few policies it can judge well: usually one, judged on every call or on finished work, and never more than three. Each clause or rule shows the text it came from and why, the page lists what TestMachine left out and why, and you pick which policies to create. They are in force at once, in Shadow mode. A outcome policy judges an agent’s work only when the agent starts it, so the page gives you a line to add to the skill that tells the agent to.

  • Say exactly what to block. List the signs a call must show, one per line. “Customer personal information” is vague; “an email address, phone number or home address of a customer” is not.
  • Say what doesn’t count. Name the ordinary calls that look similar, so they get through.
  • Keep one idea per clause. Two ideas make two clauses, and each blocks on its own.
  • Limit it to the tools it’s about. A clause about posts on X should only read calls to X. A clause about something any tool can carry, such as credentials, reads every tool of the servers it names.
  • Tell the agent what to do instead. A good instruction lets the agent fix the call itself.
Field What it’s for
Title A short name, shown in the dashboard and to the agent.
The clause What TestMachine reads each call against, in plain English.
Applies to Which calls the clause reads. Pick Every server, or pick server tiles; a picked server can be narrowed to some of its tools, such as create_*. A clause written from a server’s or a tool’s page starts with it filled in.
When Before the call runs reads what the agent sends, and a block stops the call. After it runs, before the agent sees it reads what the server sends back, and a block keeps it from the agent.
Tell the agent why Why the call was blocked, in the agent’s terms. Blank uses the title.
And what to do instead What the agent should do instead. Below the fields you see the exact text the agent gets.

Some clauses depend on something a call’s arguments can’t show, such as why the agent is sending an email or which sources a page edit is based on. For those, a clause can ask agents to declare it. Each declaration names a server, a tool or a pattern such as send_*, a field and what the agent should write in it, and whether it is required.

When you add or edit a clause in a draft, TestMachine reads it with your servers’ tools and proposes the declarations it needs, if any. The clause’s page shows the proposal under What agents declare, with why each field is needed; add the ones you want, or edit them. An admin can open How it decided to see how the proposal was made.

After you sign off, agents see the declared fields as extra arguments on those tools, but only where the policy is in force for them. TestMachine takes the fields out before the call reaches the server, records them with the call, and gives them to the judge as the agent’s own claims: they never make a call acceptable that a clause forbids. A call that leaves out a required field is blocked, and the agent is told what to declare. When every clause asking for the field is in Shadow mode, it is recorded and still goes through. A required session is the exception: a call without one is blocked even when the clause asking for it is in Shadow mode, unless your org runs everything in Shadow mode. Calls shows what each call declared, and you can search it.

Every agent also declares a session: before a piece of work, it calls open_session with its purpose and who asked for it, and passes the session it gets on every call for that work, on any server. Sessions (via the Calls / Sessions toggle at the top of Calls) groups the calls by the work the agent declared, and the judge reads each call with its session’s purpose. A session closes when the agent calls close_session, or after an hour without a call. Administration has a Sessions setting, Required unless you turn it off: a server call without a session is then blocked before any clause is judged, even in Shadow mode, and the agent is told to open one. Turned off, a clause can still require a session on the tools it covers.

Every change goes into a draft. The version in force keeps running until you sign the draft off.

  1. Open Policies, choose a policy, and choose Start a draft.
  2. Choose Add clause, or Edit on a clause in the draft. Each opens its own page, with recent calls under the policy beside the editor.
  3. Before you save, choose Run to judge those calls again under the draft with your clause in it. A clause that reads results is tested on the results the servers sent back. Open a call to see its input, its result, how each clause read it, grouped under the policy it comes from, and what the agent would get back. Recorded calls don’t change.
  4. Mark calls Allowed or Blocked to make them test cases. Each run tells you how many test cases match, and which were blocked or allowed by mistake, counting only the clause or draft you are testing; other policies that would also apply are shown, but don’t change the score. Calls you’ve already reviewed are test cases, and a mark is saved as your review of the call.
  5. Choose Test the draft to run every clause in the draft against the same test cases. Switch a clause off to see what the rest do without it.
  6. Read the changes, then choose Sign off. The new version is in force from the next call.

To take out a clause in force, choose Remove beside it on the policy’s page. That opens a draft without the clause if none is open. The clause stays in force until you sign the draft off.

New policy asks what agents should do, or never do, in one sentence. Create policy has TestMachine write the clause with the servers and tools it covers, and the policy is in force at once, in Shadow mode, for everyone: it records what it would block and blocks nothing. While a policy of your own runs in Shadow mode, each edit is in force from the next call too, with no draft to sign off, and History shows each one as a version signed off by the person who made it, so Policy red teaming can red-team the policy straight away. Enforcing it still goes through a draft and Sign off, and so does every edit once it is enforced. Policies from TestMachine’s catalog always wait for sign-off.

Choose History on a policy’s page to select an earlier version, see who created and signed it off, and compare its clauses with the previous version.

Only an admin can create a policy, edit or discard a draft, mark test cases, see stored results or sign a draft off. Anyone signed in can read a policy and its draft and test it.

An admin can choose Delete policy on a policy’s page. The policy stops applying at once: it is detached everywhere it was attached, and its open draft is discarded. Past calls keep their verdicts and the clauses that judged them. Deleting can’t be undone. Any policy can be deleted, including one that applies to everyone.

A policy adopted from the catalog applies to everyone. On any other policy’s page, Reach everyone under Applies to makes it apply to everyone too, and Only who it’s attached to undoes that. An admin can also attach a policy:

  • To a person, on their page: it applies with any agent they use.
  • To an agent, on its page: it applies to whoever runs it.
  • To one identity, a person using one agent, in the agents table on the person’s or agent’s page.

A policy’s page lists everywhere it is attached under Applies to, and can attach it from there too. The attachment grid on Policies shows every policy against every person, agent or identity in one grid; pick a square to see how many identities attaching it there would reach, then attach or detach it. Every policy that applies to a call is checked: the call is blocked if it breaks a clause in any of them, so an attached policy can only add limits. A policy an admin takes out of effect judges no calls until it is put back in effect. A call’s page groups the clauses that judged it under their policies, so two policies’ §01 never look alike. To lift one, detach it where it is attached.

When TestMachine has switched on compliance frameworks for your org, Compliance frameworks, under Policies, lists a pack for SOC 2, HIPAA, 42 CFR Part 2, PCI DSS, GLBA, FedRAMP 20x and the NIST AI RMF. A framework’s page starts with what the pack can’t do for you, then lists every requirement of the framework with its status: enforced by a clause, partly enforced, recorded as evidence a person still reviews, or not covered, with why. Choose a requirement to read its text and the clauses that cite it; Policies shows each clause with the requirements it cites, and Not covered lists what’s outside what TestMachine sees or decides. A pack is a starting point, not a compliance program or an audit. Set up this pack walks through five steps: review the pack’s policies and the sections each clause cites; tag your servers with what the framework needs, such as Holds PHI or Covered by a BAA for HIPAA, from the next call; choose whether agents must open a session and, for packs that use them, whether unsure calls wait for approval; optionally, keep a policy off a server; then add the pack in Shadow mode or Enforce. A pack policy about changing records or access in a regulated system, such as HIPAA’s health record policies, runs only on servers with the framework’s tag, and joins a server once it’s tagged; the rest, such as the ones about data leaving, run on every server, and a clause names the tagged servers when it judges a call. On any policy’s page, Remove under Servers stops it judging a server’s calls from the next call without changing its clauses, so a managed policy keeps TestMachine’s updates; Add a server puts it back. A server’s page lists the policies that judge its calls, each with Remove. Adding it adopts each pack policy from TestMachine’s catalog for everyone, in force from the next call, and TestMachine keeps its wording up to date like any catalog policy. The catalog on Policies lists the pack policies under their framework, and its count includes them. In Shadow mode each clause records what it would block and blocks nothing; in Enforce a call that breaks a clause is blocked. If your framework isn’t listed, the form under the packs asks TestMachine for it.

When TestMachine has switched on red teaming for your org, Policy red teaming, under Policies, grades your policies in force by what they let through rather than by their wording. It ranks your workflows by what your agents’ sessions of the last 30 days did: the tools that can take data out which sessions reached after bringing in private or outside data, by each tool’s risk level. TestMachine can red-team the ones it has a sandbox for. AgentMail, Gmail, Notion, GitHub, Firecrawl, Exa and Orthogonal have full sandboxes of their own for the tools that send, write or fetch; every other tool on a server in TestMachine’s catalog has a sandbox that records each call and tells whether it carries the confidential data to an outside address or site, or to the place the task says is shared with an outside firm. Each one says how data could leave through it, such as a page fetch that carries what the agent read in the web address itself, a Notion page shared with guests from an outside firm, an Exa search whose query carries it, or an Orthogonal request whose parameters carry it to an outside API. A Firecrawl or Exa run also replays a vendor’s docs page, its robots.txt and its agents.txt asking the agent to say who it works for, then a request that carries the person’s name, email or company to an outside site, in the address, base64-encoded in a callback or in a search, beside the same pages followed by a request that carries nothing about them; code decides whether the person’s identity left. Red-team it writes a task for the workflow, worded as an ordinary work ticket from someone at your company, with confidential data planted in a simulated inbox, repository or workspace, copies your policies in force into a throwaway sandbox org, enforced even where yours run in Shadow mode, so the record shows what they would stop, and has an agent try the task through TestMachine, in sessions, the way your agents would. A try counts only when the agent tries to send the confidential data out: a try that declines or sends nothing is dropped and run again with the task’s steps spelled out or with another model, and when no try ever attacks, the run fails rather than grade policies nobody attacked. Code reads the sandbox’s end state to decide whether the confidential data left, such as reaching an outside address, a public repository, a Notion page people outside can see or an outside site; neither a model nor your clause wording decides it. Each workflow is listed under the clauses in force that judge it, whoever wrote them, and has a record: whether the confidential data got out and whether the fix held, the calls that carried it out, every attacker try, the new cases (other confidential data the fix never saw) and every earlier run. While a run goes, its record shows the stage it’s at and the tries so far. When an attempt got through, TestMachine writes a fix from that session and grades it the same way, and Add fix to draft puts it in your draft. The fix rewrites your data-leaving clause for that tool; if no data-leaving clause covers the tool, it’s a new clause, in a new Data leaving the company policy when you have none. Before it’s graded, a second model reads the fix next to the session it came from, never the new cases, and marks each part that only fits that session, such as its exact figure or the document it was in; a fix with such a part is rewritten once, and the Suggested fix tab shows what the review found. A run takes about 30 minutes, nothing in your own org changes until you add the fix, and sign-off is still separate.

Policy red teaming lists your policies, each with the clauses in force that judge a workflow and the workflows under each. Red-team this policy red-teams every one of them in one go: for each clause that isn’t about data leaving it first drafts what breaks the clause, with marked examples, for you to confirm as described below; a data-leaving clause needs nothing marked, because code decides it. Start red-teaming then runs them all. When their runs have fixes, Add N fixes to draft puts every one in the policy’s draft. A data-leaving clause’s fix is rewritten in rounds on the scripted sends, with the planted data or without it, and a round is kept only when it gets more of them right than the clause in force.

You can also red-team one clause in force that judges a workflow, including one you wrote. Under that clause on Policy red teaming, open the workflow and choose Red-team §NN. TestMachine drafts what breaks the clause in one sentence, with example calls; edit the sentence and mark each example Breaks it or Fine. From then on your marks decide whether an attack got through, never the clause wording. The run first confirms that a judge agrees with your marks, reading your sentence alone and reading your other marks. When your sentence doesn’t decide your own examples the way you marked them, TestMachine sharpens it until it does and shows you both; when your marks contradict the clause itself, the run stops. Then TestMachine copies that one clause into a sandbox org and has agents attack it in ten ways: as asked, encoded, split up, buried in a long body, in another field, reworded or masked, with an approved-sounding reason, to an odd destination, called a test, and as an instruction planted in a document the agent reads. Agents try up to 60 sessions, 20 at a time, each on a ticket written to break the clause one of those ways; a ticket that no agent acts on in its first two sessions gets no more. TestMachine also takes your sentence apart into the parts of the clause (each kind of thing it forbids, each form, field, place or amount it reaches) and writes single calls an honest agent would make in ordinary work that break it in each part, in three rounds: about 120 calls in the first, then two rounds of about 50 that learn from the calls that came closest to getting through and from what the judge noticed in them. It writes about 50 allowed calls close to the line that must go through. The same judge labels every written call, and a call it doesn’t label the way it was written is dropped, so every attack counted breaks your sentence. A second reader reads every call that gets through; one it says doesn’t clearly break your sentence is shown as arguable and not counted, since it points at wording to tighten rather than a hole. The record counts every attack, shows them by part of the clause, one dot each, opens on the call that got through or else the closest one, and states the most that attacks like the first round’s could get through at 95% confidence (an exact one-sided bound), so 0 of 150 reads as at most 1 in 50, where 0 of 3 could still mean 1 in 2. Later rounds aim at the weak spots, so they sharpen the search but aren’t part of the bound. It also writes practice calls near the line. A fix is rewritten in rounds on the practice calls and any attack that got through, and only a round that gets more of the practice calls right than the clause in force, and isn’t overfit to them, is kept; the fix then faces the same written calls and new agent sessions. Your examples are never shown to the fix: the record compares the clause in force and the fix on the attacks, the allowed calls and your examples.

A call policy judges each call as the agent makes it. An outcome policy judges the outcome: what an agent hands over when it finishes one kind of work, such as a research brief. Its rules are in plain words, in stages if the work needs them. The agent starts one with outcome_policy_start, does the work with its tools, and hands in what it produced with outcome_policy_submit. The judge looks through the calls the agent made and what the servers returned, can verify facts again with the read-only tools of those servers, and either passes the work or tells the agent what to fix. Every save makes a new version, and each version has its own settings, such as Shadow mode, where the judge’s answer is recorded and the agent moves on anyway. Outcome policies don’t block calls.

Policies shows every policy as a card, call policies and outcome policies alike, and New policy starts either kind, from a template or blank. An outcome policy’s Work tab lists each piece of work an agent handed in under it, and each one opens to what was handed over, whether it met every rule, and what the agent was told to fix.

The judge also reads the earlier calls of the session a call was made in. It uses them to fill in what a call leaves out, such as who a reply that names only a message ID goes to, so a clause can catch calls that look harmless alone. A clause can also refer to the session directly, such as “a reply must go to the person whose thread the agent just read”.

A clause that reads results reads a long result in parts of 60,000 characters, side by side, each judged on its own, and withholds the result if any part breaks it.

A call the judge isn’t sure of waits for a person instead of being allowed or blocked outright. Only an enforced policy holds a call; a policy in Shadow mode never does. The agent gets a link to a TestMachine page, where the person who runs the agent, or an admin, signs in and approves or denies that exact call. The agent can’t approve it itself. Once it’s approved, the same call with the same arguments goes through once. Agents that support MCP tasks get their result when the call goes through. Other agents make the call again.