Hmbown/CodeWhale · error

runtime checked

Error message

runtime checked

What it means

In `followup_one` (crates/tui/src/tools/subagent/coord.rs:337), `self.runtime.clone().expect("runtime checked")` unwraps an `Option<Runtime>` after a preceding branch checked `self.runtime.is_some()`. The `expect` asserts the earlier check guarantees presence. A panic means the runtime option was `None` despite the preceding condition — i.e. the guard and the use drifted apart after a refactor.

Solutions

  1. Re-read the guard condition above line 337 and confirm it still implies `self.runtime.is_some()`.
  2. Bind the option once: `if let Some(runtime) = self.runtime.as_ref() { ... }` instead of check-then-expect.
  3. If the runtime can legitimately disappear, return a `ToolError::execution_failed("runtime unavailable")` instead of panicking.
  4. Check for code paths that clear `self.runtime` while a followup is executing.

Example fix

// before
self.runtime.clone().expect("runtime checked"),
// after
match self.runtime.clone() {
    Some(runtime) => /* use runtime */,
    None => return Err(ToolError::execution_failed("runtime unavailable for followup resume")),
}
Defensive patterns

Strategy: type-guard

Validate before calling

// Precondition check the caller can run before invoking followup
if coordinator.runtime.is_none() {
    return Err("subagent runtime unavailable; cannot resume followup");
}

Type guard

// Narrow once instead of check-then-expect
let Some(runtime) = self.runtime.as_ref() else {
    return Err(ToolError::execution_failed("runtime unavailable"));
};

Try / catch

// Handle the None case explicitly at the call boundary
match self.runtime.clone() {
    Some(rt) => /* proceed with resume_from_checkpoint_for_session */,
    None => Err(ToolError::execution_failed("runtime unavailable for followup")),
}

Prevention

When it happens

Trigger: Invoking the subagent `followup` action's resume-from-checkpoint path when the combined guard (`manager.is_some() && self.runtime.is_some()`) was satisfied, but `self.runtime` became `None` between check and use, or the guard was edited and no longer covers this branch.

Common situations: Concurrent mutation of the coordinator's runtime field, or a refactor that weakened the `is_some()` precondition while keeping the `expect` in place.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15). Data as JSON: /api/errors/fff5dfd8573cd603. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/tools/subagent/coord.rs:337

            .continuation_target_for_caller(
                &context.state_namespace,
                agent_ref,
                self.caller_agent_id.as_deref(),
                "agents/followup",
            )
            .map_err(|error| ToolError::invalid_input(error.to_string()))?;
        let snapshot = manager
            .get_result(&target)
            .map_err(|error| ToolError::invalid_input(error.to_string()))?;
        let resumed_already = source != target;
        let receipt = if super::subagent_checkpoint_is_continuable(&snapshot)
            && self.runtime.is_some()
        {
            let snapshot = manager
                .resume_from_checkpoint_for_session(
                    &context.state_namespace,
                    Arc::clone(&self.manager),
                    self.runtime.clone().expect("runtime checked"),
                    &target,
                    message,
                )
                .map_err(|error| ToolError::execution_failed(error.to_string()))?;
            ParentMailReceipt {
                agent_id: snapshot.agent_id.clone(),
                status: subagent_status_name(&snapshot.status).to_string(),
                queue_depth: 0,
                woke: true,
                continued_from_checkpoint: true,
                continuation_handle: None,
                note: format!(
                    "resumed from checkpoint {source} as {}; original receipt retained",
                    snapshot.agent_id
                ),
            }
        } else if resumed_already && snapshot.status != SubAgentStatus::Running {
            ParentMailReceipt {

View on GitHub (pinned to 433685b202)