Hmbown/CodeWhale · error
failed to durably register write-capable sub-agent before…
Error message
failed to durably register write-capable sub-agent before launch: {error} What it means
Before a write-capable sub-agent is launched, it must be durably registered in the coordination state (so a crash after launch leaves a record). If that durable pre-launch registration fails, the agent's work lifecycle is marked Failed and the launch is aborted with this error. This prevents launching workers that the durable ledger would not know about.
Solutions
- Inspect the embedded {error} and fix the state-persistence failure (permissions, disk space, path validity), then retry the spawn.
- Verify the coordination state file and its parent directory exist and are writable.
- If the state is corrupted, restore or recreate the coordination state before launching write-capable agents.
Example fix
// before $ test -w $SESSION_DIR/subagents.json || echo "not writable" not writable // after $ chmod u+w $SESSION_DIR/subagents.json && retry spawn
Defensive patterns
Strategy: validation
Validate before calling
// pre-flight before write-capable spawn
if (!canWrite(stateDir)) throw new Error(`state dir ${stateDir} not writable: fix before launching`); Try / catch
if (err.message.startsWith("failed to durably register")) {
// embedded cause is in the message tail; fix persistence, then retry
repair_state_storage(); retry_spawn();
} Prevention
- Verify the coordination state file and parent directory exist and are writable before spawning write-capable agents.
- Keep the state path on a local, non-read-only filesystem.
- Validate coordination state integrity at session start to avoid mid-spawn registration failures.
When it happens
Trigger: Spawning a write-capable sub-agent (or one with a continuation_from source) when the pre-launch durable registration step (persisting worker_records/coordination) returns an error.
Common situations: State file unwritable (permissions, disk full, missing parent directory); corrupted coordination state causing the persist/registration call to fail; filesystem errors on the session state path.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- ; additionally failed to persist contention receipt
- failed to record sub-agent verification approval
- failed to register sub-agent work
- sub-agent transcript history shrank from
- agent action=claim widens an enforced write scope, and the…
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/02f5c8fe278dae7a.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/tools/subagent/mod.rs:7286
}
self.agents.insert(agent_id.clone(), agent);
let persist_result = self.persist_state_synchronously();
agent = self
.agents
.remove(&agent_id)
.expect("pre-launch agent remains registered under manager lock");
if let Err(error) = persist_result {
if let Some(source) = continuation_from.as_ref() {
self.resume_targets.remove(source);
}
let (worker_records, coordination) = durable_launch_snapshot
.expect("durable launch captured a registration snapshot");
self.worker_records = worker_records;
self.coordination = coordination;
if let Some(lifecycle) = agent.work_lifecycle.as_ref() {
let _ = lifecycle.reconcile_state(OwnerState::Failed, 1, None);
}
return Err(anyhow!(
"failed to durably register write-capable sub-agent before launch: {error}"
));
}
}
if let Some(mb) = runtime.mailbox.as_ref() {
let _ = mb.send(MailboxMessage::started(&agent_id, agent_type.clone()));
}
if let Some(event_tx) = runtime.event_tx.clone() {
let _ = event_tx.try_send(Event::AgentSpawned {
owner_session_id: runtime.context.state_namespace.clone(),
id: agent_id.clone(),
prompt: prompt.clone(),
worker_status: self
.worker_record_by_ref(&agent_id)
.map(|(_, record)| record.status),
parent_run_id: runtime.parent_agent_id.clone(),View on GitHub (pinned to 73e0f67d83)