Deep dive
Subagent Failure Deep Dive
Executive summary
The failures were not one single bug. They came from a mixed orchestration stack: earlier successful work used OpenClaw-native subagent completion, later attempts used the ChatGPT/Codex spawn_agent/wait_agent tools available in this runtime, while OpenClaw CLI session spawning was blocked by sandbox filesystem permissions. I then compounded that by treating returned agent ids as reliable active work without durable liveness evidence.
Bottom line: subagents are not safe to rely on here until we standardize on one mechanism, make it observable, and add a durable supervision layer. For now, bounded main-session work blocks with clean worktrees are more reliable.
Observed symptoms
- PM and Dev spawned agent ids later returned
not_found. openclaw agentvia CLI failed with sandbox EPERM while trying to write identity/session files.- OpenClaw status showed no Tasks and no active PM/Dev sessions, despite my earlier “active” wording.
- Manual main-session recovery succeeded: Hub Agent Overview was implemented, deployed, verified, and issue #21 closed.
Impact
- Status reliability dropped: I reported work as active without enough proof.
- PM handoff work stalled until Jeremy checked.
- The architecture needs explicit liveness checks and recovery, not trust in a returned id.
Evidence timeline
- Earlier success: keynote-deck subagent completed and announced through OpenClaw with a session key and session id.
- CLI failure: a PM attempt via
openclaw agentfailed with sandbox EPERM on~/.openclaw/identity/.fs-safe...and~/.openclaw/agents/main/sessions/.fs-safe-replace.... - Spawn/wait mismatch: later PM/Dev
spawn_agentids returnednot_foundwhen checked. - Incorrect status: I briefly reported Dev as active before re-checking liveness.
- Mitigation proven: main-session supervised work block used a clean Hub worktree, pushed commit
96e4c55, verified Pages, commented evidence, and closed #21.
Likely causes
1. Mixed subagent mechanisms
OpenClaw docs describe sessions_spawn, sessions_yield, and subagents as the native mechanism. The current runtime exposed separate spawn_agent/wait_agent tools, not the OpenClaw sessions_spawn stack. That means OpenClaw status, cron/task views, and session lists did not reliably reflect these tool-spawned agents.
2. Missing or unavailable OpenClaw session tools in this context
The runtime context indicated local embedded mode, with gateway-dependent tools unavailable. OpenClaw docs say sessions_yield is the correct waiting primitive for spawned subagents, and that sessions_spawn availability depends on tool policy. In this session, the proper OpenClaw session tools were not available as first-class tools.
3. Sandbox EPERM blocks CLI-based Gateway agent runs
Attempting to use openclaw agent from the sandbox hit filesystem writes outside the writable roots:
EPERM: operation not permitted, open '/Users/obot/.openclaw/identity/.fs-safe-...tmp' EPERM: operation not permitted, open '/Users/obot/.openclaw/agents/main/sessions/.fs-safe-replace...tmp'
So CLI fallback is not a reliable way to start isolated PM/Dev sessions from this sandbox.
4. No durable work-session ledger
There was no durable record of spawned work-session id, expected checkpoint, liveness method, and recovery plan. Without that, “still going?” required ad hoc reconstruction.
5. Auto-archive/stale-run semantics can hide old children
OpenClaw docs note that subagent sessions can auto-archive and stale unended runs stop counting as active. That is good hygiene, but it means status must be checked through the right owner/session and cannot be inferred from memory.
Recommended mitigations
- Standardize on one runtime: prefer OpenClaw-native
sessions_spawn+sessions_yieldwhen available. Do not mix with separatespawn_agentunless we explicitly mark it experimental. - Expose needed tools: configure the main Telegram session with OpenClaw
sessions_spawn,sessions_yield, andsubagentsif policy allows. - Do not use CLI agent fallback from sandbox: it currently cannot write required identity/session files. Use first-class tools or unsandboxed scheduled jobs.
- Create a work-session ledger: record session id, task, issue/PR, start time, checkpoint, liveness method, and recovery plan in a local JSON/Markdown file and linked issue comments.
- Add liveness gate: before saying a cycle is active, verify reachable session status or concrete evidence: recent diff, commit, check run, issue comment, report, or process.
- Use TaskFlow/cron for long work: for work expected to survive turns, use durable TaskFlow/cron-style jobs with explicit announce delivery rather than ephemeral subagents.
- Keep main-session recovery path: for bounded Hub/PM fixes, main can use clean worktrees and direct evidence when subagents fail.
Concrete changes already made
- Created
skills/work-session-supervision/SKILL.md. - Added supervision rules to
skills/portfolio-pm-audit/SKILL.md. - Updated
AGENTS.mdandHEARTBEAT.mdto require liveness evidence. - Filed Hub issue #25: durable work-session supervision.
- Updated Hub Agent Overview page to explain active vs proposed agent roles.
Proposed implementation plan
- Issue #25: implement a work-session ledger and status helper.
- Config audit: inspect tool policy for main Telegram sessions and decide whether to expose OpenClaw-native session tools.
- TaskFlow option: if session tools cannot be safely exposed, implement PM/Dev cycles as durable TaskFlow/cron jobs with explicit completion announcements.
- PM cycle update: every PM handoff must include monitoring plan and recovery action.
- Status command/report: add a small report that lists planned, active, stalled, completed, pushed/deployed, and reviewed work.
Open questions
- Should we expose OpenClaw-native
sessions_spawn/sessions_yield/subagentsto this Telegram session, or prefer durable TaskFlow/cron jobs for PM/Dev? - Should PM/Development/Testing become actual OpenClaw agent configs, or remain prompt-scoped work modes until the supervision layer is built?