2026-08-03 11:48:36 -04:00
---
kind: task
slug: worker-checkpoint-resume
title: Worker checkpoint and crash recovery
plan_slug: automation-foundation
epic_slug: apps-worker-v1
2026-08-25 17:20:53 -04:00
status: done
2026-08-03 11:48:36 -04:00
priority: P1
tenant_id: global
owner: unassigned
cursor_todo_id: null
2026-08-25 17:20:53 -04:00
updated_at: "2026-08-12"
2026-08-03 11:48:36 -04:00
---
# Task summary
Persist worker session progress at configurable checkpoints so a crashed or stalled job resumes from the last checkpoint instead of restarting the brief from scratch.
## Description
**Benchmark:** [Autensa mission-control ](https://github.com/crshdn/mission-control ) checkpoint & crash recovery — study their checkpoint restore API and per-task history UX; implement Echodo-native equivalents on Postgres.
### Schema
Add `worker_checkpoints` (or JSONB on `agent_runs` ) workspace-scoped:
- `agent_run_id` , `convoy_id` , `brief_id`
- `checkpoint_seq` , `tool_history` (bounded), `files_touched` , `branch` , `worktree_path`
- `occurred_at`
### Worker behavior
- Save checkpoint after each tool round (configurable via `WORKER_CHECKPOINT_EVERY_N_STEPS` , default 1).
- On job start: if open run has latest checkpoint, resume tool loop from saved state.
- Orchestrator stall detector can trigger re-dispatch with `resume_from_checkpoint: true` .
### Operator surface (minimal v1)
- Mission control detail panel: checkpoint count + last checkpoint time (full history deferred).
## Dependencies
- [Task-worker-minimal-tool-loop ](./Task-worker-minimal-tool-loop.md ) (baseline loop must exist).
## Subtasks
2026-08-25 17:20:53 -04:00
- [x] Zod schemas in `packages/shared/worker`
- [x] Drizzle migration + workspace-scoped queries
- [x] Checkpoint write in `minimal-session` / `handle-job`
- [x] Resume path on re-dispatch
- [x] Env docs in `docs/worker.md`
2026-08-03 11:48:36 -04:00
## Estimation
M
## Acceptance criteria
2026-08-25 17:20:53 -04:00
- [x] Kill worker mid-brief; re-dispatch resumes from last tool step without re-cloning
- [x] Checkpoints filtered by `workspace_id`
- [x] Checkpoint payload does not store API keys or full file contents (paths + hashes only)
2026-08-03 11:48:36 -04:00
## Links
- Epic: `./Epic-apps-worker-v1.md`
- Blocks: reliable unattended dogfood for Epic 8