Rewriting "Restart It If It Looks Wrong" Into a Runbook an AI Can Execute

"Restart it if it looks wrong" is enough for a veteran on-call engineer, but a new hire or an AI agent can read it as several different actions. A restart runbook with numeric observation conditions, target, approval and execution, stop conditions and recovery checks, plus acceptance tests for recovery during approval and duplicate requests.

John Baek
John Baek
Founder, CollabOps
2 min read

"If the preview service looks wrong, restart it." An engineer who has been on call for years reads that line and knows which metric on which server to check. A new on-call engineer or an AI agent can pick a different action from the same sentence. It might restart all four servers running the same version. It might act on a server that has already recovered. Rewriting a runbook means putting into words the judgment the veteran was making in their head.

A runbook an AI can execute spells out, in numbers, under what condition, on which single target, how many times, when to stop, and how recovery is judged, rather than just what to do.

What sentences does a restart runbook need?

A restart runbook needs five items with numbers attached: observation condition, target and evidence, approval and execution, stop conditions, and recovery check. Take a stateless preview API running on four production servers as the example. The numbers below are assumed to be thresholds agreed by a team that knows the service's traffic and spare capacity.

Runbook itemSentence the executor reads
Observation conditionOver the last 5 minutes, each server handled at least 200 requests, one server's 5xx rate is 5% or higher, and the other three are each below 0.5%. That server becomes the candidate.
Target and evidencePin the project, production environment, a single server ID, observation window and error samples into the request. Save diagnostic records before restarting.
Approval and executionAfter production approval, re-check the error condition and the spare capacity of the other three. Stop new traffic to the one target, wait for in-flight requests to finish, and restart the process once.
Stop conditionsStop if errors rise on other servers too, or if in-flight requests don't finish within the time limit. If a request that already ran arrives again, look up the existing result.
Recovery checkAfter three consecutive health check passes, send a small amount of traffic. If 5xx stays below 0.5% over at least 200 requests in 5 minutes, return to normal weight. If the sample is too small, hand off in an observing state.

The "at least 200 requests" condition matters more than it looks. On a server that handled ten requests, one failure is a 10% error rate. The decision not to restart when the sample is small belongs in the runbook too.

What should the approval screen title say?

The approval screen title changes as well. Instead of Approve preview service restart, it can read Production preview API · server 03 only · one process restart. If server 03 has already recovered by the time the approver opens the screen, the executor re-reads the conditions and records closed: recovery confirmed. Things can change in the few minutes between approval and execution. Putting a manual approval inside an automation run is also how AWS Systems Manager's aws:approve works.

Put a duplicate request in the acceptance test

The acceptance test for this runbook needs a scene where the same execution request is sent twice. The first request restarts the server but the response is slow. Check that the second request finds the same execution record and shows it, the same way a deploy retry after a lost response recovers the earlier result by its execution ID. That way the next on-call engineer gets, in one record, which server was touched, how many times, and how the service recovered.

  • #sre
  • #ai-agent
  • #runbook
  • #incident
  • #change-management