An agent fixes it, you approve by text
Someone acknowledges a page at 3 a.m., your agent works out a fix, and it runs only after that person texts Y.
Something breaks in production at 3 a.m. Adam is paged and acknowledges. Your agent starts on the problem, finds that the last deploy caused it, and wants to roll it back. It texts Adam first:
[treason.app] P2: Approval needed: Roll back deploy 4f2a in production (#4822). Reply Y4822 to approve or N4822 to deny.
Adam replies Y4822, and the agent rolls back. If Adam says no or doesn't answer, nothing runs.
treason.app does not run the agent. It does what it already does for every page: it reaches a person, records who answered, and tells your systems. The agent runs on your infrastructure, with your credentials and your model provider, so you control what it can touch.
#How it fits together
- A monitoring tool raises an alert, and the on-call person is paged as usual.
- They acknowledge. treason.app sends
alert.acknowledgedto your webhook, with who acknowledged. - Your webhook receiver starts your agent with the alert.
- The agent investigates with your tools: logs, metrics, recent deploys.
- Before it changes anything, it asks for approval with
relatedAlertIdset to that alert. The person who acknowledged is paged with the question, and the team's escalation policy still runs behind them. - They answer by text, a key on a call, the app or the dashboard. The question and the answer are written into the original alert's timeline.
- The agent acts only on
approved: true.
#1. Receive the acknowledgement
Subscribe a webhook to alert.acknowledged, in the dashboard under Settings → Developers → Webhooks or from code:
const { secret } = await treason.webhookEndpoints.create({
url: "https://ops.example.com/hooks/treason",
events: ["alert.acknowledged"],
});The event says who acknowledged, as a person when we can tell:
{
"type": "alert.acknowledged",
"data": {
"alert": { "id": "5b0f0c5e-…", "tinyId": 4821, "message": "Checkout error rate above 5%", "status": "acknowledged", "…": "…" },
"acknowledgedBy": { "actor": "sms:9d2c…", "userId": "9d2c…", "name": "Adam" }
}
}userId is null when an API key or an integration acknowledged, not a person. Then start the agent. Answer the webhook quickly and do the slow work in the background, since a delivery that takes more than 10 seconds is retried:
import { webhooks } from "@treason/sdk";
app.post("/hooks/treason", express.raw({ type: "application/json" }), (req, res) => {
const event = webhooks.constructEvent(req.body, req.headers["x-treason-signature"], process.env.TREASON_WEBHOOK_SECRET!);
res.sendStatus(204);
const alert = event.data.alert;
if (event.type === "alert.acknowledged" && alert?.tags.includes("checkout")) {
queue.add("investigate", { alertId: alert.id, message: alert.message });
}
});Pick which alerts the agent takes on: by tag, by source, by team. An agent that starts on every alert will mostly be investigating noise.
#2. Guard the risky tools
Give the agent a treason.app key that can send alerts, never a full-access one. That key can ask for an approval but can't approve one, so a confused or compromised agent can't answer for Adam.
Wrap every tool that changes production so it runs only after a yes. examples/agent-approval has the wrapper:
import { withHumanApproval } from "./guard.js";
const rollback = withHumanApproval(treason, "rollback", deploys.rollback, {
describe: ({ deployId }) => `Roll back deploy ${deployId} in production`,
relatedAlertId: job.alertId, // the alert from the webhook
priority: "P2", // P1 rings through; P3 is a push and a text
timeoutMs: 15 * 60_000, // no answer in 15 minutes means no
});
const result = await rollback({ deployId: "4f2a" });
// { ran: true, value } or { ran: false, reason: "denied" | "timeout" }Without the wrapper it is one call:
const answer = await treason.approvals.ask({
title: "Roll back deploy 4f2a in production",
context: { deploy: "4f2a", reason: "error rate rose from 0.2% to 6% two minutes after it shipped" },
relatedAlertId: job.alertId,
timeoutSeconds: 900,
});
if (!answer.approved) return; // denied, expired or cancelled: do nothingPut what the person needs to decide in context: the command, the diff, what the agent saw. The text message carries only the title, so make it a complete sentence. The context shows in the dashboard and the app.
#Using an MCP client instead
If the agent runs in Claude Code, Cursor or another MCP client, add the MCP server and tell the agent which alert it is working on. request_approval takes the same link as alert_id:
{ "title": "Roll back deploy 4f2a in production", "alert_id": "5b0f0c5e-…", "context": { "deploy": "4f2a" } }The tool returns approved: true only when a person said yes. Otherwise it says not to proceed.
#What relatedAlertId changes
| Without it | With relatedAlertId | |
|---|---|---|
| Who is asked | The team's escalation policy, or userIds | Whoever acknowledged that alert first, then the policy. userIds still overrides. |
| Which team | teamId, or the only team | That alert's team, unless teamId says otherwise |
| Timeline | Only on the approval's own page | The question and the answer also appear on the original alert |
| In the dashboard | "For alert #4822" | "About alert #4821" |
Deciding an approval closes only the page that asked the question. The original alert stays as it is until someone, or the agent, closes it.
#Good defaults
- Deny on timeout. Keep
onTimeout: "deny", the default. Silence at 3 a.m. should not count as a yes. - One approval per action. Ask right before each change, with what it will do, not once for "fix it".
- Read-only first. Let the agent investigate freely, but require an approval for every tool that writes to production.
- Leave notes. The agent can write what it found and did onto the alert (
treason.alerts.note(alertId, text), oradd_alert_noteover MCP), so the timeline explains itself in the morning.