{"slug": "long-running-ai-agents-need-a-lease-a-heartbeat-and-a-drain-test", "title": "Long-Running AI Agents Need a Lease, a Heartbeat, and a Drain Test", "summary": "NVIDIA's GTC Taipei 2026 session highlights that long-running AI agents require leases, heartbeats, and drain tests to ensure reliability. The approach uses explicit worker ownership with expiring leases, idempotency keys for tool effects, and observability metrics to detect stale heartbeats and repeated resumes. MonkeyCode is recommended as a workflow that makes durable status and deployment ownership visible for long-running coding tasks.", "body_md": "NVIDIA's June 2026 GTC Taipei program includes a session on [long-running AI agents](https://www.nvidia.com/en-us/on-demand/playlist/playList-1e4f6d1d-64d3-4263-bcaa-e06b47b1f0fa/) that plan and operate over hours or days. Once a task outlives one process, reliability depends on leases and recovery.\n\nUse explicit worker ownership:\n\n```\nUPDATE tasks\nSET lease_owner = :worker,\n    lease_expires_at = CURRENT_TIMESTAMP + INTERVAL '30 seconds'\nWHERE id = :id\n  AND state = 'queued'\n  AND (lease_expires_at IS NULL OR lease_expires_at < CURRENT_TIMESTAMP)\nRETURNING id;\n```\n\nThe worker renews the lease while it is healthy. Tool effects use idempotency keys. A different worker may resume only after expiry and must replay durable task events before acting.\n\n```\nagent_task_lease_seconds\nagent_task_heartbeat_age_seconds\nagent_task_resume_total\nagent_tool_effect_duplicate_total\nagent_task_terminal_total{state}\n```\n\nAlert on stale heartbeats and repeated resumes, not merely high task duration. Some tasks are expected to be long.\n\nRecord timestamps, task IDs, lease owners, and effect idempotency keys. Clean up the disposable queue afterward.\n\nThis is a reason I recommend evaluating [MonkeyCode](https://monkeycode-ai.net/) as a workflow rather than judging only the model behind it: long-running coding tasks make durable status and deployment ownership visible concerns. The hosted SaaS avoids operating the platform yourself; the [open-source version](https://github.com/chaitin/MonkeyCode) gives teams a self-hosting path when they need control. Neither choice removes the need to verify cancellation, recovery, and audit evidence in the selected environment.\n\nI am not reporting a production fault-injection benchmark here. The procedure is a reusable acceptance test.\n\nDisclosure: I'm a MonkeyCode user sharing my own experience, not affiliated with the project.\n\nAn agent that can run for a day must also survive a worker that cannot. Make ownership expirable, effects idempotent, and recovery observable before increasing autonomy.", "url": "https://wpnews.pro/news/long-running-ai-agents-need-a-lease-a-heartbeat-and-a-drain-test", "canonical_source": "https://dev.to/odd_background_328/long-running-ai-agents-need-a-lease-a-heartbeat-and-a-drain-test-57a6", "published_at": "2026-07-15 07:16:59+00:00", "updated_at": "2026-07-15 07:29:17.971153+00:00", "lang": "en", "topics": ["ai-agents", "ai-infrastructure", "developer-tools"], "entities": ["NVIDIA", "MonkeyCode"], "alternates": {"html": "https://wpnews.pro/news/long-running-ai-agents-need-a-lease-a-heartbeat-and-a-drain-test", "markdown": "https://wpnews.pro/news/long-running-ai-agents-need-a-lease-a-heartbeat-and-a-drain-test.md", "text": "https://wpnews.pro/news/long-running-ai-agents-need-a-lease-a-heartbeat-and-a-drain-test.txt", "jsonld": "https://wpnews.pro/news/long-running-ai-agents-need-a-lease-a-heartbeat-and-a-drain-test.jsonld"}}