{"record":{"id":"dff1e9722590721c","repo":"Hmbown/CodeWhale","slug":"thread-thread-id-not-found","errorCode":null,"errorMessage":"thread '{thread_id}' not found","messagePattern":"thread '(.+?)' not found","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/runtime_threads.rs","lineNumber":3274,"sourceCode":"            }\n        };\n        let ack =\n            self.spawn_dynamic_tool_settlement(claim, DynamicToolTerminalOutcome::Resolved(result));\n        Ok(Self::await_dynamic_tool_settlement(ack)\n            .await?\n            .result_accepted)\n    }\n\n    pub async fn submit_user_input(\n        &self,\n        thread_id: &str,\n        input_id: &str,\n        response: crate::tools::user_input::UserInputResponse,\n    ) -> Result<bool> {\n        let engine = {\n            let active = self.active.lock().await;\n            let Some(state) = active.engines.get(thread_id) else {\n                bail!(\"thread '{thread_id}' not found\");\n            };\n            state.engine.clone()\n        };\n        let request = match self.claim_pending_user_input(thread_id, input_id) {\n            PendingUserInputClaim::Claimed(request) => request,\n            PendingUserInputClaim::Missing | PendingUserInputClaim::Settling => {\n                return Ok(false);\n            }\n            PendingUserInputClaim::Indeterminate => {\n                bail!(\n                    \"User-input request '{input_id}' has an indeterminate terminal receipt; inspect Runtime storage before retrying\"\n                );\n            }\n        };\n\n        // This child task deliberately outlives the HTTP future. Once a\n        // request is claimed, client disconnect/cancellation cannot strand it\n        // between durable acceptance and engine delivery.","sourceCodeStart":3256,"sourceCodeEnd":3292,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/runtime_threads.rs#L3256-L3292","documentation":"submit_user_input could not find thread_id in the active engines map. The user-input protocol only works against a thread whose engine is currently started (an active turn exists to receive the answer), so a thread that was never started, has finished, or was evicted fails here.","triggerScenarios":"Calling submit_user_input after the turn/engine ended (the pending request expired with the engine), with a stale or mistyped thread_id, or before start_thread completed. See runtime_threads.rs:3274-3279.","commonSituations":"Client held a request id across a runtime restart and resumed answering after the engine shut down; race between turn completion and a late user response; thread archived or evicted by a workspace change between polling the request and answering.","solutions":["Check the thread exists and has a live engine before answering (poll thread status / pending requests first)","If the engine legitimately ended, discard the stale request - the Ok(false) contract for Missing/Settling shows the runtime distinguishes this from hard errors","Re-poll pending_requests_for_thread to confirm the input_id is still advertised before submitting","Verify thread_id spelling and that the thread was started in this runtime session"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Confirm the thread has a live engine before answering.\nlet thread = manager.get_thread(thread_id).await?; // hard error if the record is gone\nif !manager.has_active_engine(thread_id).await { // or your equivalent liveness check\n    return Ok(()); // engine ended; drop the stale request\n}\nmanager.submit_user_input(thread_id, input_id, response).await?;","typeGuard":null,"tryCatchPattern":"// Distinguish 'engine gone' (restartable) from real errors.\nmatch manager.submit_user_input(thread_id, input_id, response).await {\n    Ok(accepted) => Ok(accepted),\n    Err(e) if e.to_string().contains(\"thread '\") && e.to_string().contains(\"not found\") => {\n        // Re-check thread state; restart it or discard the stale request.\n        Ok(false)\n    }\n    Err(e) => Err(e),\n}","preventionTips":["Answer user-input requests promptly; engines end with their turns","Re-poll pending requests right before answering to confirm the request is still advertised","Never cache thread ids across runtime restarts"],"tags":["user-input","thread-lifecycle","not-found","runtime"],"backgroundTag":"thread-or-session-not-found","analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}