{"record":{"id":"e387c37b253defd2","repo":"Hmbown/CodeWhale","slug":"turn-turn-id-is-not-active-on-thread-thread-id","errorCode":null,"errorMessage":"Turn {turn_id} is not active on thread {thread_id}","messagePattern":"Turn (.+?) is not active on thread (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/runtime_threads.rs","lineNumber":6194,"sourceCode":"        acceptance_rx\n            .await\n            .map_err(|_| anyhow!(\"Turn lifecycle task ended before acknowledgement\"))?\n            .map_err(anyhow::Error::msg)\n        })\n        .await\n    }\n\n    pub async fn interrupt_turn(&self, thread_id: &str, turn_id: &str) -> Result<TurnRecord> {\n        {\n            let mut active = self.active.lock().await;\n            let Some(active_thread) = active.engines.get_mut(thread_id) else {\n                bail!(\"Thread is not loaded\");\n            };\n            let Some(active_turn) = active_thread.active_turn.as_mut() else {\n                bail!(\"No active turn on thread {thread_id}\");\n            };\n            if active_turn.turn_id != turn_id {\n                bail!(\"Turn {turn_id} is not active on thread {thread_id}\");\n            }\n            active_turn.interrupt_requested = true;\n            if let Some(compaction_id) = active_turn.compaction_id.as_deref() {\n                active_thread.engine.cancel_compaction(compaction_id)?;\n            } else {\n                active_thread.engine.cancel();\n            }\n            touch_lru(&mut active.lru, thread_id);\n        }\n\n        self.emit_event(\n            thread_id,\n            Some(turn_id),\n            None,\n            \"turn.interrupt_requested\",\n            json!({ \"thread_id\": thread_id, \"turn_id\": turn_id }),\n        )\n        .await?;","sourceCodeStart":6176,"sourceCodeEnd":6212,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/runtime_threads.rs#L6176-L6212","documentation":"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.","triggerScenarios":"Thrown at crates/tui/src/runtime_threads.rs:6194 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fetch the thread's current turn id","Retry the interrupt with that id"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}