{"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":5619,"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":5601,"sourceCodeEnd":5637,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/tools/subagent/mod.rs#L5601-L5637","documentation":"continue_child_from_user only handles three statuses: Running (delivered as live mail), and Interrupted(_)/Completed (checkpoint resume). Any other status hits the catch-all arm and is refused because the child cannot resume: a Failed, Cancelled, or BudgetExhausted agent has no continuation path in this API. The message includes the concrete status name via subagent_status_name.","triggerScenarios":"Calling continue on an agent whose status is Failed(_), Cancelled, or BudgetExhausted; a status race where the agent fails or gets cancelled between the caller's check and the continue call; continuing an agent cancelled to free admission capacity.","commonSituations":"User retries a 'continue' action on an agent that crashed earlier; orchestration code treats continue as a universal retry; agents cancelled by admission pressure or heartbeat timeouts receiving continue commands.","solutions":["Spawn a replacement agent whose prompt embeds the failed agent's last known output; there is no resume path for Failed/Cancelled/BudgetExhausted","Check status with get_result_by_ref first and only issue continue for Running, Interrupted, or Completed agents","For BudgetExhausted agents, respawn with a fresh token budget configured on the spawn"],"exampleFix":"// before\nlet outcome = manager.continue_child_from_user(handle, runtime, &agent_ref, &text)?;\n\n// after\nlet snap = manager.get_result_by_ref(&agent_ref)?;\nif matches!(snap.status,\n        SubAgentStatus::Running\n        | SubAgentStatus::Interrupted(_)\n        | SubAgentStatus::Completed) {\n    manager.continue_child_from_user(handle, runtime, &agent_ref, &text)?;\n} else {\n    spawn_replacement(manager, &agent_ref, &text).await?;\n}","handlingStrategy":"type-guard","validationCode":"let snap = manager.get_result_by_ref(&agent_ref)?;\nanyhow::ensure!(continuable_status(&snap.status),\n    \"agent {agent_ref} status {} cannot continue\", snap.status);","typeGuard":"fn continuable_status(status: &SubAgentStatus) -> bool {\n    matches!(status,\n        SubAgentStatus::Running\n        | SubAgentStatus::Interrupted(_)\n        | SubAgentStatus::Completed)\n}","tryCatchPattern":"On 'Cannot continue agent ... cannot resume', read the status word and route: Failed/Cancelled -> respawn with a summary; BudgetExhausted -> respawn with a fresh budget. Suppress retry loops.","preventionTips":["Model agent state explicitly in orchestration code (Runnable / Resumable / Dead) instead of calling continue unconditionally","Consume completion/failure events to retire agents from the continuable set","For user-facing commands, map the refusal to a clear 'agent ended; start a new one' message"],"tags":["subagent","rust","lifecycle","invalid-state-transition","continue"],"backgroundTag":"invalid-state-transition","analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}