CogniMail AI
Autonomous email intelligence system using multi-agent orchestration
An agentic AI system that autonomously processes, categorizes, prioritizes, and drafts responses to emails using a multi-agent architecture with specialized worker agents coordinated by a supervisor agent.
Problem
Knowledge workers spend 28% of their workweek on email. Existing solutions — rules, templates, basic ML classifiers — fail to handle the nuance and context required for intelligent email processing. A CFO's email thread about quarterly results requires fundamentally different handling than a customer support inquiry, yet most automation treats them identically.
Solution
CogniMail AI uses a supervisor-worker agent architecture. A supervisor agent classifies incoming emails by intent and urgency, then routes them to specialized agents for summarization, information extraction, or response drafting. The system learns from user corrections and maintains conversation context across email threads. Unlike rigid rule-based systems, the agentic approach adapts to novel email patterns without retraining.
Architecture
Supervisor-Worker multi-agent system orchestrated via LangGraph. Hybrid retrieval (FAISS + PostgreSQL) for historical email context. Structured output schemas for downstream CRM/calendar integration. Ephemeral processing ensures raw email content is never persisted.
Challenges
- Handling ambiguous email intent without hallucinated responses — implemented confidence thresholds with explicit 'needs clarification' routing
- Maintaining conversation thread context across fragmented email chains spanning weeks and multiple participants
- Balancing automation with appropriate human-in-the-loop checkpoints — built a risk-scored routing system
- Privacy-preserving email processing without storing sensitive content — all processing in-memory with zero persistence of raw bodies
Results
- 85% reduction in time spent on routine email processing (measured across 50 beta users over 3 months)
- 92% classification accuracy on multi-intent emails in production traffic (10K+ emails/day)
- Successfully deployed and processing 10,000+ emails per day with 99.7% uptime
- User satisfaction score of 4.6/5 with Net Promoter Score of 72
Lessons Learned
- Agent orchestration requires explicit error recovery paths — don't assume the LLM will handle tool failures gracefully; every tool call needs a fallback
- Multi-agent systems need structured inter-agent communication protocols (typed messages), not free-form text — this eliminated 40% of agent coordination failures
- Human-in-the-loop is not a fallback — it's a feature that improves both safety and system quality when designed as a first-class interaction pattern
System Architecture
┌──────────────────────────────────┐
│ Email Sources │
│ Gmail · Outlook · IMAP · API │
└──────────────┬───────────────────┘
│
▼
┌──────────────────────────────────┐
│ Ingest & Preprocess │
│ · HTML parsing & text extraction │
│ · Thread history reconstruction │
│ · Attachment handling │
└──────────────┬───────────────────┘
│
▼
┌──────────────────────────────────┐
│ Supervisor Agent │
│ · Intent classification │
│ · Urgency scoring │
│ · Agent routing decisions │
└──┬──────────┬──────────┬─────────┘
│ │ │
┌────────▼──┐ ┌─────▼─────┐ ┌─▼──────────┐
│ Classifier │ │ Extractor │ │ Drafter │
│ Agent │ │ Agent │ │ Agent │
└────────────┘ └───────────┘ └────────────┘
│ │ │
└──────────┼──────────┘
│
▼
┌──────────────────────────────────┐
│ Memory Layer │
│ Short-term: Redis (session state) │
│ Long-term: PG + FAISS (history) │
└──────────────┬───────────────────┘
│
▼
┌──────────────────────────────────┐
│ Human Review Layer │
│ · Risk-scored routing │
│ · Draft approval UI │
│ · Feedback loop for learning │
└──────────────────────────────────┘
How It Works
Step 1: Email Intake
When an email arrives, the system extracts the body, metadata, and attachments. HTML normalization strips signatures, quoted replies, and formatting noise. Thread reconstruction links the email to its conversation history — a critical step since context often spans dozens of fragmented messages across days or weeks.
Step 2: The Multi-Agent System
CogniMail uses LangGraph to orchestrate a supervisor-worker architecture:
Supervisor Agent. The entry point. Analyzes the email, determines which specialized agents are needed, and coordinates the workflow. Makes routing decisions — whether to draft a response immediately, extract structured data, or escalate for human review. Maintains state across the processing pipeline.
Classifier Agent. Fine-grained intent classification: distinguishes between meeting requests, task assignments, status updates, FYI notifications, and spam. Identifies specific action items with deadlines. Confidence scores determine whether to auto-process or flag for review.
Extractor Agent. Pulls structured data from emails — meeting dates/times, monetary amounts, tracking numbers, contact details. Outputs typed JSON that integrates directly with calendars, CRMs, and task managers via webhooks.
Drafter Agent. Composes contextual responses based on email intent, user's communication style (learned from history), and thread context. Responses are presented for human review with diffs highlighted before sending.
Step 3: Memory & Context
- Short-term memory (Redis): Active conversation state, recent thread context, agent state during multi-step workflows
- Long-term memory (PostgreSQL + FAISS): Historical email patterns, user communication preferences, and successful response templates indexed by intent and context similarity
Step 4: Safety & Privacy
Ephemeral processing — raw email bodies are never persisted to disk. All processing happens in-memory. Sensitive content detection (financial data, PHI) triggers automatic human review flags. Encrypted in transit end-to-end.