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