Hmbown/CodeWhale · error

Cannot continue agent {agent_id}: status is {} and the child

Error message

Cannot continue agent {agent_id}: status is {} and the child cannot resume

What it means

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.

Source

Thrown at crates/tui/src/tools/subagent/mod.rs:5619

                    ));
                };
                let resumed = self.resume_from_checkpoint_with_policy(
                    manager_handle,
                    runtime,
                    &agent_id,
                    text,
                    ResumePolicy::InterruptedOrCompleted,
                )?;
                let target = resumed.agent_id.clone();
                Ok(UserFollowUpOutcome {
                    agent_id,
                    delivered: true,
                    resumed: true,
                    note: format!("continued from checkpoint as {target}"),
                    target_agent_id: target,
                })
            }
            other => Err(anyhow!(
                "Cannot continue agent {agent_id}: status is {} and the child cannot resume",
                subagent_status_name(&other)
            )),
        }
    }

    pub(crate) fn continue_child_from_user_for_session(
        &mut self,
        active_session_id: &str,
        manager_handle: SharedSubAgentManager,
        runtime: Option<SubAgentRuntime>,
        agent_ref: &str,
        text: &str,
    ) -> Result<UserFollowUpOutcome> {
        let agent_id = self.resolve_agent_ref_for_session(active_session_id, agent_ref)?;
        self.continue_child_from_user(manager_handle, runtime, &agent_id, text)
    }

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Spawn a replacement agent whose prompt embeds the failed agent's last known output; there is no resume path for Failed/Cancelled/BudgetExhausted
  2. Check status with get_result_by_ref first and only issue continue for Running, Interrupted, or Completed agents
  3. For BudgetExhausted agents, respawn with a fresh token budget configured on the spawn

Example fix

// before
let outcome = manager.continue_child_from_user(handle, runtime, &agent_ref, &text)?;

// after
let snap = manager.get_result_by_ref(&agent_ref)?;
if matches!(snap.status,
        SubAgentStatus::Running
        | SubAgentStatus::Interrupted(_)
        | SubAgentStatus::Completed) {
    manager.continue_child_from_user(handle, runtime, &agent_ref, &text)?;
} else {
    spawn_replacement(manager, &agent_ref, &text).await?;
}
Defensive patterns

Strategy: type-guard

Validate before calling

let snap = manager.get_result_by_ref(&agent_ref)?;
anyhow::ensure!(continuable_status(&snap.status),
    "agent {agent_ref} status {} cannot continue", snap.status);

Type guard

fn continuable_status(status: &SubAgentStatus) -> bool {
    matches!(status,
        SubAgentStatus::Running
        | SubAgentStatus::Interrupted(_)
        | SubAgentStatus::Completed)
}

Try / catch

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.

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20). Data as JSON: /api/errors/4208e5f4943ab919. Report an issue: GitHub.