zed-industries/zed · error · anyhow::Error
Message not found
Error message
Message not found
What it means
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.
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/agent/src/thread.rs:2387 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@916fc2b8cb (2026-08-20).
Data as JSON: /api/errors/8fc34c61a74e36f6.
Report an issue: GitHub.
Appendix: source
Thrown at crates/agent/src/thread.rs:2393
/// the token usage indicator reports `Exceeded` instead of the stale usage
/// from the last successful request. Providers don't report usage for
/// failed requests, so we synthesize one from the reported overflow (when
/// available) or the model's context size.
fn mark_token_limit_exceeded(&mut self, tokens: Option<u64>, cx: &mut Context<Self>) {
let Some(model) = self.model() else {
return;
};
let input_tokens = tokens.unwrap_or(0).max(model.max_token_count());
let Some(last_user_message) = self.last_user_message() else {
return;
};
self.request_token_usage.insert(
last_user_message.id.clone(),
language_model::TokenUsage {
input_tokens,
..Default::default()
},
);
cx.emit(TokenUsageUpdated(self.latest_token_usage()));
cx.notify();
}
pub fn truncate(
&mut self,
client_user_message_id: ClientUserMessageId,
cx: &mut Context<Self>,
) -> Result<()> {
self.cancel(cx).detach();
// Clear pending message since cancel will try to flush it asynchronously,
// and we don't want that content to be added after we truncate
self.pending_message.take();
let Some(position) = self.messages.iter().position(|msg| {
matches!(&**msg, Message::User(UserMessage { id, .. }) if id == &client_user_message_id)
}) else {
return Err(anyhow!("Message not found"));View on GitHub (pinned to 916fc2b8cb)