Hmbown/CodeWhale · error
Agent Mail ownership denied: source and destination must…
Error message
Agent Mail ownership denied: source and destination must belong to the same runtime owner and workspace
What it means
Agent Mail ownership check: the resolved source and destination addresses have different owner ids (and/or workspaces); cross-owner or cross-workspace mail is denied so one runtime owner cannot inject messages into another owner's threads.
Solutions
- Send mail only between threads owned by the same runtime owner and workspace.
- Re-create the foreign thread under this runtime if cross-runtime handoff is genuinely needed.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/tui/src/runtime_threads.rs:6376 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/5d6ac78f5fc4ec1f.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/runtime_threads.rs:6376
*label = sanitize_agent_mail_text(
label,
codewhale_protocol::agent_mail::MAX_AGENT_MAIL_EVIDENCE_LABEL_BYTES,
);
}
}
request.validate().map_err(|error| anyhow!(error))?;
if request.source_thread_id == request.destination_thread_id {
bail!("Agent Mail source and destination threads must differ");
}
let source_thread = self.get_thread(&request.source_thread_id).await?;
let destination_thread = self.get_thread(&request.destination_thread_id).await?;
let source = agent_mail_address(&self.store.owner_id, &source_thread)?;
let destination = agent_mail_address(&self.store.owner_id, &destination_thread)?;
if source.owner_id != destination.owner_id
|| source.workspace_id != destination.workspace_id
{
bail!(
"Agent Mail ownership denied: source and destination must belong to the same runtime owner and workspace"
);
}
let expected_sender = agent_mail_sender_identity(&source_thread)?;
if request.sender.identity != expected_sender {
bail!(
"Agent Mail ownership denied: sender identity does not own the source task/session"
);
}
let (envelope, idempotent_replay) = {
let _mail_mutation = self.store.mail_mutation.lock();
let path = self.store.mail_path(&request.message_id)?;
if path.exists() {
let persisted = self.store.load_agent_mail(&request.message_id)?;
if !persisted.matches_send_request(&request) {
bail!(
"Agent Mail message id '{}' already exists with different delivery intent",View on GitHub (pinned to 73e0f67d83)