Hmbown/CodeWhale · error

Turn lifecycle task ended before acknowledgement

Error message

Turn lifecycle task ended before acknowledgement

What it means

Sentinel from acceptance_rx.await.map_err in submit_turn: the oneshot/mpsc receiver failed because the spawned turn lifecycle task (the closure that claims the permit and sends Op to the engine) exited or was dropped before sending an acknowledgement. It signals the producer side died — engine loop panicked, task aborted, or the channel sender was dropped — not that the turn itself failed.

Source

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

                allow_shell,
                trust_mode,
                auto_approve,
                policy.permission,
                configured_sandbox_mode,
            );
            let _sender = permit.send(op);
            touch_lru(&mut active.lru, thread_id);
            self.spawn_claimed_turn_monitor(
                turn.clone(),
                Some(user_item),
                engine.clone(),
                ClaimedTurnKind::Message,
            )
        };

        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;

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Check the TUI logs/engine task panic output to find why the lifecycle task exited before acking
  2. Verify the engine operation channel and permit machinery are alive (engine not shut down mid-submit)
  3. Resubmit the turn once the underlying task failure is diagnosed; the turn was never acknowledged so no durable turn record was accepted
Defensive patterns

Strategy: try-catch

When it happens

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