Concepts
Runs and the event log
A run is an append-only log of events. Everything else, including resume, replay and fork, is built by reading that log.
Before a step has an effect, keel appends an event saying it's about to happen. After, it appends what happened. The run's state is never stored separately; it's the fold of its events.
| Event | Written when |
|---|---|
| run.created | The run is queued, with its input and the agent version |
| model.requested / model.completed | Around each model call, with the exact content blocks returned |
| tool.started / tool.completed / tool.failed | Around each tool call, keyed by its call id |
| approval.requested / approved / denied | A gated tool is waiting for a person |
| handoff.started / handoff.completed | Work was handed to another agent |
| run.completed / run.failed / run.cancelled | The run is finished |
Statuses
- queued: waiting for a worker
- running: a worker holds its lease and is driving it
- waiting_for_approval: a gated tool call needs a person
- needs_review: a tool call is in doubt and keel won't guess
- waiting: a child agent is working; no worker is held
- completed, failed, cancelled, limit_exceeded: finished
Events are unique on (run_id, seq). Two workers can never both write step 7: the second append fails and that worker stops.