{"record":{"id":"4208e5f4943ab919","repo":"Hmbown/CodeWhale","slug":"cannot-continue-agent-agent-id-status-is-and","errorCode":null,"errorMessage":"Cannot continue agent {agent_id}: status is {} and the child cannot resume","messagePattern":"Cannot continue agent (.+?): status is (.+?) and the child cannot resume","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/tools/subagent/mod.rs","lineNumber":6137,"sourceCode":"                    ));\n                };\n                let resumed = self.resume_from_checkpoint_with_policy(\n                    manager_handle,\n                    runtime,\n                    &agent_id,\n                    text,\n                    ResumePolicy::InterruptedOrCompleted,\n                )?;\n                let target = resumed.agent_id.clone();\n                Ok(UserFollowUpOutcome {\n                    agent_id,\n                    delivered: true,\n                    resumed: true,\n                    note: format!(\"continued from checkpoint as {target}\"),\n                    target_agent_id: target,\n                })\n            }\n            other => Err(anyhow!(\n                \"Cannot continue agent {agent_id}: status is {} and the child cannot resume\",\n                subagent_status_name(&other)\n            )),\n        }\n    }\n\n    pub(crate) fn continue_child_from_user_for_session(\n        &mut self,\n        active_session_id: &str,\n        manager_handle: SharedSubAgentManager,\n        runtime: Option<SubAgentRuntime>,\n        agent_ref: &str,\n        text: &str,\n    ) -> Result<UserFollowUpOutcome> {\n        let agent_id = self.resolve_agent_ref_for_session(active_session_id, agent_ref)?;\n        self.continue_child_from_user(manager_handle, runtime, &agent_id, text)\n    }\n","sourceCodeStart":6119,"sourceCodeEnd":6155,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/tools/subagent/mod.rs#L6119-L6155","documentation":"Thrown by the continue-agent flow's catch-all arm when the child's status is one that can never be resumed: Failed, Cancelled, BudgetExhausted, or any other non-resumable state. Only Running (live delivery), Interrupted, and Completed statuses continue; everything else fails closed.","triggerScenarios":"Calling `continue_agent` on a child that failed, was cancelled, exhausted its budget, or is otherwise in a terminal non-resumable status (the `other =>` match arm).","commonSituations":"User hits 'continue' in the UI on a failed child; a retry script blindly continues agents regardless of status; a budget-exhausted child is continued without raising the budget; status changed to Failed between the check and the continue call.","solutions":["Check the child's status first and only call continue for Interrupted/Completed/Running children.","For Failed or Cancelled children, spawn a new child with the original task plus any partial output.","For BudgetExhausted, increase the budget and spawn a fresh child (its budget is spent, not resumable).","Inspect the status detail via `subagent_status_name` to understand which terminal state blocked the resume."],"exampleFix":"// before\nlet outcome = registry.continue_agent(&handle, &agent_ref, text, runtime)?;\n// after\nmatch registry.status_of(&agent_ref) {\n    SubAgentStatus::Running | SubAgentStatus::Interrupted(_) | SubAgentStatus::Completed => {\n        registry.continue_agent(&handle, &agent_ref, text, runtime)?\n    }\n    other => {\n        let new_ref = registry.spawn_child_with_context(&original_task)?;\n        registry.user_follow_up(&new_ref, text)?\n    }\n}","handlingStrategy":"validation","validationCode":"match registry.status_of(agent_ref) {\n    SubAgentStatus::Running | SubAgentStatus::Interrupted(_) | SubAgentStatus::Completed => {},\n    other => anyhow::bail!(\"agent is {:?}; cannot be continued, spawn a new child\", other),\n}","typeGuard":"fn is_continueable(status: &SubAgentStatus) -> bool {\n    matches!(status, SubAgentStatus::Running | SubAgentStatus::Interrupted(_) | SubAgentStatus::Completed)\n}","tryCatchPattern":"match registry.continue_agent(&handle, agent_ref, text, runtime) {\n    Err(e) if e.to_string().contains(\"cannot resume\") => {\n        let new_ref = registry.spawn_child_with_context(&original_task)?;\n        registry.user_follow_up(&new_ref, text)?\n    }\n    r => r?,\n}","preventionTips":["Gate 'continue' UI actions on the child's live status, not on stale snapshots.","Failed/Cancelled/BudgetExhausted children are never resumable — always spawn fresh.","BudgetExhausted requires a bigger budget on a new child, not a resume.","Re-read status right before continuing to narrow check/act races."],"tags":["subagent","agent-lifecycle","invalid-state-transition","rust"],"backgroundTag":"invalid-state-transition","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"}