{"record":{"id":"f317d9231fb6a95f","repo":"Hmbown/CodeWhale","slug":"agent-mail-source-and-destination-threads-must-dif","errorCode":null,"errorMessage":"Agent Mail source and destination threads must differ","messagePattern":"Agent Mail source and destination threads must differ","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/runtime_threads.rs","lineNumber":6366,"sourceCode":"        if agent_mail_looks_like_raw_transcript(&request.summary) {\n            bail!(\"Agent Mail accepts a bounded handoff summary, not a raw transcript\");\n        }\n        request.summary = sanitize_agent_mail_text(&request.summary, MAX_AGENT_MAIL_SUMMARY_BYTES);\n        request.sender.display_label = sanitize_agent_mail_text(\n            &request.sender.display_label,\n            codewhale_protocol::agent_mail::MAX_AGENT_MAIL_DISPLAY_LABEL_BYTES,\n        );\n        for evidence in &mut request.evidence {\n            if let Some(label) = evidence.label.as_mut() {\n                *label = sanitize_agent_mail_text(\n                    label,\n                    codewhale_protocol::agent_mail::MAX_AGENT_MAIL_EVIDENCE_LABEL_BYTES,\n                );\n            }\n        }\n        request.validate().map_err(|error| anyhow!(error))?;\n        if request.source_thread_id == request.destination_thread_id {\n            bail!(\"Agent Mail source and destination threads must differ\");\n        }\n\n        let source_thread = self.get_thread(&request.source_thread_id).await?;\n        let destination_thread = self.get_thread(&request.destination_thread_id).await?;\n        let source = agent_mail_address(&self.store.owner_id, &source_thread)?;\n        let destination = agent_mail_address(&self.store.owner_id, &destination_thread)?;\n        if source.owner_id != destination.owner_id\n            || source.workspace_id != destination.workspace_id\n        {\n            bail!(\n                \"Agent Mail ownership denied: source and destination must belong to the same runtime owner and workspace\"\n            );\n        }\n        let expected_sender = agent_mail_sender_identity(&source_thread)?;\n        if request.sender.identity != expected_sender {\n            bail!(\n                \"Agent Mail ownership denied: sender identity does not own the source task/session\"\n            );","sourceCodeStart":6348,"sourceCodeEnd":6384,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/runtime_threads.rs#L6348-L6384","documentation":"Self-mail guard in the Agent Mail send path: source_thread_id and destination_thread_id must differ, checked after request.validate(). A message a thread addresses to itself is rejected before any ownership or persistence work.","triggerScenarios":"Thrown at crates/tui/src/runtime_threads.rs:6366 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set destination_thread_id to a different thread.","Route self-directed notes through a different mechanism; Agent Mail is inter-thread by design."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}