Skip to content

Stop an agent

Scenario. An agent starts behaving strangely at 3 a.m. You need it stopped now, without a deployment and without affecting anything else.

Sefra has three switches, from narrow to wide. Each takes effect on the next request and is recorded in the audit trail.

Switch Stops Use it when
Suspend One agent or person One agent misbehaves or its credential may be stolen
Disable One intent, for everyone One action is unsafe
Pause All execution You need everything to stop while you investigate

All three also affect work in progress. A running plan that reaches a stopped step fails there, and Sefra undoes its completed steps. Undo calls still run during a pause, because stopping them would leave partial changes behind.

Start from a clean sandbox, in its directory:

./sandbox destroy
./sandbox up
AGENT=$(./sandbox token agent)
export SEFRA_OPERATOR_TOKEN=$(./sandbox token admin)
budget() {
  curl -sS -X POST http://127.0.0.1:18180/v1/executions \
    -H "Authorization: Bearer $AGENT" -H "Content-Type: application/json" \
    -d '{"intent": "procurement.get_budget", "input": {"department": "it-ops"}}' \
    | jq -c '{status: (.envelope.status // .status), code}'
}
budget
./sandbox sefra control suspend agent:procurement-bot --note "Unusual order pattern"
budget
./sandbox sefra control unsuspend agent:procurement-bot
budget

While suspended, the agent is refused with 403. Sefra also suspends an agent by itself after 20 counted refusals in 10 minutes, which stops a runaway loop before anyone is awake.

The agent keeps working, except for this one intent:

./sandbox sefra control disable procurement.get_budget --note "ERP budget module under maintenance"
budget
./sandbox sefra control enable procurement.get_budget
budget

A pause is the widest switch. It fails the next forward step of every running plan, so do not use it for an upgrade.

./sandbox sefra control pause --note "Investigating an incident"
budget
./sandbox sefra control resume
budget

Every switch is an operator.action event, with who pressed it and why:

./sandbox sefra audit export | jq -r 'select(.type == "operator.action") | "\(.seq)  \(.actor)  \(.body.action)  \(.body.note // "")"' | head -6

The same switches are on the System page of the console, for anyone with the sefra_operator role.