You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(runtime): add idle_cached lifecycle + Claude session resume
Adds the Claude-only idle_cached lifecycle with session-id capture/resume support, stale-session cold-start fallback, supervisor wake-path support, docs, and regression tests for Claude Code stale-resume wording.
Copy file name to clipboardExpand all lines: README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -123,7 +123,7 @@ Agent definitions live in a single JSON file:
123
123
124
124
Each agent entry has:
125
125
-`name` — unique identifier used on the message bus.
126
-
-`lifecycle` — `24/7` (continuous respawn loop) or `on-demand` (idle until triggered).
126
+
-`lifecycle` — `24/7` (continuous respawn loop), `on-demand` (idle until triggered), or `idle_cached` (idle until triggered, but the prior Claude `session_id` is preserved across triggers via `claude --resume` so context survives idle periods). **`idle_cached` is Claude-only**: pairing it with `runtime: codex` (or `WANMAN_RUNTIME=codex`) is rejected at startup since Codex has no equivalent resume mechanism in this runtime.
127
127
-`model` — usually an abstract tier (`high` or `standard`); the runtime adapter maps it to Claude or Codex defaults, with environment overrides available.
128
128
-`systemPrompt` — baked-in persona/mission; agents also auto-discover shared skill files at `~/.claude/skills/`.
129
129
- Optional `cron`, `events`, and `tools` fields — see the architecture doc for the full schema.
Copy file name to clipboardExpand all lines: docs/architecture.md
+26-1Lines changed: 26 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -64,8 +64,33 @@ start()
64
64
65
65
- Initial state is `idle`; no CPU is spent until something pokes it.
66
66
- A steer-priority message or a cron tick triggers a single execution, after which the agent falls back to `idle`.
67
+
- Each spawn is stateless: the next trigger gets a fresh CLI session.
67
68
68
-
### 2.3 Agent states
69
+
### 2.3 `idle_cached` — idle, but with resumed context (Claude-only)
70
+
71
+
```
72
+
start()
73
+
+-> state = 'idle' (no CLI subprocess running)
74
+
+-> lastSessionId = null
75
+
76
+
trigger() / handleSteer()
77
+
+- relay.recv()
78
+
+- spawnClaudeCode({ resumeSessionId: lastSessionId }) # claude --resume <id>
79
+
+- onSessionId(id => lastSessionId = id) # captured from system/init
80
+
+- wait()
81
+
+- if resumeMissed(): # stale session
82
+
lastSessionId = null
83
+
respawn without --resume # cold-start fallback
84
+
+- state = 'idle' again (but lastSessionId is preserved)
85
+
```
86
+
87
+
- Same idle CPU profile as `on-demand`, but conversation context survives idle periods because the next spawn passes the captured Claude `session_id` as `--resume <id>`.
88
+
- The first trigger always cold-starts (no captured session yet).
89
+
- If the local Claude CLI has dropped the session id (rotated, manually deleted, etc.), the runtime detects the failure via stderr + exit code, clears the cached id, and re-spawns once without `--resume`. No agent gets stranded.
90
+
- Useful for stateful long-running roles where keeping a process alive forever would be wasteful but losing context every trigger is also wrong (e.g. a "support" agent that should remember the customer between messages).
91
+
-**Claude-only.** The resume mechanism depends on `claude --resume` and Claude Code's `system/init` session id; Codex has no equivalent in this runtime today. Pairing `idle_cached` with `runtime: codex` (or letting `WANMAN_RUNTIME=codex` flip the effective runtime) is rejected at supervisor startup so the misconfig surfaces loudly instead of silently degrading to `on-demand` semantics.
0 commit comments