Hmbown/CodeWhale · error
Agent Mail ownership denied: message does not belong to…
Error message
Agent Mail ownership denied: message does not belong to this destination
What it means
mark_agent_mail_read verifies the envelope's destination matches the thread it is being marked read in; a message id belonging to another thread is refused so read receipts cannot be forged across threads.
Solutions
- Call mark_agent_mail_read with the message_id from the destination thread's own inbox.
- Verify the thread id is the thread the envelope was delivered to.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/tui/src/runtime_threads.rs:6462 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/758928e5ecd9e02d.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/runtime_threads.rs:6462
.collect::<Vec<_>>();
Ok(inbox)
})
.await
.context("Agent Mail inbox task panicked")?
}
pub async fn mark_agent_mail_read(
&self,
thread_id: &str,
message_id: &AgentMailMessageId,
) -> Result<AgentMailEnvelope> {
let thread = self.get_thread(thread_id).await?;
let address = agent_mail_address(&self.store.owner_id, &thread)?;
let envelope = {
let _mail_mutation = self.store.mail_mutation.lock();
let mut envelope = self.store.load_agent_mail(message_id)?;
if envelope.destination != address {
bail!("Agent Mail ownership denied: message does not belong to this destination");
}
match envelope.status {
AgentMailStatus::Read => envelope,
AgentMailStatus::Delivered => {
envelope.status = AgentMailStatus::Read;
envelope.read_at = Some(Utc::now());
self.store.save_agent_mail(&envelope)?;
envelope
}
_ => bail!("Agent Mail can be marked read only after delivery"),
}
};
self.emit_agent_mail_event(AGENT_MAIL_EVENT_READ, &envelope)
.await?;
Ok(envelope)
}
/// Withdraw a queued envelope before it starts delivery (#6176). OnlyView on GitHub (pinned to 73e0f67d83)