Hmbown/CodeWhale · error · anyhow::Error
Thread engine not loaded
Error message
Thread engine not loaded
What it means
Inside the start-turn critical section, the thread id had no entry in the active engines map — the engine was expected to be loaded (ensure_engine_loaded ran earlier) but is not registered. Effectively an internal invariant failure, typically triggered by concurrent teardown/eviction of the engine between load and claim.
Source
Thrown at crates/tui/src/runtime_threads.rs:6112
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, ¤t_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 {
turn_id: turn_id.clone(),
interrupt_requested: false,
compaction_id: None,
});
state.route_identity = provider_identity;
state.route_model.clone_from(&model);
View on GitHub (pinned to 0c42157ee5)
Solutions
- Retry the turn start so the engine reloads
- If persistent, check for concurrent thread teardown or eviction
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at crates/tui/src/runtime_threads.rs:6112 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/9469225b365a790c.
Report an issue: GitHub.