Hmbown/CodeWhale · error

Agent Mail ownership denied: sender identity does not own…

Error message

Agent Mail ownership denied: sender identity does not own the source task/session

What it means

The sender identity on the envelope does not match the identity derived from the source thread (agent_mail_sender_identity); a caller claiming another agent's identity is denied, preventing spoofed senders.

Solutions

  1. Set request.sender.identity to the identity derived from the source thread (agent_mail_sender_identity).
  2. Send the message from the thread that actually owns the source task/session.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/tui/src/runtime_threads.rs:6382 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/08ffc1c29d01e945. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/runtime_threads.rs:6382

        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",
                        request.message_id
                    );
                }
                (persisted, true)
            } else {
                let envelope = AgentMailEnvelope {

View on GitHub (pinned to 73e0f67d83)