When an agent does the wrong thing — contain, audit, postmortem
An agent merged a change it should not have. Roll back first, use the scoping you configured to contain and reconstruct what happened — diffs, logs and approve-once records — walk the incident workflow, and close with a blameless postmortem whose action items name the missing gate.
At a glance
| When | An agent merged, wrote or executed something it should not have; After any agent action a human did not explicitly approve |
|---|---|
| Where | Agentic Data Engineering |
| Why | The scoping that bounded the blast radius — no push credentials, approve-once tokens, a logged execute path — is what makes the incident auditable and the rollback cheap. |
Learning objectives
- Contain the damage before diagnosing — rollback first
- Reconstruct what the agent did from the audit trail
- Produce a blameless postmortem with dated, owned action items
What you need
- The scoped, logged execute path your agent writes through
- The repository the agent worked in
- [object Object]
Steps
- Roll back first — a deploy broke production: correlate the signal with the change and roll back before diagnosing. (from runbook-bad-deployment )
- Containment was designed in — the git server can commit and create branches in the scoped repository, but cannot push unless credentials are also present in the environment. (from mcp-git )
- Reconstruct the change from the tools the agent had — git_status, git_diff_unstaged, git_diff_staged, git_log, git_commit. (from mcp-git )
- Pull the approval record — any write-class tool against a production target was suspended for an approve-once token scoped to the single call, so the log names the human who approved it. (from hook-prod-write-confirm )
- Walk the incident workflow in order — establish impact and start time, check for a correlated deploy, walk the matching runbook, capture the timeline for the postmortem. (from agent-incident-assistant )
- Keep the assistant's own guardrails on during response — it suggests, never executes, production changes, and escalates to a human before any destructive step. (from agent-incident-assistant )
- Close with the postmortem — timeline, impact, detection gap, contributing factors, and action items with owners and dates. (from skill-incident-postmortem-writer )
Check yourself
- You can list every tool call the agent made — read-only tools leave diffs and logs, writes leave approve-once records.
- The postmortem separates trigger from contributing factors, and every action item has an owner and a date.
Worked example
The rollback-first line — from runbook-bad-deployment
A deploy broke production; correlate the signal with the change and roll
back first.
The approval record — from hook-prod-write-confirm
Any write-class tool against a production target is suspended and surfaced
for a human "approve once" token scoped to the single call.
Postmortem structure — from skill-incident-postmortem-writer
Timeline, impact, detection gap, contributing factors, and action items
with owners and dates.
Sourced from
Security scan
Last sweep 2026-10-24: 0 finding(s), 0 marked as examples.
Common gotchas
- Roll back first — correlate the signal with the change before diagnosing.
- The git server cannot push unless credentials are also present — if the agent pushed, a credential was in scope.
- Mitigation runs under the same guardrails — suggest, never execute, production changes.
Production considerations
- Keep the approve-once token log with the postmortem — it is the audit record of who approved the write.
- Feed the detection gap back into the hooks — the postmortem's action items should name the gate that was missing.
Diagram
agent incident
|
|- rollback first --> correlate signal with change
|
|- contain --> no push credentials --> wrong commit stays local
|
|- audit --> git log/diff + approve-once token log
|
|- respond --> impact -> correlated deploy -> runbook -> timeline
|
|- close --> blameless postmortem -> owned, dated action items
Registry stats
| Verification | community · Oct 23, 2026 |
|---|---|
| Completeness | 81 |
| Trust multiplier | ×1.25 |
| Composite | 34.15 · adequate |
| Freshness | 1 days since last source check |
| Difficulty | advanced |
| Version | 0.1.0 |
| License | CC-BY-4.0 |
| Security flags | none |
Did this solve your problem?
When an agent does the wrong thing — contain, audit, postmortem