Hmbown/CodeWhale · error · anyhow::Error

Turn {turn_id} is not active on thread {thread_id}

Error message

Turn {turn_id} is not active on thread {thread_id}

What it means

interrupt_turn's id match failed: the thread has an active turn, but its turn id differs from the requested one. This catches stale turn ids (from an older, finished turn) being interrupted by mistake, before any stop signal is sent.

Source

Thrown at crates/tui/src/runtime_threads.rs:6194

        acceptance_rx
            .await
            .map_err(|_| anyhow!("Turn lifecycle task ended before acknowledgement"))?
            .map_err(anyhow::Error::msg)
        })
        .await
    }

    pub async fn interrupt_turn(&self, thread_id: &str, turn_id: &str) -> Result<TurnRecord> {
        {
            let mut active = self.active.lock().await;
            let Some(active_thread) = active.engines.get_mut(thread_id) else {
                bail!("Thread is not loaded");
            };
            let Some(active_turn) = active_thread.active_turn.as_mut() else {
                bail!("No active turn on thread {thread_id}");
            };
            if active_turn.turn_id != turn_id {
                bail!("Turn {turn_id} is not active on thread {thread_id}");
            }
            active_turn.interrupt_requested = true;
            if let Some(compaction_id) = active_turn.compaction_id.as_deref() {
                active_thread.engine.cancel_compaction(compaction_id)?;
            } else {
                active_thread.engine.cancel();
            }
            touch_lru(&mut active.lru, thread_id);
        }

        self.emit_event(
            thread_id,
            Some(turn_id),
            None,
            "turn.interrupt_requested",
            json!({ "thread_id": thread_id, "turn_id": turn_id }),
        )
        .await?;

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Fetch the thread's current turn id
  2. Retry the interrupt with that id
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at crates/tui/src/runtime_threads.rs:6194 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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