{"record":{"id":"8fc34c61a74e36f6","repo":"zed-industries/zed","slug":"message-not-found","errorCode":null,"errorMessage":"Message not found","messagePattern":"Message not found","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/agent/src/thread.rs","lineNumber":2393,"sourceCode":"    /// the token usage indicator reports `Exceeded` instead of the stale usage\n    /// from the last successful request. Providers don't report usage for\n    /// failed requests, so we synthesize one from the reported overflow (when\n    /// available) or the model's context size.\n    fn mark_token_limit_exceeded(&mut self, tokens: Option<u64>, cx: &mut Context<Self>) {\n        let Some(model) = self.model() else {\n            return;\n        };\n        let input_tokens = tokens.unwrap_or(0).max(model.max_token_count());\n        let Some(last_user_message) = self.last_user_message() else {\n            return;\n        };\n\n        self.request_token_usage.insert(\n            last_user_message.id.clone(),\n            language_model::TokenUsage {\n                input_tokens,\n                ..Default::default()\n            },\n        );\n        cx.emit(TokenUsageUpdated(self.latest_token_usage()));\n        cx.notify();\n    }\n\n    pub fn truncate(\n        &mut self,\n        client_user_message_id: ClientUserMessageId,\n        cx: &mut Context<Self>,\n    ) -> Result<()> {\n        self.cancel(cx).detach();\n        // Clear pending message since cancel will try to flush it asynchronously,\n        // and we don't want that content to be added after we truncate\n        self.pending_message.take();\n        let Some(position) = self.messages.iter().position(|msg| {\n            matches!(&**msg, Message::User(UserMessage { id, .. }) if id == &client_user_message_id)\n        }) else {\n            return Err(anyhow!(\"Message not found\"));","sourceCodeStart":2375,"sourceCodeEnd":2411,"githubUrl":"https://github.com/zed-industries/zed/blob/916fc2b8cb3a815cbef4a3b40e13081be72036b6/crates/agent/src/thread.rs#L2375-L2411","documentation":"Sentinel from Thread::truncate: no message in the thread matches the given ClientUserMessageId, so truncation (rewind to that message) cannot proceed. Typically a stale or already-truncated message id.","triggerScenarios":"Thrown at crates/agent/src/thread.rs:2387 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Refresh the client's message list so ids match the thread's current messages","Check the id wasn't already removed by a previous truncate or edit","Ignore/reject truncate requests for messages no longer present"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"916fc2b8cb3a815cbef4a3b40e13081be72036b6","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}