An LLM-powered agent that reads incoming emails, classifies them by urgency and category, and generates a prioritized action plan with recommended next steps.
A data scientist receives dozens of emails daily: production alerts, client requests, project updates, newsletters. Manually prioritizing these wastes time and risks missing critical issues. This agent automates the triage process.
Incoming Emails → [Classification] → [Prioritization] → Action Plan
urgency sort by recommended
category urgency next steps
Each email is classified on two dimensions:
- Urgency: critical / high / medium / low / ignore
- Category: production_issue, client_request, security, project, hr_admin, billing, newsletter
A prioritized action plan with:
- Summary of each email
- Recommended action (specific, not vague)
- Estimated time to handle
- Whether a reply is needed
[!!!] CRITICAL | Urgent: Model predictions seem off
Category: production_issue
Summary: Credit scoring model returning abnormally high default probabilities
Action: Check model deployment logs and compare feature distributions
Time: 2hr [REPLY NEEDED]
[ ! ] HIGH | Feature request: explainability report
Category: client_request
Summary: Client needs SHAP values for regulatory compliance
Action: Scope SHAP integration into API response, estimate timeline
Time: 30min [REPLY NEEDED]
[ - ] MEDIUM | New project: churn prediction model
Category: project
Action: Accept meeting invite, prepare data availability overview
Time: 15min
# Rule-based mode (no API key needed)
python agent.py
# With OpenAI
export OPENAI_API_KEY=your_key
python agent.py --provider openai
# With Anthropic
export ANTHROPIC_API_KEY=your_key
python agent.py --provider anthropic
# Custom email file
python agent.py --emails path/to/emails.json --output results.jsonagent.py
├── Data models (Urgency, Category, TriageResult)
├── Prompt engineering (SYSTEM_PROMPT, build_triage_prompt)
├── LLM providers (OpenAI, Anthropic, local fallback)
└── EmailTriageAgent
├── triage_email() → classify single email
├── triage_batch() → classify + sort by urgency
└── generate_action_plan() → formatted output
-
Provider-agnostic — Swappable LLM backends (OpenAI, Anthropic, or rule-based fallback). The agent logic doesn't depend on any specific API.
-
Structured output — Forces JSON responses with a predefined schema. This makes the output parseable and actionable, not just free-text summaries.
-
Local fallback — Keyword-based classification works without any API key. Useful for testing the pipeline and demonstrates that the architecture matters more than the model.
Python, OpenAI API, Anthropic API