Skip to content

A complete AI agency at your fingertips - From frontend wizards to Reddit community ninjas, from whimsy injectors to reality checkers. Each agent is a specialized expert with personality, processes, and proven deliverables.

Shell

Reject ambiguous email identities before thread reconstruction

Rudy Celekli5bc194a0a84f
diff --git a/engineering/engineering-email-intelligence-engineer.md b/engineering/engineering-email-intelligence-engineer.md
index 46b27c7f..918fc537 100644
--- a/engineering/engineering-email-intelligence-engineer.md
+++ b/engineering/engineering-email-intelligence-engineer.md
@@ -128,7 +128,15 @@ def reconstruct_thread(messages):
- Quoted replies duplicate content (20-msg thread = ~4-5x token bloat)
- Thread forks when people reply to different messages in the chain
"""
- # Build reply graph from In-Reply-To and References headers
+ # Reject ambiguous identities before building or mutating the graph.
+ # Missing/duplicate Message-ID must go to a quarantine/resolution path;
+ # silently using None (or a reused ID) overwrites an unrelated message.
+ message_ids = [msg.get("message_id") for msg in messages]
+ if any(not isinstance(mid, str) or not mid.strip() for mid in message_ids):
+ raise ValueError("Every message needs a nonempty Message-ID")
+ if len(set(message_ids)) != len(message_ids):
+ raise ValueError("Duplicate Message-ID: resolve identity before reconstruction")
+
graph = {}
for msg in messages:
parent_id = msg["in_reply_to"]