Quick Start
Add--hot to any run or resume command:
How It Works
Smithers is built on React. Your workflow’sbuild(ctx) function is a React component tree that the engine re-renders every loop iteration using a custom React reconciler. All run state lives in SQLite, not in the React fiber tree.
Hot reload leverages this architecture:
- Watch — The engine watches your workflow’s directory tree (excluding
node_modules/,.git/,.jj/,.smithers/). - Overlay — On file change, Smithers creates a “generation overlay” — a copy of your source tree with fresh file URLs so every module (including transitive dependencies) is re-evaluated.
- Import — The new workflow module is imported from the overlay.
createSmithers()returns the cached DB connection and schema maps (no duplicate connections). - Swap — Only
workflow.buildis replaced. The database, schema registry, and all persisted state remain untouched. - Wake — The engine loop is woken immediately (even if tasks are still running) so it re-renders with the new code.
What You Can Change Live
These changes take effect on the next render cycle:| Change | Effect |
|---|---|
Prompt strings / .md files | New tasks get the updated prompt |
| Focus lists, config values | Scheduler sees new priorities |
| Agent configuration (model, timeout, system prompt) | New agent instances for new tasks |
| JSX tree structure (add/remove/reorder tasks) | New plan tree on next render |
| Concurrency / retry settings | Applied to newly scheduled tasks |
What Requires a Restart
These changes are blocked to prevent data corruption:| Change | Why |
|---|---|
| Output Zod schemas (shape changes) | Schema identity is used for output table resolution |
createSmithers() dbPath | Would create a second database connection |
| Adding/removing output schema keys | Changes the schema registry |
In-Flight Task Behavior
When a hot reload changes the task graph, tasks that are already running are not cancelled. They continue with the code they were launched with and their output is persisted normally. This means:- A task started with
PLANNING_PROMPTv1 will finish with v1, even if you’ve since saved v2. - If a reload removes a task from the tree, its in-flight attempt still completes. The output may go unused by downstream tasks.
- If a reload changes a task’s
id, the old in-flight attempt is treated as a different node. Both may run.
CLI Output
When hot reload detects and applies changes, you’ll see:Events
Hot reload emits events through the standard event system:| Event | When |
|---|---|
WorkflowReloadDetected | File changes detected (before reload attempt) |
WorkflowReloaded | Reload succeeded; includes generation number and changedFiles |
WorkflowReloadFailed | Reload failed (syntax error, import error); includes error |
WorkflowReloadUnsafe | Reload blocked (schema change); includes reason |
onProgress.
Options
| CLI Flag | RunOptions field | Description | Default |
|---|---|---|---|
--hot | hot: true | Enable hot reload | Disabled |
RunOptions.hot object):
| Field | Description | Default |
|---|---|---|
rootDir | Directory to watch | Workflow file’s directory |
outDir | Overlay output directory | .smithers/hmr |
maxGenerations | Number of overlay generations to keep | 3 |
cancelUnmounted | Cancel in-flight tasks that become unmounted after reload | false |
debounceMs | Debounce interval for file change events | 100 |
Tips
Keep prompts in separate files
If your prompts live in.md or .ts files imported by your workflow, editing them triggers a hot reload automatically. This is the most common use case:
Avoid module-scope side effects
Code that runs at import time (outside ofbuild()) is re-executed on every reload. Keep side effects inside build() or use createSmithers() which is automatically cached in hot mode.
Use with resumability
Hot reload and resumability work together. You can:- Start a run with
--hot - Edit files while it runs
- Kill the process (Ctrl+C)
- Resume with
smithers resume workflow.tsx --run-id <id> --hot
Related
- Execution Model — How the render-schedule-execute loop works.
- Resumability — How crash recovery preserves state.
- Events — Subscribing to lifecycle events.
- CLI Reference — Full CLI flag reference.