ANTIGRAVITY LABJP
Articles/Agents & Manager
Agents & Manager/2026-05-29Advanced

Supervising Long-Running Antigravity Agents — Watchdog and Tiered Recovery

Eight weeks of running AdMob revenue optimization on Antigravity background agents revealed three quiet failure modes. Here is the watchdog plus tiered recovery design I landed on.

agents128antigravity434watchdog2observability19production71

Premium Article

I am Masaki Hirokawa (@dolice), an indie developer since 2014, running a portfolio of wallpaper and mindfulness apps with around 50 million cumulative downloads. For the past eight weeks I handed off AdMob eCPM tuning and Crashlytics triage to Antigravity background agents. After the first three weeks I learned an uncomfortable thing: agents keep running while completely broken. The process is alive, the terminal stays quiet, but nothing inside is actually moving.

Below are the three stall modes I observed across that period, and the watchdog plus heartbeat plus tiered recovery design I eventually settled on. Notes for fellow indie developers running agents overnight.

Three observed stall modes

When a long-running agent goes quiet, the failure mode almost always falls into one of three buckets. Across eight weeks I logged 142 abnormal terminations with the following breakdown.

  1. Unresponsive (41%) — An LLM call goes out and never returns, but the SDK never raises a timeout or retry either. Process is alive, CPU sits at 0%, everything looks fine.
  2. Session-dead (34%) — The Antigravity workspace session has expired internally. New tool calls fail silently. The agent keeps planning the "next step" as if nothing was wrong.
  3. Context-bloat (25%) — Input context exceeds limits, the agent enters elision mode, can no longer recall its earlier decisions, and loops over the same step.

None of these is detectable from outside. The process is alive, memory and CPU look calm. You have to look at internal logical state. This is the biggest trap I fell into as someone who used to rely on process-level monitoring.

Overall architecture

This is the layout I landed on.

  ┌────────────────────────────────┐
  │ Agent Process (Antigravity)    │
  │  - business logic              │
  │  - heartbeat(stage, progress)  │──┐
  └────────────────────────────────┘  │ writes
                                       ▼
                            ┌───────────────────┐
                            │ heartbeat.json    │ (atomic write)
                            └───────────────────┘
                                       ▲
                                       │ reads (5s interval)
  ┌────────────────────────────────┐  │
  │ Supervisor Process             │──┘
  │  - watchdog timer              │
  │  - tiered recovery             │
  │  - escalation log              │
  └────────────────────────────────┘

The agent itself only writes its own progress to heartbeat.json. All judgment lives in the supervisor. The premise is that an agent in trouble cannot be relied on to rescue itself.

Why an external supervisor instead of self-monitoring

I tried the pattern of "if you find yourself stuck, please recover" inside the agent itself first. It failed on two of the three stall modes. The unresponsive mode never reaches the recovery code path, and the context-bloat mode forgets the very fact that it is stuck. An independent supervisor process is non-negotiable.

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
Three stall modes observed across 8 weeks (unresponsive / session-dead / context-bloat) and how to detect each
Full TypeScript implementation of watchdog and heartbeat protocol in about 90 lines
Tiered recovery (soft retry / context reset / agent rotation) with the measured 87% auto-recovery ratio across 6 parallel sites
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 $10 for lifetime access
View Membership →

Related Articles

Agents & Manager2026-05-27
Record & Replay for Antigravity Agents — A Production Pattern to Reproduce Failures in 3 Minutes
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.
Agents & Manager2026-07-05
Protecting Your Agent Stack's Known-Good State with a Single Lockfile — Change-Budget Design for an Era of Simultaneously Moving Parts
When the IDE build, CLI, model, and dependencies all move at once, you can no longer tell which one caused a regression. Here is a change-budget design that pins your known-good state to one lockfile, with working code and operational logs.
Agents & Manager2026-06-15
Containing Failure in Antigravity Multi-Agent Systems: Three Boundaries That Stop Cascades
Antigravity multi-agent setups run beautifully in isolation but cascade in production, where one small failure drags the whole orchestration down. These notes organize the fix around three boundaries—layered control, trust separation, and observability with idempotency—down to the TOML and the correlation-ID wrapper.
📚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
See all →