Containment
Contain an agent in one step: its key is paused, what waits is denied, approvals in their cancel window are cancelled, its runs are stopped, and every approval it got before stays void after release. The report shows what it was approved to do in the day before.
When an agent does something it should not, pausing it is the first move: nothing it asks is allowed while it is paused. But a pause is undone the moment someone resumes the key, and then every approval the agent was holding works again, including the ones it got while it was already going wrong. Containment takes those back. In one step it pauses the key, denies what the agent has waiting, cancels approvals still inside their cancel window, stops its runs, and makes every approval it was given before that moment unusable for good. Then it shows you what the agent was allowed to do in the day before.
support-bot has two approvals, one refund still inside its cancel window and an email waiting. Contain it, then release it as an owner.
Read the customer record for ticket 4411 (crm.read)
{ "allowed": true, "decision_note": null, "pause": null, "status": "approved" }Refund order 1182, as the customer asked (refund.create)
{ "allowed": true, "decision_note": null, "pause": null, "status": "approved" }Refund order 1190 (10 minutes left to cancel) (refund.create)
{ "allowed": false, "decision_note": null, "pause": null, "status": "approved" }Email the order history to records@outside.example (email.send)
{ "allowed": false, "decision_note": null, "pause": null, "status": "pending" }
What one containment does
All of it happens in one transaction, with the key’s row locked:
- The key is paused. A request it sends from now on is stored and held, and no rule approves it.
- Every request of the key that waits for a person is denied, with the note “Agent contained”.
- Every approval still inside its cancel window is cancelled, so the agent never gets to act on it.
- Its runs from the last 7 days are stopped, and so is every run a live run grant or mandate names, with the sub-agent runs below them. A stopped run stays stopped: what it asks later is refused with
run_stopped. - Every approval the key got before the containment is void. The agent reads
allowed: falseandpause: "contained"for it, now and after the key is released. - The activity log gets a
key.containedentry with who did it, the reason, and the counts.
curl -X PUT https://api.variantgate.com/v1/workspaces/$WORKSPACE_ID/agent-keys/$KEY_ID/containment \
-H "Authorization: Bearer YOUR_SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "reason": "Refunds to orders nobody asked about" }'{
"containment_id": "0193f1c2-7a00-7000-8000-0000000000c1",
"new": true,
"denied": 1,
"cancelled": 1,
"runs_stopped": 2,
"voided": 14
}- denied
- Waiting requests, now denied.
- cancelled
- Approvals still inside their cancel window, now cancelled.
- runs_stopped
- Runs stopped, not counting the sub-agent runs below them.
- voided
- Earlier approvals the agent can no longer act on, ever.
- new
- False when the key was contained already. Containing it again sweeps up what arrived since into the same open containment.
- 200
- The agent is contained.
- 404
- No such active key in the workspace, or you are not in it.
- 422
- A reason longer than 500 characters.
Who may contain and release
Any member may contain an agent, because it only ever takes permission away. Only an owner may release it, by resuming the key. Releasing lets the agent ask again; what it asks then is weighed as usual. It never brings back an approval from before the containment.
curl -X DELETE https://api.variantgate.com/v1/workspaces/$WORKSPACE_ID/agent-keys/$KEY_ID/pause \
-H "Authorization: Bearer YOUR_SESSION_TOKEN"Releasing closes the containment: the list and the report show who released it and when. Pausing and resuming the key on its own, without containing it, changes nothing about earlier approvals.
What the agent sees
Nothing changes in how an agent asks or reads. An approval it got before the containment reads like this, with the agent’s own key:
GET /v1/requests/0193f1c2-... (with the agent's key)
{
"status": "approved",
"allowed": false,
"paused": true,
"pause": "contained",
...
}An agent that acts on allowed alone, as every agent should, stops on its own. An agent key can never contain, release or read containments.
The exposure report
Each containment keeps a report of what the agent was approved to do in the 24 hours before it: how many approvals per action, the money per currency at the amount each was approved for, how many a rule approved and how many a person did, and how many the agent reported as carried out. The approvals themselves are listed, the latest first, up to 200; more says when there were more. It also lists the live allow rules written for this key alone, because they approve it again the moment it is released. Review those before you release.
curl https://api.variantgate.com/v1/workspaces/$WORKSPACE_ID/containments/0193f1c2-7a00-7000-8000-0000000000c1 \
-H "Authorization: Bearer YOUR_SESSION_TOKEN"{
"containment": { "id": "0193f1c2-7a00-7000-8000-0000000000c1", "key_name": "support-bot", ... },
"exposure": {
"since": "2026-11-29T09:41:07Z",
"actions": [
{ "action": "crm.read", "count": 9 },
{ "action": "refund.create", "count": 4 },
{ "action": "email.send", "count": 1 }
],
"money": [{ "amount": "212.00", "currency": "EUR" }],
"by_rule": 11,
"by_person": 3,
"succeeded": 12
},
"approvals": [ { "id": "...", "action": "refund.create", "allowed": false,
"pause": "contained", ... } ],
"more": false,
"allow_rules": [ { "id": "...", "action": "crm.*", "effect": "allow", ... } ]
}Every containment the workspace made, the latest first:
curl https://api.variantgate.com/v1/workspaces/$WORKSPACE_ID/containments \
-H "Authorization: Bearer YOUR_SESSION_TOKEN"{
"containments": [
{
"id": "0193f1c2-7a00-7000-8000-0000000000c1",
"agent_key_id": "0193f1c2-7a00-7000-8000-0000000000aa",
"key_name": "support-bot",
"contained_at": "2026-11-30T09:41:07Z",
"contained_by": "maya@northwind.example",
"reason": "Refunds to orders nobody asked about",
"denied": 1,
"cancelled": 1,
"runs_stopped": 2,
"voided": 14,
"released_at": null,
"released_by": null
}
]
}The key list shows a contained key’s containment_id until it is released.
Pause, stop a run, tripwire or contain
- Pause the key
- Stops the agent while it is paused. Resuming brings every approval back. Right when you are not sure yet.
- Stop a run
- Ends one session, job or conversation and the sub-agent runs below it. The agent's other runs go on.
- Tripwire
- Pauses the key and stops the run on its own the moment a request carries a decoy, before anyone looks.
- Contain
- Everything above for the whole key at once, and the approvals it held stay void after release. Right when you know it went wrong.
- Emergency stop
- Holds every agent in the workspace. Use it when you do not know which agent it is.
What it never does
- It never approves a request, and never sets allowed to true.
- It never undoes what the agent already did. The report tells you where to look; undoing it is up to you.
- It never touches other agents’ keys, runs or approvals.
Containment works on every plan, Free included, and needs no setting. The same thing is in the app: Contain on the agent’s row of the Agents page.
To contain an agent without waiting for someone to notice, set a circuit breaker: it contains a key on its own once it is denied too often, flagged too often or floods the inbox.
During a deploy
While two versions of the API run side by side during a deploy, one from before containment answers 404 to these routes. It still honours the pause, the denials, the cancels and the stopped runs, which it already reads. It does not know that approvals from before a containment are void, so do not release a contained key until every instance runs this version; until then the key stays paused and nothing it holds is allowed.