{"record":{"id":"e9b9143dbb4ce593","repo":"Hmbown/CodeWhale","slug":"failed-to-register-sub-agent-work-err","errorCode":null,"errorMessage":"failed to register sub-agent work: {err}","messagePattern":"failed to register sub-agent work: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/tools/subagent/mod.rs","lineNumber":2883,"sourceCode":"        let external = format!(\"worker:{agent_id}\");\n        let lifecycle = Self {\n            work,\n            session_id,\n            external,\n        };\n        lifecycle\n            .work\n            .register_operation(\n                &lifecycle.session_id,\n                OperationIntent::new(\n                    lifecycle.external.clone(),\n                    title,\n                    true,\n                    \"agent\",\n                    format!(\"agent:{agent_id}:spawn\"),\n                ),\n            )\n            .map_err(|err| anyhow!(\"failed to register sub-agent work: {err}\"))?;\n\n        // A root Operate verification lease is provenance, not delegated\n        // authority. Nested workers cannot inherit this bit.\n        if runtime.accept_verification && runtime.spawn_depth == 1 {\n            let reference = format!(\"operate-verification:{agent_id}\");\n            if let Err(err) = lifecycle.work.record_operation_approval(\n                &lifecycle.session_id,\n                &lifecycle.external,\n                &reference,\n                \"agent\",\n                &format!(\"agent:{agent_id}:approval\"),\n            ) {\n                let _ = lifecycle.reconcile_state(OwnerState::Failed, 1, None);\n                return Err(anyhow!(\n                    \"failed to record sub-agent verification approval: {err}\"\n                ));\n            }\n        }","sourceCodeStart":2865,"sourceCodeEnd":2901,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/tools/subagent/mod.rs#L2865-L2901","documentation":"Raised in the sub-agent lifecycle constructor: work.register_operation for the agent spawn operation failed, so no work-tracking entry exists for this sub-agent's run. The {err} explains the registry-side cause (closed channel, session shutdown, or duplicate operation id).","triggerScenarios":"Thrown at crates/tui/src/tools/subagent/mod.rs:2883 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the inner {err} for the work-registry failure cause","Verify the parent session/work registry is still alive and accepting operations","Retry spawning the agent after the registry issue is resolved"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}