Run a blameless postmortem for an incident caused by an AI agent or LLM feature — hallucinated facts shipped to users, runaway tool use, prompt injection, co...
---
name: agent-incident-postmortem
description: "Run a blameless postmortem for an incident caused by an AI agent or LLM feature — hallucinated facts shipped to users, runaway tool use, prompt injection, cost blowouts, or wrong actions taken autonomously. Use when asked to write up an AI incident, analyse why an agent did something wrong, or produce corrective actions after an LLM failure. Produces a structured postmortem with trace reconstruction, a root-cause layer analysis, and corrective actions including a permanent regression case. For non-AI production incidents use incident-postmortem."
homepage: https://mohitagw15856.github.io/pm-claude-skills/skill/agent-incident-postmortem.html
metadata:
{
"openclaw": { "emoji": "🦾" }
}
---
# Agent Incident Postmortem Skill
AI incidents differ from outages: the system didn't go down — it did something wrong, confidently, and maybe only once. This skill adapts blameless postmortem practice to nondeterministic systems, where "can we reproduce it?" needs traces, not just steps.
## What This Skill Produces
- A **blameless postmortem document** with timeline and user/business impact
- A **trace reconstruction** of what the agent saw, decided, and did
- A **root-cause analysis across the AI failure layers** (not "the model hallucinated" as a conclusion)
- **Corrective actions** — always including a new permanent case in the regression suite
## Required Inputs
Ask for (if not already provided):
- **What the agent did** and what it should have done
- **The trace** — the full request: system prompt, context, tool calls and results, output. If no trace exists, that absence is itself a finding
- **Blast radius** — how many users/requests, over what window, and whether it's ongoing
- **Detection** — how it was noticed (user report? monitor? luck?) and how long after it started
## Root-Cause Layers
Walk the layers in order; the root cause is usually the *earliest* layer that could have prevented the outcome. "The model was wrong" is a starting point, never the conclusion — models are known to be fallible, so the question is what let a fallible output become an incident.
| Layer | Ask |
|---|---|
| **Input / context** | Was the context wrong, stale, contradictory, or poisoned (injection)? Did retrieval feed it bad ground truth? |
| **Model behaviour** | Given that context, was the output a foreseeable failure mode (fabrication under missing data, over-compliance with injected text)? |
| **Guardrails** | What check should have caught this output and didn't exist / didn't fire? (schema validation, groundedness check, action allow-list) |
| **Action layer** | Why could the wrong output become a real action or reach a user without the appropriate gate for its risk level? |
| **Detection** | Why did we learn about it this way, this late? What signal would have caught it in minutes? |
## Nondeterminism Discipline
- **Reproduce with the trace, not the anecdote:** replay the exact context; then re-run N times to measure frequency — a 1-in-20 failure at 10k requests/day is 500 incidents/day.
- **Pin everything when replaying:** model version, prompt version, temperature, tool results.
- **If it can't be reproduced:** say so, keep the trace as the evidence, and treat frequency as unknown — not as "rare".
## Output Format
### AI Incident Postmortem: [title] — [date]
**Severity:** [level] · **Status:** [resolved/monitoring] · **Owner:** [name]
**Summary:** [3 sentences: what the agent did, impact, root cause layer]
**Impact:** [users/requests affected, window, cost, trust/regulatory dimension]
**Timeline:** [first bad output → detection → mitigation → resolution, with the detection gap called out]
**Trace reconstruction:** [what was in the window; which tool calls ran; where the path diverged from intended behaviour]
**Root cause by layer:**
| Layer | Finding |
|---|---|
| Input/context | |
| Model behaviour | |
| Guardrails | |
| Action layer | |
| Detection | |
**Reproduction:** [replayed? failure frequency over N runs / not reproducible — evidence is the trace]
**Corrective actions:**
| Action | Layer | Owner | Due |
|---|---|---|---|
| Add this trace as a permanent regression case | eval | | |
| [guardrail/monitor/context fix] | | | |
**What went well / what got lucky:** [both, honestly]
## Quality Checks
- [ ] The postmortem is blameless toward humans *and* useful about the system — "prompt engineer error" and "model hallucinated" are both banned conclusions
- [ ] Root cause identifies the earliest layer that could have prevented impact, not just the layer that misbehaved
- [ ] The trace (or its absence) is in the document; findings cite it
- [ ] Failure frequency was measured or explicitly marked unknown
- [ ] Corrective actions include the permanent regression case and at least one detection improvement
## Anti-Patterns
- [ ] Do not close with "improved the prompt" as the only action — the same class of output must also be caught by a guardrail or gate next time
- [ ] Do not assess frequency from one replay — nondeterministic failures hide at low temperatures and reappear at scale
- [ ] Do not skip the injection question when any untrusted text (web, user docs, tickets) was in the window
- [ ] Do not let "the model will be better next version" close an action item — upgrades are migrations (see model-migration-plan), not fixes
- [ ] Do not write it as an outage report — the system was up; the failure was behavioural, and the doc must analyse behaviour
don't have the plugin yet? install it then click "run inline in claude" again.
added explicit inputs section with external connections (llm api, tracing backend, regression suite), fleshed out procedure into 7 discrete steps with input/output for each, made decision points explicit (trace availability, reproducibility frequency, ongoing status), formalized output contract as complete markdown template with all required fields, clarified outcome signal as measurable success criteria including regression test automation.
use this skill when an ai agent or llm feature caused an incident (hallucinated facts shipped to users, runaway tool use, prompt injection, cost blowouts, wrong autonomous actions) and you need a blameless postmortem. ai incidents differ from outages: the system stayed up but did something wrong, confidently, and maybe only once. this skill adapts blameless postmortem practice to nondeterministic systems, where reproducibility requires traces and statistical measurement, not just step replication. output is a structured postmortem document with timeline, user/business impact, trace reconstruction, root-cause analysis across ai failure layers, and corrective actions including a permanent regression test case.
gather these before starting (ask if not already provided):
external connections (if applicable):
LLM_API_KEY. scope: model inference only. note rate limits and billing account in blast radius.TRACE_BACKEND_URL. scope: read full execution traces. required to reconstruct exact context.collect the incident snapshot: obtain the execution trace, timestamp, model/prompt versions, and user report. document any missing pieces (if trace is unavailable, note this as a finding now).
reconstruct the execution trace: walk through exactly what context the agent received, what it decided, what tools it called, what results came back, what it output. cite the trace verbatim.
map the root-cause layers: walk each layer in order (input/context, model behavior, guardrails, action layer, detection). for each layer, ask: "could this layer have prevented the incident?" the root cause is the earliest layer that could have stopped it.
measure reproducibility and frequency: attempt to replay the exact trace (same context, model version, temperature, tool results). then run N times (minimum 5, recommended 20+) to measure how often the failure occurs.
write the postmortem document: assemble into structured format below. ensure blamelessness toward humans (no "prompt engineer error" or "operator fault") while being ruthlessly useful about system failure. cite the trace, cite the layer analysis, cite reproduction results.
write corrective actions: for each, specify which layer it addresses and whether it prevents, detects, or mitigates. always include at least one permanent regression case and one detection improvement.
add permanent regression test: write a test case that exercises the exact trace from step 2 and asserts the model does not produce the bad output. add to test suite. this case should run in ci/cd.
if trace is fully available: reconstruct it step 3 (input/context through detection layers) and proceed to reproducibility testing.
if trace is partial or unavailable: document what's missing (were logs not captured? trace backend down?). treat absence of data as a finding in "detection" layer. do not speculate about missing steps; flag as unknown and recommend adding traces retroactively.
if failure is reproducible 100% of the time: root cause is often in input/context or model behavior. proceed to guardrails and action layer to find why it wasn't caught. set reproduction frequency to 100%.
if failure is intermittent (5-95% frequency): root cause usually in model behavior (nondeterminism at this temp/model) or guardrails (probabilistic check that doesn't always fire). note that rerunning at different temp will change frequency; always pin temperature in reproduction. mark frequency as "measured" not "estimated".
if failure is not reproducible (0% in local replay): context or tool results must differ in production. investigate stale retrieval index, live tool side effects, or production model serving a different version. call out that frequency is unknown and recommend production instrumentation (trace sampling, live replay). do not close this action as "rare".
if root cause spans multiple layers: identify the earliest one (the one that, if fixed alone, would prevent recurrence). flag other layers as secondary (e.g., "model behavior is a known failure mode; guardrails should catch it anyway").
if detection gap is large (hours/days between start and discovery): prioritize detection improvement as first corrective action. new alerts, sampling, or user feedback loops belong here.
if blast radius is ongoing: mark status as "monitoring" not "resolved" until traffic returns to baseline and no new incidents observed.
produce a markdown document named postmortem-[incident-slug]-[date].md. format must be:
# AI Incident Postmortem: [incident title] , [date]
**Severity:** [critical/high/medium/low] · **Status:** [resolved/monitoring] · **Owner:** [name]
## Summary
[3 sentences: what agent did, impact, root cause layer]
## Impact
- Users/requests affected: [number, timeframe]
- Window: [start datetime → end datetime, duration]
- Cost: [if applicable, in dollars or usage units]
- Trust/regulatory: [data exposure, soc-2 gap, user trust damage, etc., or "none"]
## Timeline
- [timestamp] incident start: [first bad output]
- [timestamp] detection: [how found, by whom]
- [timestamp] mitigation: [what was done, by whom]
- [timestamp] resolution: [fully fixed, monitoring in place]
- **Detection gap: [duration between start and detection]**
## Trace Reconstruction
[full execution trace as timeline, verbatim from logs]
[tool calls and results]
[where behavior diverged]
## Root Cause by Layer
| Layer | Finding |
|---|---|
| Input/context | [citation to trace] |
| Model behavior | [citation to trace] |
| Guardrails | [citation to trace] |
| Action layer | [citation to trace] |
| Detection | [citation to trace] |
**Earliest preventative layer:** [which layer could have stopped this]
## Reproduction
- Reproduced: [yes/no]
- Frequency: [N/M runs, percentage] OR [not reproducible, frequency unknown]
- Pinned parameters: [model, temp, prompt version, retrieval index, tool versions]
## Corrective Actions
| Action | Layer | Owner | Due |
|---|---|---|---|
| Add regression test case [test id] | eval | [name] | [date] |
| [action] | [layer] | [name] | [date] |
| [detection/alert improvement] | detection | [name] | [date] |
## What Went Well / What Got Lucky
- What went well: [human or system response that contained damage]
- What got lucky: [what almost went worse, or what found it early]
## Quality Checklist
- [ ] Blameless toward humans, useful about system (no "prompt engineer error", no "model hallucinated" as conclusion)
- [ ] Root cause is earliest preventative layer, not just layer that misbehaved
- [ ] Trace (or absence) is in document; findings cite it
- [ ] Failure frequency measured or explicitly marked unknown
- [ ] Corrective actions include permanent regression case + at least one detection improvement
- [ ] No action is "improve the prompt" alone; guardrails or gates also included
- [ ] Injection question asked if any untrusted text in window
- [ ] Model upgrade is tracked as migration, not as fix
the postmortem is done when:
measure success by: regression test runs in ci/cd, detection alert is live and would catch this class of incident in the future, and the same failure does not recur within 30 days of resolution.