{"record":{"id":"931c41ff919b6e31","repo":"Hmbown/CodeWhale","slug":"write-capable-sub-agent-launch-requires-a-durable","errorCode":null,"errorMessage":"write-capable sub-agent launch requires a durable coordination state path","messagePattern":"write-capable sub-agent launch requires a durable coordination state path","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/tools/subagent/mod.rs","lineNumber":7102,"sourceCode":"                || !options\n                    .write_claim\n                    .as_ref()\n                    .is_some_and(|claim| claim.contains_path(&claimed_path))\n            {\n                return Err(anyhow!(\n                    \"deliverable {path:?} is outside the worker write scope; declare an exact_files entry or a containing write_roots path\"\n                ));\n            }\n        }\n        if write_capable {\n            // Isolated-worktree children mutate their own checkout, so they\n            // do not contend for the shared-workspace process lock (#5036).\n            if !options.isolated_worktree {\n                self.ensure_coordination_process_lock()\n                    .map_err(anyhow::Error::msg)?;\n            }\n            if self.coordination_process_lock_required && self.state_path.is_none() {\n                return Err(anyhow!(\n                    \"write-capable sub-agent launch requires a durable coordination state path\"\n                ));\n            }\n        }\n        let durable_registration = write_capable || continuation_from.is_some();\n        let durable_launch_snapshot =\n            durable_registration.then(|| (self.worker_records.clone(), self.coordination.clone()));\n        let persisted_claim = if write_capable {\n            options\n                .write_claim\n                .clone()\n                .map(|mut claim| {\n                    claim.owner = agent_id.clone();\n                    let claim = if options.claim_pre_namespaced {\n                        claim\n                    } else {\n                        self.namespace_write_claim(\n                            &agent.workspace,","sourceCodeStart":7084,"sourceCodeEnd":7120,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/tools/subagent/mod.rs#L7084-L7120","documentation":"Write-capable sub-agents coordinate through a durable coordination state file guarded by a process lock. If the manager was configured as requiring that lock (`coordination_process_lock_required`) but has no durable `state_path`, launching a write-capable child is refused, because concurrent writers could corrupt shared workspace state (#5036).","triggerScenarios":"Spawning a write-capable sub-agent (non-isolated worktree) when SubAgentManager.coordination_process_lock_required is true and self.state_path is None — i.e. the manager was constructed without a durable state file path.","commonSituations":"TUI/session started in a mode that skips state persistence (ephemeral or in-memory manager) while the model still requests a write-capable worker; configuration regression after refactoring manager construction; running in an environment where the state directory could not be determined.","solutions":["Initialize the SubAgentManager with a durable state_path (point it at the session's coordination/state file) before launching write-capable agents.","If the work truly needs no shared-workspace coordination, set options.isolated_worktree = true so the child mutates its own checkout and bypasses the process lock.","Check why the manager was built without a state path (config/env) and fix the construction site so coordination state persists."],"exampleFix":"// before\nlet manager = SubAgentManager::builder().without_state_path().build();\n// after\nlet manager = SubAgentManager::builder()\n    .state_path(session_dir.join(\"subagents.json\"))\n    .build();","handlingStrategy":"validation","validationCode":"if (writeCapableSpawn && !options.isolatedWorktree && !manager.hasDurableStatePath()) {\n  throw new Error(\"configure state_path before launching write-capable sub-agents\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always construct SubAgentManager with a durable state_path in sessions that may spawn write-capable workers.","Use isolated_worktree for children that do not need shared-workspace coordination.","Add a startup check that fails loud when the manager lacks a state path but write-capable spawns are expected."],"tags":["subagent","write-capable","missing-config","coordination"],"backgroundTag":"missing-required-config","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}