Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Restart‑Safe and Duplicate‑Free: How Baize Makes Long‑running Agent Runs Resumable

Описание и применение

Baize обеспечивает безопасный и бездублирующийся запуск долгих задач агента, сохраняя каждый Run в базе данных, используя аренду и сердцебиение для гарантии однократного выполнения, а также рекавери орфанских задач и воспроизводимые события для фронтенда.

Задача

Agent runs can span minutes to hours, involve human approvals, and may be retried across replicas, leading to lost or duplicated work when workers crash or restart.

Результат

Baize achieves restart‑safe, duplicate‑free long‑running agent runs by persisting Runs in a database, using leases and heartbeats for single execution, a reconciler for orphan recovery, and replayable event streams for front‑end resilience.

Рабочий процесс

  • 1. Trigger (chat, webhook, schedule, approval, child receipt) enqueues a Job and creates a Run row. 2. Workers pull Jobs (default 8 concurrency) and attempt to lease the Run via a DB UPDATE. 3. If lease acquired, worker heartbeats every ~20s to extend a 60s TTL. 4. Run executes; may enter waiting_human state for approvals or child receipts. 5. On worker crash, reconciler scans every 15s, re‑enqueues orphan Runs. 6. On shutdown, workers stop pulling new Jobs, allow 5s grace for in‑flight work, and rely on DB state for recovery. 7. Human approvals trigger either a hot wake‑up (same process) or an approval_resume job (cross‑restart). 8. Events are written to an event table with sequence numbers; front‑end reconnects replay missing events. 9. Scheduled tasks scan every 15s, clear stale placeholders, and enqueue new runs without duplicates.

Доказательства

make a Run a first‑class row in the database, not a goroutine in memory.

Источник

Workers pull Jobs off the queue with a default concurrency of 8.

Источник

Lease TTL is 60 seconds; heartbeat renews it roughly every 20 seconds.

Источник

Reconciler runs every 15 seconds, re‑enqueues orphan Runs.

Источник

  • Дата записи: 2026-10-26T04:26:28.383Z