◉ANTIGRAVITY LABJP
Articles/Agents & Manager
◈ Agents & Manager/2026-07-02Advanced

Turning Last Night's Failed Runs into Tomorrow's Prevention — Designing a Postmortem Feedback Loop

Stop letting unattended failures end at a notification. A concrete design for classifying failures and feeding fixes back into Guide skills, gates, and schedules, with measured recurrence rates.

antigravity458agents143postmortemautomation-operationsunattended-runs

✦ Premium Article

An agent run scheduled for 2 a.m. fails, and all that greets you in the morning is a notification. You skim the log, mutter "timeout again," patch something, rerun it, and move on. A few days later a suspiciously similar failure shows up in a different task. As an indie developer running several unattended jobs every night, I lived in that loop longer than I'd like to admit.

The diagnosis is simple. I was responding to failures, but nothing carried the lesson back into my prompts, gates, or schedules. There was no return path.

This article is about building that return path as a fixed piece of machinery. Incident response itself — detection, mitigation, recovery — is covered in Designing Production Incident Runbooks for Antigravity Agents: A Practical Framework from Detection to Recovery, so here I focus strictly on what happens after recovery: making sure the same failure cannot come back unchanged.

Why response and review must be separated

Right after a failure, you are in "just make it pass" mode. Once the rerun succeeds, the motivation to record a root cause evaporates.

So I split the roles by time of day. At night, the only automated reactions are a retry and a notification. Classification and correction happen in a fixed five-minute slot the next morning. Since adopting that separation, the quality of my follow-ups stopped depending on how sleepy I was.

Thinning out the immediate response only works if every run leaves machine-readable evidence behind. That is the foundation.

Recording evidence as a run record

Every run, pass or fail, writes one JSON file on exit. Mine looks like this:

{
  "task": "site-a-premium-article",
  "startedAt": "2026-07-02T02:00:11+09:00",
  "endedAt": "2026-07-02T02:14:52+09:00",
  "exitCode": 1,
  "phase": "quality-gate",
  "lastOutputTail": "templating_gate: duplicated paragraph detected ...",
  "configHash": "9f2c31a",
  "modelUsed": "gemini-3.5-flash",
  "retryCount": 1
}

The field that earns its keep is phase. Slice the run into stages — prepare, generate, quality gate, push, log — and record where it died. Most of the classification below falls out of that one field.

configHash is a hash over the prompt and config files together. It exists to answer "did failures spike right after I changed the config?" — a question it has settled for me twice already.

The record is written by a wrapper script using a trap:

#!/usr/bin/env bash
# run-with-record.sh <task-name> <command...>
TASK="$1"; shift
REC_DIR="$HOME/.agent-runs/$(date +%Y-%m-%d)"
mkdir -p "$REC_DIR"
START="$(date -Iseconds)"
LOG="$(mktemp)"
 
finish() {
  local code=$?
  jq -n \
    --arg task "$TASK" --arg started "$START" \
    --arg ended "$(date -Iseconds)" \
    --arg tail "$(tail -c 800 "$LOG")" \
    --arg phase "${AGENT_PHASE:-unknown}" \
    --argjson code $code \
    '{task:$task, startedAt:$started, endedAt:$ended,
      exitCode:$code, phase:$phase, lastOutputTail:$tail}' \
    > "$REC_DIR/${TASK}-$(date +%H%M%S).json"
}
trap finish EXIT
 
"$@" 2>&1 | tee "$LOG"
exit "${PIPESTATUS[0]}"

The task itself only needs to update export AGENT_PHASE=generation as it moves between stages. Existing tasks barely change.

✦

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
✦A five-way failure taxonomy where each class maps to exactly one place to fix
✦A run-record JSON schema plus a script that turns yesterday's failures into a five-minute morning digest
✦Field data from cutting same-cause recurrence from roughly 40% to 12% over six weeks
Secure payment via Stripe · Cancel anytime
✦

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Antigravity Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • ✦Copy-paste ready implementation code
  • ✦New advanced guides published daily
  • ✦$5/mo or $15 for lifetime access
View Membership →

Related Articles

◈ Agents & Manager2026-09-04
Snapshot Your Agents' Effective Scope So You Notice the Day a Default Changes
Antigravity 1.1.25 made Markdown-defined custom agents inherit the surrounding skills, rules, and subagents by default. Here is the snapshot-and-diff routine I now use to check whether an agent I meant to keep narrow quietly got wider after an update.
◈ Agents & Manager2026-08-21
Why I Check Description Overlap Before Turning On inheritCustomizations
CLI 1.1.14 collapsed markdown agent inheritance into a single inheritCustomizations switch. Here is what happened when I actually inventoried the 47 skills in my workspace and decided the switch on description overlap rather than on context size.
◈ Agents & Manager2026-05-27
Record & Replay for Antigravity Agents
How to deterministically replay a failed Antigravity Agent run offline, drawn from a month of running it across four production sites. Covers boundary recording, R2 + KV storage costs, PII masking, and a working TypeScript harness.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links