Run system
How the daemon prepares, starts, continues, and stops strategy runs.
Run system
The run system owns each strategy run from preparation through cleanup. The daemon uses it to keep run identity, persisted conversation history, client subscriptions, and cancellation consistent across the full lifecycle.
Most applications interact with this lifecycle through the WebSocket protocol. Use the exported createRunSystem API only when embedding the run lifecycle in a custom daemon host.
Run lifecycle
A run uses one stable run ID across preparation, execution, persistence, and continuation:
- Prepare loads the strategy, creates or restores the run, and returns its metadata and conversation.
- Start executes a newly prepared run with an optional initial prompt.
- Continue restores a completed run and executes another prompt against its retained conversation.
- Stop aborts active work for the run.
- Shutdown aborts remaining work and waits for cleanup to finish.
Preparation is separate from execution. Wait for run_prepared before sending start_run or continue_run; this guarantees that the strategy and any restored conversation are ready before execution begins.
RunSystem
The interface for preparing and controlling daemon runs.
Prop
Type
CreateRunSystemOptions
Dependencies and defaults used by createRunSystem.
Prop
Type
PrepareRunOptions
Options for preparing either a new run or a continuation.
Prop
Type
For a new run, provide strategyPath; the run system generates a run ID unless you supply one. For a continuation, provide the completed run's runId. The saved run supplies the strategy path, working directory, model override, and project manifest unless you explicitly override them.
EventSink
The destination for run events sent to individual clients or all subscribers of a run.
Prop
Type
Persistence and continuation
Run events are stored under the configured runs directory. Preparing a completed run reconstructs its conversation from those events and restores agent context before the next prompt starts. A run that is still pending or running cannot be prepared as a continuation.
See Run persistence for the stored event format and Protocol for the client messages that control this lifecycle.