Hmbown/CodeWhale · error

Failed to start turn: engine operation channel closed

Error message

Failed to start turn: engine operation channel closed

What it means

Reserving capacity on the engine's operation channel failed because the receiver was dropped — the turn loop has shut down, so no further turns can be submitted to this engine. Reservation happens before any durable state is claimed, so nothing is half-committed.

Source

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

            auto_approve,
            translation_enabled: false,
            allowed_tools: None,
            dynamic_tools: req.dynamic_tools,
            hook_executor: None,
            approval_mode: policy.permission,
            verbosity,
            provenance: input_source.provenance(),
        };

        // Reserve mailbox capacity before claiming or persisting anything.
        // If the caller is cancelled while capacity is unavailable, no
        // durable or in-memory turn state has changed.
        let permit = engine
            .tx_op
            .clone()
            .reserve_owned()
            .await
            .map_err(|_| anyhow!("Failed to start turn: engine operation channel closed"))?;

        let acceptance_rx = {
            // Lock order is active -> thread_mutation. Neither guard crosses
            // an await, and spawning the owned lifecycle task is synchronous.
            let mut active = self.active.lock().await;
            let Some(state) = active.engines.get_mut(thread_id) else {
                bail!("Thread engine not loaded");
            };
            if state.active_turn.is_some() {
                bail!("Thread already has an active turn");
            }
            let _thread_mutation = self.store.thread_mutation.lock();
            let mut current_thread = self.store.load_thread(thread_id)?;
            if !thread_execution_state_matches(&thread, &current_thread) {
                bail!("Thread execution settings changed while preparing the turn; retry");
            }
            let previous_active_route = (state.route_identity.clone(), state.route_model.clone());
            state.active_turn = Some(ActiveTurnState {

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. The engine/session has terminated; start a new session or recreate the runtime
  2. Restart the Codewhale process if the engine should still be alive
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at crates/tui/src/runtime_threads.rs:6105 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/a402a654a9668a64. Report an issue: GitHub.