diff --git a/docs/agent.md b/docs/agent.md index 5af4d57..bea6a0c 100644 --- a/docs/agent.md +++ b/docs/agent.md @@ -46,12 +46,13 @@ 1. Polling detects process exit, `FileTailer.stop()` flushes remaining output 2. `OutputHandler.handleCompletion()` triggered -3. **Primary path**: Reads `.cw/output/signal.json` from agent worktree -4. Signal contains `{ status: "done"|"questions"|"error", result?, questions?, error? }` -5. Agent DB status updated accordingly (idle, waiting_for_input, crashed) -6. For `done`: proposals created from structured output; `agent:stopped` emitted -7. For `questions`: parsed and stored as `pendingQuestions`; `agent:waiting` emitted -8. **Fallback**: If signal.json missing, lifecycle controller retries with instruction injection +3. **Path resolution**: Uses `ActiveAgent.agentCwd` (recorded at spawn) to locate signal.json. Standalone agents run in a `workspace/` subdirectory under `agent-workdirs//`, so the base `getAgentWorkdir()` path won't contain `.cw/output/signal.json`. Reconciliation and crash detection paths also probe for the `workspace/` subdirectory when `.cw/output` is missing at the base level. +4. **Primary path**: Reads `.cw/output/signal.json` from agent worktree +5. Signal contains `{ status: "done"|"questions"|"error", result?, questions?, error? }` +6. Agent DB status updated accordingly (idle, waiting_for_input, crashed) +7. For `done`: proposals created from structured output; `agent:stopped` emitted +8. For `questions`: parsed and stored as `pendingQuestions`; `agent:waiting` emitted +9. **Fallback**: If signal.json missing, lifecycle controller retries with instruction injection ### Account Failover