Run plans
An agent says at the start of a run which actions it will take, each at most so many times. The plan is locked, and anything off it waits for a person, whatever a rule says.
An agent that reads a web page, an email or a ticket can be talked into doing something its task never needed. A support agent answering a question has no reason to issue a refund, but if the customer’s email says to, and a rule allows refunds, nothing stops it.
A run plan closes that gap. At the start of a run, before it reads anything from outside, the agent says what the task needs: these actions, each at most so many times. The plan is then locked. Text the agent reads later cannot widen it, so a request off the plan waits for a person, whatever the rules say. This is the idea behind Google DeepMind’s CaMeL research (plan from the trusted task before seeing untrusted data), applied at the approval gate instead of inside the agent, so it works with any agent that asks through VariantGate.
Allow rules cover every action. Ask in any order and see what the plan does to each request.
support-bot · run ticket-4411
- Nothing asked yet. Pick a request on the left.
Declare a plan
The agent sends the plan with its own key, once per run. The run id is the one it puts on its requests.
curl -X PUT https://api.variantgate.com/v1/runs/ticket-4411/plan \
-H "Authorization: Bearer gl_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"goal": "Answer ticket 4411",
"steps": [
{ "action": "crm.read" },
{ "action": "kb.*" },
{ "action": "email.send", "max": 1 }
]
}'- goal
- The task in one sentence, shown to the people who see the run. Up to 300 characters; may be left out.
- steps
- 1 to 20 actions the run will take. Each is an exact action such as email.send or a family such as kb.*, written the way rules write them. The same action twice is refused: plan it once with the total.
- max
- How many times at most, 1 to 1000. Leave it out for no count.
The answer is the plan, with how much of each step is used:
{
"run": "ticket-4411",
"goal": "Answer ticket 4411",
"steps": [
{ "action": "crm.read", "used": 0 },
{ "action": "kb.*", "used": 0 },
{ "action": "email.send", "max": 1, "used": 0 }
],
"after_untrusted": false,
"requests_before": 0,
"held": 0,
"declared_at": "2026-11-29T14:02:11Z"
}- 201
- The plan was declared.
- 200
- The run already had exactly this plan; nothing changed. Safe to send again after a retry.
- 409 plan_locked
- The run already has a different plan. A plan cannot be changed, widened or narrowed once declared.
- 422
- No steps, more than 20, a goal over 300 characters, a max out of range, an action that is not a pattern, or a run id with characters other than letters, digits, . _ : -
The agent can read its plan back at any time:
curl https://api.variantgate.com/v1/runs/ticket-4411/plan \
-H "Authorization: Bearer gl_YOUR_KEY"With the SDKs, the client’s run is used:
import { ApprovalClient } from "@variantgate/agent";
const approvals = new ApprovalClient({
agent: "support-bot",
apiUrl: process.env.VARIANTGATE_API_URL ?? "https://api.variantgate.com",
key: process.env.VARIANTGATE_KEY ?? "",
run: "ticket-4411",
});
// First, before the agent reads the ticket or anything else from outside.
await approvals.declarePlan({
goal: "Answer ticket 4411",
steps: [
{ action: "crm.read" },
{ action: "kb.*" },
{ action: "email.send", max: 1 },
],
});from variantgate import ApprovalClient
approvals = ApprovalClient("support-bot", run="ticket-4411")
# First, before the agent reads the ticket or anything else from outside.
approvals.declare_plan(
"Answer ticket 4411",
[{"action": "crm.read"}, {"action": "kb.*"}, {"action": "email.send", "max": 1}],
)What happens to the run’s requests
- A request is off the plan when the plan names no step for its action, or when every step for its action is used as often as planned.
- A step counts the run’s requests that match it and may have run: approved, or still waiting and not yet expired. Denied, expired and withdrawn requests never ran, so they do not use it up.
- No allow rule, run grant or mandate approves an off-plan request. It waits for a person, who can still approve it.
- A rule that denies still denies. A request on the plan is decided by the rules exactly as before.
- The plan belongs to one agent key and one run id. The key’s other runs, and its requests with no run, are not touched.
- A sub-agent run linked below the run answers to this plan too, and its requests use up the plan’s steps.
A worked example
With allow rules for every action and the plan above, the run reads the customer record and sends its answer. Then the email it read asks for a refund, and later for the order history to go to another address:
POST /v1/requests {"action": "crm.read", "run": "ticket-4411", ...} -> approved by a rule
POST /v1/requests {"action": "email.send", "run": "ticket-4411", ...} -> approved by a rule
POST /v1/requests {"action": "refund.create", "run": "ticket-4411", ...} -> pending: not in the plan
POST /v1/requests {"action": "email.send", "run": "ticket-4411", ...} -> pending: used upPeople in the workspace see the plan on the run page, with each step’s use and how many requests it held, and an Off plan block on each request it held. The agent sees only that its request is pending, so it is not told how to word its way back onto the plan:
"off_plan": {
"reason": "used_up",
"step": "email.send",
"max": 1,
"goal": "Answer ticket 4411",
"planned": [
{ "action": "crm.read" },
{ "action": "kb.*" },
{ "action": "email.send", "max": 1 }
]
}When the plan came late
A plan only helps if it was written before the agent read anything from outside. Two fields say how it was made:
- after_untrusted
- true when the run had already taken in untrusted content when the plan was declared: a request that listed an untrusted source, or an action on the trifecta guard's untrusted list. That content may have written the plan.
- requests_before
- How many requests the run made before the plan. They were weighed without it.
Declare the plan in code, from the task the user gave, before the first tool call. Hooks and SDKs take the run id from the session, out of the model’s reach; a tool call where the model fills in the run could start a fresh run with no plan.
What it never does
- It never approves a request, and never sets allowed to true.
- It never lets an agent change its plan, so nothing the agent reads can widen it.
- During an emergency stop nothing is allowed anyway.
Run plans work on every plan, Free included, and need no setting: an agent that declares one only ever makes its own run more cautious. It pairs well with the trifecta guard, which an owner sets for every run.
During a deploy
While two versions of the API run side by side during a deploy, one from before run plans answers 404 to a plan and ignores plans, so a request that instance takes is decided as if its run had none. Do not count on plans until every instance runs this version. The SDKs' declarePlan and declare_plan answer null (None in Python) when they meet such an instance, so the run carries on under the rules alone.