Docs
Ask Opsline before your agent acts.
Your agent sends the action it wants to take. Opsline runs your policy for it and answers allowed, denied or pending. Pending actions wait for the accountable person, and every decision lands in the hash-chained audit log. With earned autonomy, an agent starts in shadow mode and acts alone on a class of actions once its record clears the bar and an admin approves.
Get started
For refunds, install the Refund starter set from the Integrations page.
- Create an API key for the agent in Settings, under API keys.
- Open Workflows and click New workflow.
- Name it
policy-refund. Opsline runspolicy-<action>for each action. - Click + Add step and pick Decide.
- Set Outcome to Allow and Reason to
ok. - Click Create workflow. This smallest policy allows every refund request with reason
policy. - Call
POST /api/v1/actionswith the key and"action": "refund"before the agent acts. See Ask before acting for the request.
A policy can only decide, and the agent then acts on an allow. Or it can also carry out the action, such as issuing the Stripe refund, so the agent's own key never needs to refund. Only the second stops an agent that skips the call, because its own key can't refund. See Issue the refund in the policy.
Add a per-customer limit
The policy from Get started allows every request, so replace it before an agent uses it. This version allows up to $200 per customer in 24 hours and sends anything above to a person:
- Open
policy-refundin Workflows and click Edit. - Delete the Decide step.
- Click + Add step and pick Branch. Set If to
trigger.risk.payee_total_24h, the comparison to is at most, the value to200and the value type to number. - On the Yes path, add a Decide step with Outcome Allow and Reason
Within $200 for this customer in 24 hours. - On the No path, add a Human approval step. Under Approvers, add the member who decides larger refunds, such as your support lead.
- Click Publish version.
Requests must pass amount and payee for this to work. A request with no amount has no total, so it goes to the approver.
Issue the refund in the policy
These steps add what the seeded policy-refund does around the limit. Opsline reads the charge, checks its customer and issues the refund. First add two secrets in Settings, under Secrets: STRIPE_READ_KEY with a Stripe key that can read charges, set to Read only, and STRIPE_SECRET_KEY with a key that can write refunds, left as Write. The charge is read before any approval, and the engine refuses a write secret there while the agent may not act alone, so the read needs its own read-only key. Requests must pass the charge in params.charge_id.
- Open
policy-refundin Workflows and click Edit. - Click + Add step and pick HTTP request. Click Move earlier until it is the first step. Set Label to
Read the charge, the method to GET and the URL tohttps://api.stripe.com/v1/charges/{{ trigger.params.charge_id }}. Click + Header and addAuthorizationwith the valueBearer {{ secrets.STRIPE_READ_KEY }}. - Click + Add step, pick Branch and move it right after Read the charge. For If, pick Read the charge's
bodyfrom the list and add.customer, such assteps.step_3.output.body.customer. Set the comparison to has a value. - On its Yes path, add a Branch. Set If to the same path, the comparison to does not equal, the value to
trigger.payeeand the value type to field. On that branch's Yes path, add a Decide step with Outcome Deny and ReasonThe charge belongs to another customer. - On the first branch's No path, add a Decide step with Outcome Deny and Reason
This charge has no Stripe customer. - Click + Add step and pick HTTP request, so it comes after every other step. Set Label to
Issue the refund, the method to POST and the URL tohttps://api.stripe.com/v1/refunds. Add the headerAuthorizationwithBearer {{ secrets.STRIPE_SECRET_KEY }}and the headerIdempotency-Keywith{{ trigger.action_id }}. - Under Body, pick Send as form fields and enter
{ "charge": "{{ steps.step_3.output.body.id }}", "amount": "{{ trigger.amount_minor }}", "metadata[opsline_action_id]": "{{ trigger.action_id }}" }, with the id of Read the charge in place ofstep_3. - Under Advanced, set Timeout ms to
80000, as long as Stripe's own libraries wait. - Click Publish version.
A denial stops the run before Issue the refund, so the refund goes out only after an allow or an approval. Give the agent a Stripe key that can only read.
Send a held action to a person
Once the agent's key is enrolled, the engine refuses Issue the refund on every action the agent may not act alone on, unless a person approved earlier in the run. These steps send those actions to a person.
- Open
policy-refundin Workflows and click Edit. - On the Yes path of the branch on
trigger.risk.payee_total_24h, add a Branch, and click Move earlier until it comes before that path's Decide step. Set If totrigger.autonomy.enrolledand the comparison to is yes. - On its Yes path, add a Branch. Set If to
trigger.autonomy.may_act_alone, the comparison to does not equal, the value type to yes/no and the value to yes. - On that branch's Yes path, add a Human approval step. Under Approvers, add your support lead. Set Prompt to
{{ trigger.agent }} wants to refund {{ trigger.amount }} USD to {{ trigger.payee }}. Agent record: {{ trigger.autonomy.record }}. - Click Publish version.
A held refund that takes the customer past $200 in 24 hours already goes to the approver on the limit branch's No path, so these steps cover only the held refunds the limit would allow, and each held refund asks a person once. Both approvals show the proposal, so their answers count as anchored approvals. On this policy a class can reach auto_limited from shadow but never auto, and a demoted class stays held. See Limits.
How it works
A policy is an ordinary Opsline workflow named policy-<action>, such as policy-refund. When an agent asks to take an action, Opsline computes risk signals from the requests it has recorded, starts the policy with the request as its trigger data, and returns the decision. A Decide step settles the action without a person. An approval step sends it to the accountable person by email, and to Slack when the workspace has a SLACK_APPROVALS_WEBHOOK secret. Every request and decision is recorded in the workspace's hash-chained audit log.
Create one API key per agent in Settings, under API keys. Approvers, policies and the Agents page know the agent by the key's name.
Ask before acting
export OPSLINE_URL=https://<your-opsline>
export OPSLINE_API_KEY=opslk_...
curl -s -X POST "$OPSLINE_URL/api/v1/actions" \
-H "Authorization: Bearer $OPSLINE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"action": "refund",
"amount": 45,
"currency": "USD",
"payee": "cus_QxR2b9TkLm",
"params": { "ticket_id": "T-1001", "charge_id": "ch_3QxR2a9TkLm" },
"reason": "Mug arrived chipped, photo attached",
"idempotency_key": "refund:T-1001"
}'A denial returns HTTP 200 too, so check decision before acting.
action(required): lowercase letters, digits and dashes. Opsline runs the workflowpolicy-<action>. With no such workflow the request is denied with reasonno_policy.amount,currencyandpayee: pass them for anything that moves money.amountis in major units (dollars, not cents), andcurrencydefaults to USD. They feed the 24-hour totals and the duplicate and split checks. Totals add amounts whatever the currency, so a policy with dollar limits should deny other currencies.params: anything the policy reads, such asticket_idorcharge_id. Up to 64 KB.reason: the agent's reason, shown to the approver.on_behalf_of: the email of the member the agent acts for. That person can't approve the request.idempotency_key: a retry with the same key returns the same action withreplayed: true. The same key with a different request (action, amount, currency, payee or params), or from another API key, returns 409. A decided action is final, so after you fix a policy, send a new key. Ano_policydenial and a policy run that couldn't start aren't kept under the key, so a retry with the same key starts over.wait_ms: how long the call waits for a policy that decides on its own, 0 to 25000. The default is 5000.callback_url: where to send the decision once it's made. See callbacks below.agent: a label for the agent, if it differs from the API key's name. Approvers see it next to the key's name.agent_version: for an agent in earned autonomy, itsmodel, the sha256 of its prompt asprompt_sha256and its tool names astools. A change moves every class of the key back to shadow. See Agent version.
Any other field returns 422 with its name, so a misspelled payee or idempotency_key shows up at once.
Responses
Allowed by policy returns 200. reason is policy, or approved with approver when a person decided.
{
"id": "act_7dq2m1x9k4p0v8sa",
"agent": "refund-agent",
"action": "refund",
"amount": 45,
"currency": "USD",
"payee": "cus_QxR2b9TkLm",
"decision": "allowed",
"reason": "policy",
"reason_code": "policy",
"approver": null,
"waiting_on": [],
"risk": {
"payee_total_24h": 45,
"payee_count_24h": 1,
"agent_total_24h": 45,
"duplicate": false,
"unusual_amount": null,
"flags": []
},
"result": {
"step_id": "issue_refund",
"status": 200,
"body": { "id": "re_3QxR2b", "object": "refund", "amount": 4500, "status": "succeeded" }
},
"run_id": "run_9b38mt9bh7bqcom8",
"run_url": "https://<your-opsline>/runs/run_9b38mt9bh7bqcom8",
"autonomy": null,
"created_at": "2026-11-21T09:41:02.118Z",
"decided_at": "2026-11-21T09:41:02.705Z"
}Waiting on a person returns 202. waiting_on names who can decide and run_url links to the policy run.
{
"id": "act_k2v9w0q7r3m5x1dz",
"agent": "refund-agent",
"action": "refund",
"amount": 1800,
"currency": "USD",
"payee": "C-45",
"decision": "pending",
"reason": "awaiting_approval",
"reason_code": "awaiting_approval",
"approver": null,
"waiting_on": ["Dana Reyes"],
"risk": {
"payee_total_24h": 1800,
"payee_count_24h": 1,
"agent_total_24h": 1965,
"duplicate": false,
"unusual_amount": null,
"flags": []
},
"run_id": "run_3l7ymeedwj2tf6dy",
"run_url": "https://<your-opsline>/runs/run_3l7ymeedwj2tf6dy",
"autonomy": null,
"created_at": "2026-11-21T09:42:10.031Z",
"decided_at": null
}Denied returns 200. reason is policy: <the Decide step's reason>, rejected (with approver), expired, no_policy (with a message naming the workflow to create), policy_error (with a message saying what to check), execution_failed (the policy allowed the action, but the API the step that carries it out calls refused it on every attempt, so it did not happen), execution_unknown (an attempt of that step timed out or got a 5xx, 409 or 429, so the action may have happened), or autonomy_blocked (your earned level doesn't let you act alone and no person approved, so the engine didn't send the step that carries it out). Don't take the action. After execution_unknown, check before retrying: for a Stripe refund, list the charge's refunds and look for metadata[opsline_action_id] equal to the action's id.
{
"id": "act_p8c4n6t1y0s2j7fb",
"agent": "refund-agent",
"action": "refund",
"amount": 150,
"currency": "USD",
"payee": "C-77",
"decision": "denied",
"reason": "rejected",
"reason_code": "rejected",
"approver": { "name": "Dana Reyes" },
"waiting_on": [],
"risk": {
"payee_total_24h": 300,
"payee_count_24h": 2,
"agent_total_24h": 2265,
"duplicate": false,
"unusual_amount": null,
"flags": ["split"]
},
"run_id": "run_knxe0vcsyaonj0c9",
"run_url": "https://<your-opsline>/runs/run_knxe0vcsyaonj0c9",
"autonomy": null,
"created_at": "2026-11-21T09:44:51.410Z",
"decided_at": "2026-11-21T09:45:10.392Z"
}Recorded returns 200 with reason_code shadow_mode: your class is in shadow, so Opsline only recorded the proposal and ran no policy. Don't take the action. See Earned autonomy.
Every response also has reason_code, which never carries free text, so branch on it instead of reason: policy, approved, rejected, expired, no_policy, policy_error, execution_failed, execution_unknown, autonomy_blocked or shadow_mode once decided, and awaiting_approval or evaluating while pending.
Errors: 400 for a body that isn't JSON, 401 for a missing or revoked key, 409 for an idempotency key reused with a different request or by another API key, 422 for an invalid request, and 429 (with Retry-After: 60) once one API key has sent 30 actions in the last minute. Replays of an idempotency key don't count toward the 30.
Wait for a decision
Long-poll GET /api/v1/actions/<id>?wait=25. It returns as soon as the action is decided, or after 25 seconds with decision: pending, so call it again until the decision isn't pending. Each way to ask names its wait differently:
POST /api/v1/actions:wait_msin the body, in milliseconds, 0 to 25000, default 5000.GET /api/v1/actions/<id>:?wait=<seconds>, 0 to 25, default 0.- MCP:
wait_msonrequest_approval, as on the POST, andwait_secondsonget_decision, 0 to 25.
An approval can wait as long as its timeout, so this client stops after 15 minutes. It then returns the action still pending, with reason_code set to client_timeout. Opsline never sends that code; it only marks where this client stopped waiting:
type Decision = {
id: string;
decision: "allowed" | "denied" | "pending" | "recorded";
reason: string | null;
reason_code: string | null;
waiting_on: string[];
// Set when the policy carried the action out itself, such as a Stripe refund.
result: { step_id: string; status: number | null; body: unknown } | null;
// Null unless an admin enrolled this API key in earned autonomy.
autonomy: {
class: string;
level: "shadow" | "supervised" | "auto_limited" | "auto";
may_act_alone: boolean;
why: string | null;
} | null;
};
const base = process.env.OPSLINE_URL;
const MAX_WAIT_MS = 15 * 60_000;
const headers = {
Authorization: `Bearer ${process.env.OPSLINE_API_KEY}`,
"Content-Type": "application/json",
};
// Asks before acting, then long-polls until a person or the policy decides.
// After 15 minutes it stops waiting and returns the action still pending, with
// reason_code "client_timeout", which only this client sets. Don't act on it.
export async function askOpsline(request: object): Promise<Decision> {
const deadline = Date.now() + MAX_WAIT_MS;
const res = await fetch(`${base}/api/v1/actions`, {
method: "POST",
headers,
body: JSON.stringify(request),
});
if (!res.ok) throw new Error(`Opsline ${res.status}: ${await res.text()}`);
let action: Decision = await res.json();
while (action.decision === "pending") {
if (Date.now() > deadline) {
return { ...action, reason_code: "client_timeout" };
}
const poll = await fetch(`${base}/api/v1/actions/${action.id}?wait=25`, { headers });
if (!poll.ok) throw new Error(`Opsline ${poll.status}`);
action = await poll.json();
}
return action;
}
const answer = await askOpsline({
action: "refund",
amount: 45,
payee: "cus_QxR2b9TkLm",
params: { ticket_id: "T-1001", charge_id: "ch_3QxR2a9TkLm" },
idempotency_key: "refund:T-1001",
});
if (answer.decision === "allowed" && answer.result) {
// Opsline already issued the refund. Don't issue it again.
} else if (answer.decision === "allowed") {
// The policy only decided, so the agent issues the refund.
} else if (answer.decision === "recorded") {
// Opsline only recorded the proposal. Don't refund, and tell the customer a
// teammate will follow up.
} else if (answer.reason_code === "execution_unknown") {
// The refund may have gone out. Tell a person, and don't retry.
} else {
// Denied or still pending. Don't issue the refund.
}A client that stops waiting doesn't cancel the approval. A person can still approve it later. When the policy carries out the action, as the seeded policy-refund does, a late approval still issues the refund, so don't treat a client-side stop as a denial or tell the customer no. When the policy only decides, the audit log and evidence export show an approved action the agent never took. Store the action id, and pass callback_url or poll it again later.
GET /api/v1/actions lists the workspace's newest actions. Filter with agent (an API key's name), decision (pending, allowed, denied or recorded), idempotency_key, ticket_id (the request's params.ticket_id), charge_id (the request's params.charge_id), reason (the decision reason, such as shadow_mode), unlabeled (an enrolled key's actions with no label of that kind yet, such as human_action or outcome) and limit (default 20, up to 50).
Callbacks
Add a secret named OPSLINE_CALLBACK_SECRET in Settings, under Secrets, then pass callback_url, an https URL on a public address (http on localhost works in development). Opsline sends one POST with the decided action, in the same JSON as the API. It carries x-opsline-timestamp (Unix seconds) and x-opsline-signature, the hex HMAC-SHA256 of ${timestamp}.${rawBody} with the secret. Check the signature against the raw body and reject timestamps more than 5 minutes old:
import { createHmac, timingSafeEqual } from "node:crypto";
const TOLERANCE_SECONDS = 300;
// rawBody is the request body exactly as received, before JSON.parse.
export function verifyOpslineCallback(rawBody, headers) {
const timestamp = headers["x-opsline-timestamp"];
const signature = headers["x-opsline-signature"];
if (!timestamp || !signature) return false;
const ts = Number(timestamp);
const age = Math.abs(Date.now() / 1000 - ts);
if (!Number.isFinite(ts) || age > TOLERANCE_SECONDS) return false;
const expected = createHmac("sha256", process.env.OPSLINE_CALLBACK_SECRET)
.update(`${timestamp}.${rawBody}`)
.digest("hex");
const a = Buffer.from(expected);
const b = Buffer.from(String(signature));
return a.length === b.length && timingSafeEqual(a, b);
}MCP
Point any MCP client at /api/mcp with the API key as a Bearer token. Agents get request_approval, which takes the same fields as the POST except callback_url, get_decision, which takes the action id and wait_seconds up to 25, and get_autonomy, which returns the agent's earned level per class (see Read your level). No tool can approve or reject, and no tool changes a level. People decide in Opsline.
Each policy-<action> workflow is also a tool named after its action, such as refund for policy-refund. It takes the same fields as request_approval without action, and it asks for amount, payee and each params key the policy reads. For an enrolled key, its title, description and annotations say what a call does at the key's level in each amount band: shadow only records the proposal and answers recorded, supervised waits on a person, and the auto levels let Opsline carry it out, with what the auto_limited daily cap still allows today. _meta carries the same levels as opsline/levels. The server is stateless and can't push tools/list_changed, so an agent reads tools/list again to see a promotion or a demotion.
{
"mcpServers": {
"opsline": {
"type": "http",
"url": "https://<your-opsline>/api/mcp",
"headers": { "Authorization": "Bearer opslk_..." }
}
}
}Or add it with the Claude Code CLI:
claude mcp add --transport http opsline https://<your-opsline>/api/mcp --header "Authorization: Bearer opslk_..."Write a policy
The policy from Get started allows every request. Put branches and approval steps in front of the Decide step to make it stricter, as in Add a per-customer limit.
Create a workflow named policy-<action> with no request form. The request becomes its trigger data: trigger.action_id (the action's id), trigger.agent, trigger.amount, trigger.amount_minor (the amount in the currency's smallest unit, such as cents), trigger.currency, trigger.payee, trigger.params, trigger.reason, trigger.on_behalf_of and trigger.risk. trigger.agent is the API key's name, and trigger.reported_agent is the request's agent label when it differs. Opsline computes trigger.risk by totaling the amounts callers report, and a request can't supply its own totals or flags: payee_total_24h (this amount plus the payee's allowed and pending amounts in the last 24 hours, and amounts denied with execution_failed or execution_unknown), payee_count_24h, agent_total_24h (the same total across every payee for the API key), duplicate, unusual_amount and flags. A decided amount counts for 24 hours from its decision, and a pending one for 24 hours from its request.
Branch on those values and end each path in a Decide step (allow or deny, with a reason) or an approval step. A run that finishes after an approval allows the action. A Decide deny, a rejection, an expired approval or a failed step denies it. A path that ends without a Decide step or an approval also denies it, with reason policy_error and a message pointing to the run, even though the run page shows the run as succeeded. The seeded policy-refund works like this:
- A refund in any currency but USD is denied.
- Opsline reads the Stripe charge in
params.charge_id. A payee that isn't the charge's customer is denied, so one customer spelled two ways can't get two allowances. A charge with no Stripe customer, such as a guest checkout, is denied, because it has no per-customer total. A charge in another currency is denied. - Once one agent's 24-hour total passes $10,000, every refund goes to finance.
- If the payee's 24-hour total stays at $200 or less, a Decide step allows it, unless it looks like a duplicate, which goes to the support lead.
- A 24-hour total up to $2,000 goes to the support lead, with a reminder after an hour.
- A 24-hour total above $2,000 goes to finance, escalating to admins after 30 minutes.
- Every allow and approval ends in the step that issues the refund in Stripe, so the agent never needs a key that can refund.
Let the policy carry out the action
End the policy with an HTTP step that does the action itself, such as a Stripe refund. It runs only after an allow or an approval, because a denial stops the run. Keep the API key in a secret, as Authorization: Bearer {{ secrets.STRIPE_SECRET_KEY }}, so the agent's own key can be read-only.
- Set the body to send as form fields for APIs such as Stripe's. A field with no value fails the step instead of being left out.
- Set the
Idempotency-Keyheader to{{ trigger.action_id }}. Without it, each retry sends a new key, and a timeout after Stripe created the refund could refund twice. - Use
{{ trigger.amount_minor }}for the amount in cents. Opsline computes it from the validated amount, and a request can't supply it. - A branch can compare two values: pick field as the value type to check, say, the charge's customer against
trigger.payee.
When the last step is an HTTP request that succeeded, the action's result holds its step_id, status and response body, so the agent gets the refund id. If that step fails after the allow, the action is denied with execution_failed when the API refused every attempt (a 4xx other than 409 or 429), because the action did not happen. A timeout, a 5xx, a 409 or a 429 on any attempt gives execution_unknown, because the action may have happened. Stripe sends 429 before it checks the Idempotency-Key, so a 429 says nothing about an earlier attempt. Stripe answers a retry under the same Idempotency-Key with what it answered the first time, a 500 included, so look for a refund with metadata[opsline_action_id] equal to the action's id before retrying. Both still count toward the 24-hour totals.
Test a policy from the workflow canvas with sample trigger data before agents use it. The test pauses at approvals and shows which path the request took.
Earned autonomy
An agent in earned autonomy starts in shadow mode and acts alone on a class of actions only after its record in that class clears the bar and a workspace admin approves the promotion. An admin enrolls the agent's API key from its Autonomy tab under Agents. A key that isn't enrolled works as the sections above describe, and its answers carry "autonomy": null.
- Enroll the agent's API key from its Autonomy tab under Agents. Every class starts in shadow, so Opsline carries out nothing for that key until a class is promoted. A key that isn't an agent can do the same with
POST /api/v1/autonomy/enrollmentsand{ "agent": "support-agent" }or theenroll_agentMCP tool. Unenrolling hands the key back to its policies, so only an admin can, from the same section: every class goes back to shadow, open promotions are canceled, and the key's policies then decide for it like any key that isn't enrolled. No API key can unenroll. A key that is enrolled or has requested an action gets 403 on enroll, and MCP doesn't listenroll_agentfor it. A key that has reported labels is a connector's and can't be enrolled, since an enrolled key can't report labels. - Send
agent_versionwith every request, so a new model, prompt or tool list starts the record over. See Agent version. - Report what people did with
POST /api/v1/actions/<id>/labelsfrom a separate connector key that never requests actions, from your own code or a connector workflow in Opsline. See Report what people did and Connector workflow. - If your policy carries out the action with a write secret, add the steps in Send a held action to a person before you approve a promotion. Without them the engine refuses a supervised or sampled action that no person approved earlier in the run.
- Watch each class's record in the agent's Autonomy tab, and approve a promotion request when one arrives.
Refund starter set
For refunds and store credits, an admin can install the Refund starter set from the Integrations page instead of building the workflows: policy-refund with its blind review, policy-credit, connector-stripe and shadow-refund, with every approval going to the workspace's admins. The installed shadow-refund waits 4 days, not the seeded one minute, before it reports that nobody refunded, so a refund made after a weekend still arrives first. Set its wait to the longest your team takes to refund, weekends included, and keep it under 5 days, since a shadow proposal with no label after 5 days counts as unlabeled and can hold a promotion. Add STRIPE_SECRET_KEY and STRIPE_READ_KEY (read only) in Settings, Secrets first. policy-credit posts store credits to your shop with SHOP_API_KEY, so the install leaves it out while that secret is missing. The workflows call STRIPE_API_BASE and SHOP_API_BASE from the server's environment, which default to the local stand-in, so on a server that isn't localhost set them to https:// URLs, such as https://api.stripe.com, before installing. SHOP_API_BASE matters only when policy-credit installs. The install makes a stripe-connector API key, holds it as the OPSLINE_CONNECTOR_KEY secret (so it refuses while the workspace has its own secret by that name), and shows the connector's webhook URL and secret once. Uninstall first names the workflows, the webhook URL and the key it would delete, then removes what it made, except a workflow that has runs or a version after the first, which stays with its history, and the connector key while a workflow that uses it stays. Installing again gives each workflow the uninstall kept a new version with the starter set's steps, over any edit, which stays in its version history, and the panel names each one. It reuses the kept connector key and webhook, whose URL and secret stay as they were and aren't shown again.
Action classes
Opsline gives every action a class from its name and an amount band: refund:0-50, refund:50-200, refund:200-2000 and refund:2000+, or the bare action name when the request has no amount. Upper edges are inclusive, so a $200 refund is in refund:50-200, as a policy's is at most 200 counts it. Each class of each key has its own level and record, and a class starts in shadow on the key's first action in it. The top band, such as refund:2000+, has no upper edge, so it stops at auto_limited and keeps the daily cap.
Levels
shadow: Opsline records the proposal, starts no policy run and answersrecordedwithreason_codeshadow_mode. A person handles the case as usual, and a connector reports what they did.supervised: the policy sends every action in the class to a person, with the agent's record for the class in the approval request. One review in four, picked at random, is blind instead, and so is every one while the class is at the cap on anchored approvals, which in practice keeps at least three reviews in four blind (see Blind reviews).auto_limited: the policy allows the action and its last step carries it out, such as the seeded policy's step that issues the refund with the workspace's Stripe key. Each class acts alone on up to 20 actions or $500 a day, and one action in ten, picked at random, goes to a person as a sampled review. The review is blind only on a policy with a blind approval step. On the seededpolicy-refundthat means the support lead's reviews, with a payee total up to $2,000 in 24 hours, and finance sees the proposal above that. On a policy with no blind step, a class atauto_limitedcan't reachauto(see Limits).auto: the daily cap goes away, and one action in fifty, picked at random, goes to a person.
A duplicate, split or unusual_amount risk flag keeps the agent from acting alone at every level, so a high agreement rate can't outweigh one. So does a currency other than USD, because the classes and the daily cap are in dollars. Shadow applies whatever the policy. Above shadow, the engine refuses any step that sends a write secret while the agent may not act alone, unless a person approved earlier in the run, so a policy that never reads the level still can't carry the action out. The seeded policy-credit works this way. A policy that reads trigger.autonomy, like the seeded policy-refund, can send the action to a person instead (see Send a held action to a person).
What each answer looks like
Every answer to an enrolled key carries autonomy with the action's class, its level, may_act_alone and why. A shadow answer returns 200 with no run and a message:
{
"id": "act_4n8r2k6w0y3t9cqe",
"agent": "support-agent",
"action": "refund",
"amount": 45,
"currency": "USD",
"payee": "cus_R7fT2mWq8L",
"decision": "recorded",
"reason": "shadow_mode",
"reason_code": "shadow_mode",
"approver": null,
"waiting_on": [],
"risk": {
"payee_total_24h": 45,
"payee_count_24h": 1,
"agent_total_24h": 45,
"duplicate": false,
"unusual_amount": null,
"flags": []
},
"result": null,
"run_id": null,
"run_url": null,
"autonomy": {
"class": "refund:0-50",
"level": "shadow",
"may_act_alone": false,
"why": "shadow mode"
},
"created_at": "2026-11-22T09:12:40.512Z",
"decided_at": "2026-11-22T09:12:40.514Z",
"message": "Shadow mode: Opsline recorded this proposal and carried nothing out. Don't act. A person handles this case, and Opsline compares what they do with this proposal."
}When decision is recorded, Opsline only recorded your proposal, so don't act, tell the user a teammate will handle it, and call get_autonomy to see where you may act, ask or only propose. In supervised the answer is pending with waiting_on when the policy asks a person, or denied with autonomy_blocked when it doesn't, and why is supervised, may not act alone. At an auto level, an action the policy lets the agent take alone comes back allowed with its result, and why is auto_limited, within the daily cap or auto level. When the agent can't act alone, why gives the reason, such as risk flag duplicate, daily cap of $500 reached or sampled review, 1 in 10 at auto_limited, and the action waits on a person.
Agent version
Send agent_version with every POST /api/v1/actions or request_approval: your model, the sha256 of your prompt as prompt_sha256 and your tool names as tools.
curl -s -X POST "$OPSLINE_URL/api/v1/actions" \
-H "Authorization: Bearer $OPSLINE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"action": "refund",
"amount": 45,
"payee": "cus_R7fT2mWq8L",
"params": { "ticket_id": "T-1101", "charge_id": "ch_3R7fT2mWq8L" },
"idempotency_key": "refund:T-1101",
"agent_version": {
"model": "anthropic/claude-haiku-5.5",
"prompt_sha256": "<sha256 hex of your system prompt>",
"tools": ["read_charge", "request_approval"]
}
}'Opsline fingerprints the version as the first 16 hex characters of a sha256 over the model, the prompt hash and the sorted tool list. Only model is required, so a prompt or tool change resets the record only when you send prompt_sha256 or tools. A new fingerprint moves every class of the key back to shadow and voids any open promotion request, and that answer's why is agent version changed, shadow mode. A request without agent_version is never compared, so it never resets a class. Once the key has reported a version, though, such a request can't act alone at an auto level, and its why is agent version missing. Any level change starts the record over: only actions requested after the class's current level began count toward it.
Agents Opsline runs
An ai_agent step can propose actions too. In the editor, under Actions the agent can propose, pick the API key it acts as and tick the actions, one per policy-<action> workflow. Enroll the key from its Autonomy tab under Agents first, or the policy alone decides and the key earns no record. The list marks each key enrolled or not and leaves out the connector's key and any key that has reported labels, and publishing refuses them. Each becomes a tool named after its action, and a call goes through that policy as the key, the same way as POST /api/v1/actions, so the key's earned level holds it. The model fills in amount, currency, payee, reason and params, and anything else it sends is dropped. The tool's answer is the action's decision after up to 5 seconds, and a pending answer says whether the policy is still running or a person decides. The run page lists the action id next to the call. The step's own HTTP tools and workflow tools don't go through the key's level, so Opsline holds them at every level: an HTTP tool that sends a write secret fails, with an autonomy.blocked entry on the key, and a workflow tool can't start its workflow, unless a person approved the call or an earlier step of the run.
Opsline sends the agent version itself: the step's model, the names of every tool it offers, and as prompt_sha256 the sha256 of the whole step as canonical JSON, leaving out only its id, name and API key. The model can't report another, so publishing a version of the workflow that changes anything in the step, its instructions, input, tools, files and output fields included, moves every class of the key back to shadow on the next call, with version_changed in the agent's Autonomy tab. Give such an agent a key of its own, since an agent outside Opsline on the same key reports its own version and the two would reset each other. A test run of the draft doesn't request actions.
The seeded hosted-support-agent workflow is one: the stand-in helpdesk's ticket.created event starts it, it runs on the local demo's scripted model, and it proposes refunds as the hosted-support-agent key.
Report what people did
Labels are the ground truth. When an approver approves or rejects an enrolled agent's action, Opsline records a human_decision label (agree or disagree) in the same transaction that settles the action. For a shadow proposal, the connector that watches your support tool or Stripe reports what the person actually did with POST /api/v1/actions/<id>/labels, using an API key other than the agent's. Make that key for the connector alone and never give it to an agent:
# A key for the connector, separate from the agent's own key.
export OPSLINE_CONNECTOR_KEY=opslk_...
# The action the agent proposed for the ticket.
curl -s "$OPSLINE_URL/api/v1/actions?ticket_id=T-1101" \
-H "Authorization: Bearer $OPSLINE_CONNECTOR_KEY"
curl -s -X POST "$OPSLINE_URL/api/v1/actions/act_4n8r2k6w0y3t9cqe/labels" \
-H "Authorization: Bearer $OPSLINE_CONNECTOR_KEY" \
-H "Content-Type: application/json" \
-d '{
"kind": "human_action",
"amount": 20,
"external_id": "re_3R7fT9xLead",
"note": "Support lead refunded $20 of the $45"
}'The connector finds the action's id from the ticket the person handled with GET /api/v1/actions?ticket_id=T-1101, or with ?idempotency_key= when the agent sends one. Matching actions come newest first, each with its id, amount and reason_code, so the connector labels the one answered shadow_mode.
external_id is required and identifies the person's action in your system, such as the refund id. Opsline marks the label agree when amount matches the agent's proposed amount to the cent, and amount 0 means the person refunded nothing. Send amount_minor instead of amount to report it as an integer in the currency's smallest unit, such as Stripe's 2400 for $24.00; sending both is a 422. A new label returns 201 with the class's standing after rescoring:
{
"label": {
"id": "lbl_9w3e7r1t5y8u2i0o",
"action_id": "act_4n8r2k6w0y3t9cqe",
"kind": "human_action",
"verdict": "disagree",
"source": "connector",
"reporter": "api_key:key_5b2n8m4v1c7x3z9a",
"external_id": "re_3R7fT9xLead",
"action_class": "refund:0-50",
"autonomy_level": "shadow",
"detail": {
"agent_amount": 45,
"human_amount": 20,
"note": "Support lead refunded $20 of the $45"
},
"created_at": "2026-11-22T09:40:03.118Z"
},
"autonomy": { "class": "refund:0-50", "level": "shadow", "changed": false }
}When the person did something other than the agent's action, name it in action (snake_case, such as replacement or store_credit, with an optional amount and description). That label is needs_review instead of a forced disagree: it isn't a sample until the grader or a person rules on it. action none means the person did nothing and counts as a disagreement.
curl -s -X POST "$OPSLINE_URL/api/v1/actions/act_2q7w5e9r1t3y6u8i/labels" \
-H "Authorization: Bearer $OPSLINE_CONNECTOR_KEY" \
-H "Content-Type: application/json" \
-d '{
"kind": "human_action",
"action": "replacement",
"description": "sent a new bulb",
"external_id": "closed:T-1106"
}'Leave out action when the person did the agent's action; amount is then required.
Report a bad outcome on an allowed action, such as a dispute, a reversal, a reopened ticket or a rollback, with kind outcome and type dispute, reversal, reopened, rollback or other:
curl -s -X POST "$OPSLINE_URL/api/v1/actions/act_6h1j4k8l2z5x9c3v/labels" \
-H "Authorization: Bearer $OPSLINE_CONNECTOR_KEY" \
-H "Content-Type: application/json" \
-d '{ "kind": "outcome", "outcome": "bad", "type": "dispute", "external_id": "dp_1RbK3d" }'- The same
external_idagain returns 200 withreplayed: true. - A key that is enrolled in earned autonomy or has requested any action gets 403 with
Labels need a separate connector key. This key is enrolled in earned autonomy or has requested actions, so it can't report labels. Create one in Settings, API keys., and the action's audit log getsautonomy.blockedwith the key andown actionoragent key. The entry is written at most once a minute for the same key, action and label kind and 10 times a minute per key, and past that one entry on the key withwhyrate_limitedsays that minute's later refusals weren't written. - 404 for an unknown action. 409 for an
external_idalready used for a different label, or a secondhuman_actionon one action. - 422 for an invalid body, an action from a key that isn't enrolled, a
human_actionon an action that wasn't answeredshadow_mode, or anoutcomeon an action that wasn't allowed. - 429 (with
Retry-After: 60) once one API key has written 120 labels in the last minute. - 500 when the label was saved but rescoring failed. Send the same request again.
Labels can't be edited or deleted, and each one writes an action.labeled entry into the hash-chained audit log.
Connector workflow
The connector can be an Opsline workflow instead of your own service. A workflow named connector-<name> gets events signed with its webhook secret, finds the action with HTTP steps and posts the label with the connector key, held as a secret such as OPSLINE_CONNECTOR_KEY. Stripe signs with its own secret, so the workflow checks Stripe's signature once an admin pastes the Stripe endpoint's signing secret on its page, as the end of this section shows. Every event gets a run in Runs with the requests it made. Only its webhook starts a connector- workflow, so Run now, start_run, schedules and other workflows can't hand it made-up events. The local demo seeds connector-stripe, which handles three events:
refund.createdthat a person issued, with nometadata[opsline_action_id]: it finds the newest shadow proposal on the charge withGET /api/v1/actions?charge_id=<charge>&reason=shadow_mode&limit=1and reports the refund withamount_minor, Stripe's amount in cents. A refund Opsline issued is left alone.charge.dispute.created: it finds the allowed action on the charge with?decision=allowed&unlabeled=outcomeand reports a bad outcome of typedispute.ticket.closedfrom the helpdesk with aresolutionother thanrefund, such asreplacementornone: it finds the shadow proposal by ticket id and reports that action, with the ticket'snoteas the description. A ticket closed with a refund waits for Stripe's event.
unlabeled=<kind> returns only actions of enrolled keys that have no label of that kind yet. Stripe sends nothing for a refund that never happened, so Opsline also starts the workspace's shadow-<action> workflow once for each shadow proposal, with trigger.action_id, trigger.ticket_id, trigger.charge_id and trigger.amount. Only Opsline starts it, and the daily job at 02:00 UTC starts one that never started for a proposal from the last 3 days with no label yet. The seeded shadow-refund waits and reads the action's labels with GET /api/v1/actions/<id>/labels?kind=human_action. When nothing arrived, it reads the Stripe charge with the workspace's read-only STRIPE_READ_KEY secret and reports action none only when amount_refunded is 0. Its wait is one minute so the demo shows it; set it to the longest your team takes to refund, weekends included, such as 4 days, and keep it under the 5 days after which a proposal with no label counts as unlabeled.
Stripe can send straight to the connector. Add the workflow's webhook URL as an endpoint in Stripe that listens to refund.created and charge.dispute.created, since ticket.closed comes from the helpdesk, not Stripe. Then paste that endpoint's signing secret (whsec_...) under Webhook trigger on the workflow's page. Opsline then checks Stripe-Signature (t=<seconds>,v1=<hex>, HMAC-SHA256 over ${t}.${rawBody}) within 5 minutes and refuses a signature it has seen. Until the secret is pasted, a request with Stripe-Signature and no Opsline signature gets 401 with a hint that says where to paste it, which Stripe's dashboard shows. The helpdesk and the shop still sign with the workflow's own webhook secret, which the editor shows once when you turn the webhook on. Without the pasted secret, a relay checks Stripe's signature, signs the same body with the workflow's webhook secret and posts it:
import { createHmac } from "node:crypto";
import Stripe from "stripe";
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);
// rawBody is Stripe's request body exactly as received, before JSON.parse.
export async function relayStripeEvent(rawBody, headers) {
// Throws when Stripe-Signature doesn't match your Stripe endpoint's secret.
stripe.webhooks.constructEvent(
rawBody,
headers["stripe-signature"],
process.env.STRIPE_WEBHOOK_SECRET,
);
const timestamp = Math.floor(Date.now() / 1000);
const signature = createHmac("sha256", process.env.OPSLINE_WEBHOOK_SECRET)
.update(`${timestamp}.${rawBody}`)
.digest("hex");
// The connector workflow's webhook URL, https://<your-opsline>/api/webhooks/<token>
return fetch(process.env.OPSLINE_WEBHOOK_URL, {
method: "POST",
headers: {
"content-type": "application/json",
"x-opsline-timestamp": String(timestamp),
"x-opsline-signature": signature,
},
body: rawBody,
});
}Grader
A shadow label that disagrees or names another action starts a run of the reserved autonomy-grader workflow. Its ai_agent step reads the ticket, the charge and the policy through three workflow tools (read_ticket, read_charge, read_policy) and rules whether the agent's proposal and the person's action are equivalent, with a confidence and a rationale, under a $0.05 budget. read_ticket returns the proposed action, amount and currency and what the person did, and leaves out the agent's reason, params, ticket id and charge id, since the agent being graded wrote them. Only the person's check shows the ticket id. read_charge asks Opsline, which fetches the charge by a charge_id in Stripe's shape with the workspace's read-only STRIPE_READ_KEY secret, or STRIPE_SECRET_KEY when there is no read key, and returns only its amount, amount refunded, currency, customer, description and creation time, so the customer's billing details, receipt email and card never reach the model. Until the grader qualifies, a person checks every ruling. After that, a person checks every ruling with confidence under 0.7 and 1 in 5 of the rest, drawn at random. An admin or operator picks yes or no in the check and presses Approve, from the signed email link or the Approvals page. Reject needs a pick too, and the pick is the answer whichever button was pressed.
- A person's check is the sample for the agent, whatever the grader said.
- The grader has a record of its own: how often its rulings matched the people who checked them, scored with the same Wilson lower bound. Its unchecked rulings count toward an agent's record only once that bound reaches 0.90 over at least 30 checks (a perfect record gets there at 35). Until then they show in the agent's Autonomy tab and count for nothing.
- A ruling that drew a check nobody answered never counts.
- A new model, new instructions or new tools start the grader's record over.
- Each ruling and each check is a label with an
action.labeledentry in the hash-chained audit log, and the agent's Autonomy tab shows the grader's record and its ruling next to each disagreement.
The grader can also be measured on a model before it has a record. pnpm eval:grader --real --max-usd <dollars> in the Opsline repo runs this workflow on a real model over 26 labeled cases made up for the demo shop: split refunds, a partial refund plus store credit, the same money under another action name, replacement parts, no refund, smaller and larger refunds, and notes that try to give the grader instructions. It reports accuracy, accuracy by confidence band, and tokens and cost per case, and it stops before the spend could pass the cap. On 23 Nov 2026, grader version d5eaca4558aa82eb on anthropic/claude-haiku-5.5 got 24 of 26 right for $0.0163 in all. It ruled all 14 not equivalent cases correctly, including the four that try to give it instructions. It ruled two of the 12 equivalent cases not equivalent: a split refund at 0.45 confidence, which a person would check, and a partial refund plus store credit at 0.80. By confidence, it was right 6 of 6 from 0.90 up, 13 of 14 from 0.70 to 0.90, 5 of 5 from 0.50 to 0.70, and 0 of 1 under 0.50. The earlier version 0221234adce4c576 also got 24 of 26 on that model, for $0.0172. It ruled two other equivalent cases not equivalent: a partial refund plus store credit at 0.55, which a person would check, and a refund one cent short of the proposal at 0.85. Every miss so far makes a promotion slower, never faster. The cases are made up, so this shows the grader works on a real model and says nothing about your tickets.
Backtest
Before an agent has a live record, send your team's past decisions to POST /api/v1/backtests from the connector key: each past ticket with the agent's proposal (action, amount) next to what the person did (human_action, human_amount), as CSV with ?agent_key_id= or as JSON { "agent_key_id", "decisions": [...] }. The agent key id, such as key_8d4h2j6k0w3p7s1a, is the agent's key, not the connector key the call is sent with, and is listed under each key's name in Settings and at the top of the agent's page under Agents. Up to 500 rows, one backtest per key per minute. Each row needs ticket_id, action and human_action, and amount, currency, payee, charge_id, reason, human_amount, human_description and decided_at are optional. A missing amount counts as 0 when the person did the agent's action. The projected date needs decided_at, since it comes from the past daily volume, and the rows are replayed in decided_at order.
# Past tickets: the agent's proposal next to what the person did. Three of 40 rows.
cat > past.csv <<'CSV'
ticket_id,action,amount,currency,payee,charge_id,human_action,human_amount,human_description,decided_at
T-0801,refund,24,USD,cus_9f2k,ch_3Pq1,refund,24,,2026-10-30T09:12:00Z
T-0802,refund,38,USD,cus_4m7d,ch_3Pq2,refund,19,,2026-10-30T14:40:00Z
T-0803,refund,40,USD,cus_8x1c,ch_3Pq3,replacement,,sent a new bulb,2026-10-31T10:05:00Z
CSV
curl -s -X POST "$OPSLINE_URL/api/v1/backtests?agent_key_id=key_8d4h2j6k0w3p7s1a" \
-H "Authorization: Bearer $OPSLINE_CONNECTOR_KEY" \
-H "Content-Type: text/csv" \
--data-binary @past.csvOpsline compares each row the way the labels call does, and replays it through the workspace's policy-<action> as a test at auto_limited, with the risk signals and daily cap the rows before it would have produced. Reads run for real and writes are captured, so nothing is carried out, and a policy with an AI step reports an error instead of calling a model. The answer has, per class, the agreement and its lower bound, how many rows need review, what the policy would have done (alone, to a person, denied) and a projected promotion date: when the live record would clear the next bar if new samples arrive at the past daily volume and agree at the past rate. results lists each row with its ticket, class, verdict and what the policy did and why, such as secret not set: STRIPE_SECRET_KEY when the workspace has no Stripe key. The answer for a file of 40 past tickets, trimmed to one row:
{
"backtest": {
"id": "btt_7c2v9n4m1x8z3k5q",
"agent": "support-agent",
"reported_by": "helpdesk-connector",
"source": "csv",
"rows": 40,
"created_at": "2026-11-23T09:00:00.000Z",
"classes": [
{
"class": "refund:0-50",
"label": "refund, up to $50",
"rows": 40,
"compared": 39,
"agreed": 38,
"needs_review": 1,
"rate": 0.974,
"lower_bound": 0.868,
"policy": { "act_alone": 40, "ask": 0, "deny": 0, "error": 0 },
"per_day": 4.103,
"first_decided_at": "2026-10-21T09:00:00.000Z",
"last_decided_at": "2026-10-31T03:00:00.000Z",
"projection": {
"to": "auto_limited",
"date": "2026-12-03T09:00:00.000Z",
"samples_needed": 40,
"reason": "40 more live samples at about 4.1 a day, agreeing 97% of the time"
}
}
],
"results": [
{
"ticket_id": "T-0802",
"class": "refund:0-50",
"verdict": "disagree",
"agent": { "action": "refund", "amount": 38 },
"person": { "action": "refund", "amount": 19 },
"policy": {
"outcome": "act_alone",
"why": "auto_limited, within the daily cap"
},
"decided_at": "2026-10-30T14:40:00.000Z"
}
]
}
}Backtest rows are never samples. They live apart from labels, so the live record still comes only from people who decided without seeing the proposal, and the agent's Backtest tab shows the latest backtest in its own table, with the name of the key that reported it. Each backtest writes an autonomy.backtest_recorded audit entry.
Read your level
get_autonomy over MCP and GET /api/v1/autonomy with the agent's key return its level per class, its record and what the next level still needs. Pass action and amount (?action=refund&amount=45 on the REST call) to get for_request.do: act (request_approval, and Opsline carries it out when the policy allows), ask (the policy asks a person, or Opsline refuses the write) or propose (Opsline only records it, so don't act). An amount without action gets 422 amount needs action: pass the action too, such as action=refund. A key that isn't enrolled gets enrolled: false and ask. Both are read-only.
{
"agent": "support-agent",
"enrolled": true,
"fingerprint": "3f9a1c07d24e8b65",
"classes": [
{
"class": "refund:0-50",
"label": "refund, up to $50",
"level": "shadow",
"since": "2026-11-13T09:00:00.000Z",
"samples": 26,
"agreed": 25,
"lower_bound": 0.811,
"days": 9.1,
"sources": {
"human_action": 26,
"blind": 0,
"human_decision": 0,
"grader_check": 0,
"grader": 0
},
"unlabeled_shadow": 0,
"awaiting_review": 0,
"bad_outcomes_30d": 0,
"next_level": "auto_limited",
"needs": ["14 more samples"],
"pending_promotion": null
}
],
"for_request": { "class": "refund:0-50", "level": "shadow", "do": "propose" }
}Scoring
Opsline scores a class after every label and once a day at 02:00 UTC, so a bar measured in days is checked when no label arrives. A score counts one sample per action requested since the class's current level began, where a shadow label wins over an approver's decision on the same action. It takes the Wilson lower bound of the agreement rate at 95 percent, and checks a minimum number of samples, a minimum span in days, and no bad outcomes in the last 30 days. These are the starting values, to be tuned once real labels exist:
- Shadow or supervised to
auto_limited: 40 samples over 7 days with a lower bound of at least 0.80. auto_limitedtoauto: 100 samples over 14 days with a lower bound of at least 0.90.- For reference, 38 agreements out of 40 give a lower bound of 0.835, and 40 out of 40 give 0.912.
- A promotion waits while shadow proposals still unlabeled after 5 days number more than 10% of the samples, such as 5 against 40, so an agent can't keep its hard tickets out of the record by leaving off the ids a connector matches.
- A promotion also waits while anchored approvals, where the person approved or rejected after seeing the proposal, number more than 25% of the samples, such as 11 against 40. People tend to approve what they are shown, so a record built from approvals has to carry enough shadow and blind samples too.
Blind reviews
A blind review asks the person what they would do before they see the proposal. One supervised review in four is blind, picked at random, and so is every sampled review at auto_limited and auto. While one more anchored approval would put the class over 25%, every supervised review is blind, so the share settles at the cap. A class starts each level with no samples, so in practice the cap, not the draw, sets the share, and it keeps at least three supervised reviews in four blind. A demoted class earns its level back, and a class at auto_limited reaches auto, only when its policy has a blind approval step, as the seeded policy-refund does for the reviews the support lead handles, with a payee total up to $2,000 in 24 hours. Its finance approval above that has no blind step, so those reviews are always anchored. A risk flag or a daily cap keeps the review anchored, so the person sees why it was held. The policy gets trigger.autonomy.blind set to true, and the agent's answer doesn't change.
An approval step is blind when it has blind: true, an action field and, optionally, a number amount field. Its prompt may read {{ trigger.agent }} and nothing else from the request or a step, and a workflow whose blind prompt does can't be published. The seeded policy-refund has one. In the workflow editor, a policy-<action> workflow's approval step has a Blind review checkbox, which adds an action select (the policy's action and none) and a number amount field when the step lacks them, and replaces a prompt that reads the request or a step with one that names only the agent. The approval page, the Approvals inbox, the email and the Slack card show the agent. They show the payee, the ticket id and the charge id only when each is a single id-shaped token, and leave out every other param, the action, the amount, the reason, the totals and the record. The step's output gets blind with the person's action, amount and a verdict against the proposal: agree when the action matches and the amount matches to the cent, disagree otherwise, or needs_review for another action or for the same action with no amount, which goes to the grader. The buttons read Submit answer and No action, and No action answers none and the run goes on. When the verdict isn't agree, the engine refuses any later step of the agent's action that sends a write secret or starts a workflow, enrolled key or not, until a later approval that shows the proposal approves it, and the action is denied with autonomy_blocked.
The seeded policy-refund asks this way at supervised and on a sampled review. Steps after the branch, such as the one that issues the refund, run on an agreeing answer or after the second approval:
{
"id": "blind_tier",
"type": "branch",
"condition": { "left": { "path": "trigger.autonomy.blind" }, "op": "truthy" },
"then": [
{
"id": "blind_lead_review",
"type": "human_approval",
"prompt": "Blind review for {{ trigger.agent }}. Enter what you would do and the amount.",
"approvers": [{ "type": "email", "email": "dana@northwind.example" }],
"blind": true,
"fields": [
{
"key": "action",
"label": "What would you do",
"type": "select",
"required": true,
"options": ["refund", "store_credit", "replacement", "none"]
},
{ "key": "amount", "label": "Amount", "type": "number" }
]
},
{
"id": "blind_differs",
"type": "branch",
"condition": {
"left": { "path": "steps.blind_lead_review.output.blind.verdict" },
"op": "ne",
"right": "agree"
},
"then": [
{
"id": "blind_lead_approval",
"type": "human_approval",
"prompt": "{{ trigger.agent }} wants to refund {{ trigger.amount }} USD to {{ trigger.payee }}.
Your blind answer: {{ steps.blind_lead_review.output.blind.action }} {{ steps.blind_lead_review.output.blind.amount }}",
"approvers": [{ "type": "email", "email": "dana@northwind.example" }]
}
]
}
],
"else": [
{
"id": "supervised_lead_approval",
"type": "human_approval",
"prompt": "{{ trigger.agent }} wants to refund {{ trigger.amount }} USD to {{ trigger.payee }}.
Agent record: {{ trigger.autonomy.record }}",
"approvers": [{ "type": "email", "email": "dana@northwind.example" }]
}
]
}The answer becomes a human_action label with source blind_review, so it weighs like a shadow label and wins over the approval on the same action. The engine counts a blind answer as a person's approval only when its verdict is agree. The seeded policy-refund issues the refund when the answer agrees. When it doesn't, a second approval shows the proposal next to the person's answer, and the refund waits for that decision. The agent's Autonomy tab shows the blind and anchored counts under Samples.
Promotion
When a class clears the bar, Opsline opens one promotion request for that class. It is a run of the reserved autonomy-promotion workflow, created in the workspace on first use, whose one step is an approval routed to the workspace admins. The request shows the agent, the class, both levels and the record, such as 38 of 40 agreed, lower bound 0.835 over 9.5 days, no bad outcomes in 30 days. Samples: 40 shadow. Unlabeled shadow proposals after 5 days: 0. Awaiting the grader or a person's check: 0. Samples come only from labels, so the unlabeled count shows how many proposals the record leaves out, and the awaiting count shows how many labels that name another action still have no ruling that counts. An admin decides from the signed email link or the Approvals page. A reminder goes out after a day, and the request expires after 7 days.
An approval moves the class up and records the admin who approved it. A rejection or an expiry declines the request, and the class needs 10 more samples before Opsline asks again. If the class's level or the agent's version changes while the request waits, Opsline voids it. So does an approval that lands after the record fell under the bar, since the record is scored again when the admin decides. Only Opsline starts an autonomy-* workflow, so Run now, webhooks, forms, email-in, schedules and start_run all refuse one.
Demotion
Demotion waits for nobody. At auto_limited or auto, any bad outcome reported in the class since the level began moves the class to supervised within the labels call that reports it. So does a lower bound that falls more than 0.10 under the level's bar over at least 10 samples, or at auto over at least 16, the fewest at which a perfect record clears 0.80. Opsline sends an alert where its other alerts go, and the class earns its samples again from zero. An admin can also demote a class from the agent's Autonomy tab at any time. A bad outcome at a lower level holds back promotion for 30 days.
Every level change, up or down, writes an autonomy.level_changed audit entry with the old and new level, the reason, the stats and who made the change. The evidence export lists them with their hashes.
Limits
- An agent that calls Opsline over REST or MCP reports its own version, so one that misreports it can hide a model change.
- An agent Opsline runs as an
ai_agentstep proposes actions as the key its step names, with a version Opsline computes from the step. Earlier steps whose output its input reads, and the system prompt Opsline puts before the step's instructions, aren't part of that version, so changing them doesn't move the key back to shadow. Its own HTTP and workflow tools are held at every level, and the gate checks an HTTP tool only when it reads{{ secrets.NAME }}, as below. Other steps of its workflow aren't held, so anhttp_requeststep after it that reads its output runs at any level. - Opsline enforces shadow before any policy runs. Above shadow, the engine checks each step that uses a stored secret. When the agent may not act alone and no person approved earlier in the run, a step with a write secret fails before the secret is loaded, the action is denied with
autonomy_blocked, and anautonomy.blockedaudit entry names the step, the level and the secrets. An admin marks a secret read only in Settings, Secrets, and a step with only read-only secrets runs at any level, such aspolicy-refundreading the charge. A held run can't start a workflow withrun_workflowor an agent's workflow tool either, since the child run doesn't carry the hold. - The engine gate keys on stored secret references. It checks a step or an
ai_agenttool only when it reads{{ secrets.NAME }}, so a key typed into a header, credentials in a URL, a Slack webhook URL typed into the step and everysend_emailstep run in a held run. Keep every write credential in Secrets and reference it there. - A secret's scope is a label an admin sets in Settings, Secrets. Opsline doesn't check what the key can do, so a Stripe key that can issue refunds, saved as Read only, passes the gate. Use Read only for a key the provider limits to reads, such as a Stripe restricted key with read access.
- An enrolled key acts only through policies. MCP gives it no
start_run, andPOST /api/v1/runswith it answers 422 and, when the workflow exists, writesautonomy.blockedto the audit log, so it can't start a workflow that sends a write secret outside its level. The entry is written at most once a minute for the same key and workflow and 10 times a minute per key, and past that one entry on the key withwhyrate_limitedsays that minute's later refusals weren't written. Start workflows with a key that isn't enrolled. - Levels are per action. An agent held on one action can ask under another action whose level still lets it act alone, such as the seeded
goodwillwhilecreditis supervised, so demote actions that move the same money together. - To send a held action to a person rather than fail it, a policy reads
trigger.autonomy, as the seededpolicy-refunddoes and Send a held action to a person shows.trigger.autonomyholdsenrolled,class,level,may_act_alone,whyandrecord, and a request, webhook orstart_runcan't set it. - Opsline carries out Stripe refunds and the demo shop's store credits out of the box, through the seeded policies' last steps. On an action whose policy has no step that carries it out, the agent acts on the allow itself, so a level there is advisory.
- On a policy without a blind approval step, every supervised and sampled review shows the proposal, so it counts as an anchored approval. The policy that Send a held action to a person builds is one. The seeded
policy-creditasks nobody, so a held action there is refused and gets no label. On either kind of policy a class can reachauto_limitedfrom shadow, where connector labels count, but neverauto. Atauto_limitedits only samples come from sampled reviews, and those are anchored approvals that the 25% cap holds back, or no samples at all. A class demoted there can't be promoted again until an admin moves it to shadow in the agent's Autonomy tab or the agent's version changes. Turning on Blind review on the policy's approval step in the editor gives the class blind samples. - Supervised approvals can turn into rubber stamps. Shadow and blind labels come from people who never saw the proposal, so they are the stronger evidence. Opsline caps anchored approvals at a quarter of a record and the agent's Autonomy tab shows where each sample came from. The run page in
/runsand the agent's action list under Agents leave out the proposal while a blind review waits. A blind review shows the payee, the ticket id and the charge id only when each is a single id-shaped token, and leaves out every other param. An agent can still pick ids that hint at an answer. The prompt shows as written, and a blind step's prompt can read only{{ trigger.agent }}, so it can't show the agent's params or payee. - Agreement compares only the action name and the amount, to the cent. The reason, the payee and the other params aren't compared, so an agreeing label says the agent picked the same action and amount and nothing about why. A different action goes to the grader, and
nonedisagrees with any proposal. - The grader's checks are made by people who see its ruling, so its record measures agreement with checkers, not blind accuracy.
- A backtest's agent proposals come from you, by running your agent over past tickets. Opsline can't check that they are what the agent would have proposed, which is one reason they never count.
- A connector workflow's webhook checks Stripe's
Stripe-Signatureonly once an admin pastes the Stripe endpoint's signing secret on the workflow's page. Until then Stripe's events need a relay that checks Stripe's signature and signs again with Opsline's, shown under Connector workflow. The demo's stand-in signs with Opsline's. - The connector matches a refund or a closed ticket to the newest shadow proposal on the charge or ticket. When that proposal already has what the person did, such as a refund that lands after the watch reported
none, or the second part of a split refund, the label call gets 409, the connector's run fails and Opsline sends a run-failed alert. The label already there stays, so the first part of a split refund is recorded as a disagreement, since amounts must agree to the cent. - The seeded
shadow-refundcan check only a proposal whoseparams.charge_idis a Stripe charge or payment id (ch_orpy_, then letters and digits), so a proposal without one gets no label from it and shows in the unlabeled count, which holds promotion once it passes 10% of the samples. Sendcharge_idorticket_idwith each request so a connector can match what the person did.
Evidence
Admins export one agent's actions from the Evidence page or the agent's Evidence tab, or from GET /api/evidence?agent=<API key id>&from=YYYY-MM-DD&to=YYYY-MM-DD&format=json (or format=csv). It needs a signed-in admin session, not an API key. from and to are whole UTC days, both included, and default to the last 30 days. One export holds up to 10,000 actions, and range.truncated is true when there were more.
The JSON has each action with its params, risk signals, decision, approvers, their comments and fields, its action_class, autonomy_level and agent_fingerprint, its labels (kind, verdict, source, reporter, external_id, detail and created_at), and any exceptions (self-approval, approved with no approver, policy error, allowed but not carried out, allowed with an unknown outcome, a bad outcome reported against it), the result of the step that carried the action out, plus every audit entry about those actions, their labels and their policy runs. The CSV has one row per action with the columns id, action, amount, currency, payee, reason, params, decision, decision_reason, approver, approver_comment, approver_fields, on_behalf_of, risk, result_id, run_id, created_at, decided_at, exceptions, action_class, autonomy_level and labels, with one line per label.
The autonomy block covers earned autonomy. classes holds the key's current level, record and version fingerprint for each action class. level_changes lists every level change in the range with its reason, its stats and the person who made it, such as the admin who approved a promotion. audit_events holds every autonomy.* audit entry about the key in the range, with the same before_text, after_text, prev_hash and hash as the other entries.
The JSON's manifest is what a reviewer checks. actions_sha256, audit_events_sha256 and autonomy_sha256 are sha256 hashes of actions, audit_events and autonomy as canonical JSON (sorted keys), so a copy that hashes the same is unchanged. Each audit entry has its hash and prev_hash, and before_text and after_text, its before and after exactly as the hash read them. hash_recipe says how to recompute every hash and check each link. chain_head_hash is the newest hash in the workspace's audit chain when the file was made, and chain says whether the whole chain verified then. The database refuses to delete audit entries, but someone with superuser access could still remove the newest ones, and the entries before them would still verify. A saved export's chain_head_hash is what proves those entries existed, so keep each export and check later that its hash is still in the chain.
To check a saved export without Opsline, press Download verifier on the Evidence page, or fetch /verify-evidence.mjs, and run node verify-evidence.mjs <export.json>. The script imports nothing from Opsline and reads no database. It recomputes every audit entry's hash, checks each prev_hash against the entry before it, compares each label, each action's amount and each level change with the audit entry behind it, recomputes the manifest's three sha256 values, and either says the file is self-consistent or names the first broken entry, exiting 1 when something is broken. It also fails on an entry with no chain_index, on an action.labeled entry about an action in the file whose labels leave that label out, on an autonomy.level_changed entry with no row in level_changes, and, unless range.truncated is true, on an action.requested entry about an action the file leaves out. It doesn't check autonomy.classes, so compare each class's level with the agent's Autonomy tab. An export holds only the entries about one agent, so it checks prev_hash only between entries whose chain_index values are consecutive and says how many gaps it couldn't check. A self-consistent file can still be forged: the hashes carry no key and the recipe is in the file, so someone who edits an entry and rehashes it and the ones after it up to the next gap, or removes a label with its entries, gets a file that passes. The verifier prints the last hash of each run of consecutive entries and chain_head_hash, each with /audit?entry=N, which opens the Audit page at that entry and shows its full hash. Compare all 64 characters with the Hash column and Verify chain there, and check that the entries in each gap are about other things.
