← All resources

Building Agents

Designing Long-Running Agents

Patterns for durable tasks that span minutes, hours, approvals, retries, and changing external state.

Persist outside the process

Long-running work needs a durable task record containing state, inputs, outputs, limits, and ownership. An in-memory loop cannot survive a restart or deployment.

Resume from checkpoints

Record completed steps and make actions idempotent so the task can continue without repeating side effects. Refresh time-sensitive observations when resuming after a delay.

Keep users informed

Expose meaningful progress, pending approvals, and a way to cancel. A background agent should never become invisible merely because it no longer fits in one request.