Lesson 72.5 · 5 of 7 · 4 min read · Reviewed 24 Nov 2026
Incident response and post-mortems
By the end, you can
- Run incident response for an AI feature.
- Write a blameless post-mortem.
Kinds of AI incident
| Type | Example |
|---|---|
| Availability | Provider outage, rate-limit storm |
| Quality | Answers suddenly wrong after a release |
| Safety | Harmful or policy-breaking output |
| Security and privacy | Prompt injection leaks data |
| Cost | Runaway loop spending heavily |
Response steps
- Detect. Alerts on errors, latency, cost rate, refusals, escalationsEscalation: Handing a case from an agent to a person, with the context needed to continue. and user reports (chapter 67).
- Contain. Kill switch, rollback to last good release, switch to fallback route. Stop harm before finding root cause.
- Communicate. Tell affected users and internal teams what is happening, in plain words. Security or privacy incidents may have legal reporting duties: involve the right people early.
- Fix. Find the first bad step with tracesTrace: A record of everything that happened during one request or agent run, as a tree of timed steps. (67.5), fix it, and test the fix.
- Learn. Post-mortem within days.
The post-mortem
- Timeline, from first signal to resolution
- Impact: who and how many were affected, for how long
- Causes: what went wrong and why the safeguards missed it
- What went well
- Follow-ups with owners: new eval cases, guardrailsGuardrail: A control that keeps an AI system within safe and allowed behaviour, such as input checks, tool limits or output filters., alerts, runbookRunbook: A written procedure for handling a known type of incident: symptoms, checks, actions and escalation. changes
Keep it blameless: focus on how the system allowed the failure, not on who typed the change. People report problems faster when they aren’t afraid.
Key points
- AI incidents include outages, quality drops, harmful outputs, data leaks and cost spikes.
- Respond in order: detect, contain (kill switch, rollback), communicate, fix, then learn.
- A blameless post-mortem records the timeline, causes and follow-ups, including new eval cases and guardrails.
Measure an incident for its post-mortem
Turn an incident's event log into the measured parts of a blameless post-mortem.
You will have: A script that prints detect, contain and resolve times, the impact, the timeline and checks on follow-ups and wording.
Steps
- Run the starter: the times print as question marks.
- Work out time to detect, contain and resolve from the event log.
- Flag follow-ups with no owner.
- Check the causes for blaming words, so the write-up stays about the system.
- Give the unowned follow-up an owner and run again.
Done when
- Time to detect is 12 minutes and time to contain is 6 minutes.
- The runbook follow-up is flagged as having no owner.
- No cause line blames a person.
Open in the Playground No API key needed.
Starter code (Python)
# Turn an incident's event log into the measured parts of a blameless post-mortem.
EVENTS = [ # (minutes after the release, kind, what happened)
(0, "change", "Release 2026.11.3 ships prompt v15 to all users"),
(9, "signal", "Refusal rate on the support bot starts climbing"),
(21, "detect", "Refusal-rate alert fires; on-call acknowledges"),
(24, "communicate", "Status note posted for support staff"),
(27, "contain", "Rolled back to release 2026.11.2"),
(64, "fix", "Prompt v15 instruction on account questions corrected and tested"),
(180, "resolve", "Fixed release 2026.11.5 rolled out through a canary"),
]
AFFECTED_CONVERSATIONS = 1840
CAUSES = [
"Prompt v15 told the bot to refuse anything mentioning account details.",
"The eval set had no account-question cases, so the release bar passed.",
"The release went to 100% of users at once instead of a canary.",
]
FOLLOW_UPS = [
{"action": "Add 40 account-question cases to the eval set", "owner": "agent lead"},
{"action": "Ship prompt changes through a 5% canary", "owner": "release manager"},
{"action": "Alert on refusal rate within 10 minutes of a release", "owner": "on-call lead"},
{"action": "Write the rollback steps into the runbook", "owner": None},
]
BLAME_WORDS = ["careless", "fault", "should have known", "mistake by"]
def first(kind):
return next(m for m, k, _ in EVENTS if k == kind)
# TODO 1: detect = first signal to detect; contain = detect to contain; resolve = first signal to resolve
print("time to detect: ? min")
print("time to contain: ? min")
print("time to resolve: ? min")
print(f"impact: {AFFECTED_CONVERSATIONS} conversations over {first('contain') - first('signal')} min before rollback")
print("timeline:")
for m, k, what in EVENTS:
print(f" +{m:>3} min {k:<11} {what}")
no_owner = [] # TODO 2: follow-ups whose owner is missing
blame = [] # TODO 3: causes that use any of BLAME_WORDS (keep the post-mortem about the system)
print(f"follow-ups without owner: {len(no_owner)}" + (f" ({'; '.join(no_owner)})" if no_owner else ""))
print(f"blaming lines in causes: {len(blame)}")
Show a solution
# Turn an incident's event log into the measured parts of a blameless post-mortem.
EVENTS = [ # (minutes after the release, kind, what happened)
(0, "change", "Release 2026.11.3 ships prompt v15 to all users"),
(9, "signal", "Refusal rate on the support bot starts climbing"),
(21, "detect", "Refusal-rate alert fires; on-call acknowledges"),
(24, "communicate", "Status note posted for support staff"),
(27, "contain", "Rolled back to release 2026.11.2"),
(64, "fix", "Prompt v15 instruction on account questions corrected and tested"),
(180, "resolve", "Fixed release 2026.11.5 rolled out through a canary"),
]
AFFECTED_CONVERSATIONS = 1840
CAUSES = [
"Prompt v15 told the bot to refuse anything mentioning account details.",
"The eval set had no account-question cases, so the release bar passed.",
"The release went to 100% of users at once instead of a canary.",
]
FOLLOW_UPS = [
{"action": "Add 40 account-question cases to the eval set", "owner": "agent lead"},
{"action": "Ship prompt changes through a 5% canary", "owner": "release manager"},
{"action": "Alert on refusal rate within 10 minutes of a release", "owner": "on-call lead"},
{"action": "Write the rollback steps into the runbook", "owner": None},
]
BLAME_WORDS = ["careless", "fault", "should have known", "mistake by"]
def first(kind):
return next(m for m, k, _ in EVENTS if k == kind)
print(f"time to detect: {first('detect') - first('signal')} min")
print(f"time to contain: {first('contain') - first('detect')} min")
print(f"time to resolve: {first('resolve') - first('signal')} min")
print(f"impact: {AFFECTED_CONVERSATIONS} conversations over {first('contain') - first('signal')} min before rollback")
print("timeline:")
for m, k, what in EVENTS:
print(f" +{m:>3} min {k:<11} {what}")
no_owner = [f["action"] for f in FOLLOW_UPS if not f["owner"]]
blame = [c for c in CAUSES if any(w in c.lower() for w in BLAME_WORDS)]
print(f"follow-ups without owner: {len(no_owner)}" + (f" ({'; '.join(no_owner)})" if no_owner else ""))
print(f"blaming lines in causes: {len(blame)}")