{"record":{"id":"95af555f3456da29","repo":"Hmbown/CodeWhale","slug":"agent-mail-message-id-already-exists-with-dif","errorCode":null,"errorMessage":"Agent Mail message id '{}' already exists with different delivery intent","messagePattern":"Agent Mail message id '(.+?)' already exists with different delivery intent","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/runtime_threads.rs","lineNumber":6393,"sourceCode":"        {\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            );\n        }\n\n        let (envelope, idempotent_replay) = {\n            let _mail_mutation = self.store.mail_mutation.lock();\n            let path = self.store.mail_path(&request.message_id)?;\n            if path.exists() {\n                let persisted = self.store.load_agent_mail(&request.message_id)?;\n                if !persisted.matches_send_request(&request) {\n                    bail!(\n                        \"Agent Mail message id '{}' already exists with different delivery intent\",\n                        request.message_id\n                    );\n                }\n                (persisted, true)\n            } else {\n                let envelope = AgentMailEnvelope {\n                    schema_version: AGENT_MAIL_SCHEMA_VERSION,\n                    message_id: request.message_id,\n                    source,\n                    destination,\n                    sender: request.sender,\n                    summary: request.summary,\n                    evidence: request.evidence,\n                    delivery_mode: request.delivery_mode,\n                    trigger_turn: request.trigger_turn,\n                    hop_count: request.hop_count,\n                    status: AgentMailStatus::Queued,","sourceCodeStart":6375,"sourceCodeEnd":6411,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/runtime_threads.rs#L6375-L6411","documentation":"Idempotency conflict in Agent Mail: a message with the same id already exists but with different delivery intent; the store refuses to silently overwrite the earlier intent because the id is the idempotency key.","triggerScenarios":"Thrown at crates/tui/src/runtime_threads.rs:6393 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reuse the same delivery intent (recipient/status) as the original send, making the replay an exact idempotent duplicate.","Use a new message id if the intent genuinely differs."],"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"}