Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Email Triage Agent

An LLM-powered agent that reads incoming emails, classifies them by urgency and category, and generates a prioritized action plan with recommended next steps.

Problem

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.

How It Works

Incoming Emails → [Classification] → [Prioritization] → Action Plan
                   urgency             sort by           recommended
                   category            urgency           next steps

Classification

Each email is classified on two dimensions:

  • Urgency: critical / high / medium / low / ignore
  • Category: production_issue, client_request, security, project, hr_admin, billing, newsletter

Output

A prioritized action plan with:

  • Summary of each email
  • Recommended action (specific, not vague)
  • Estimated time to handle
  • Whether a reply is needed

Example Output

[!!!] 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

Usage

# 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.json

Architecture

agent.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

Design Decisions

  1. Provider-agnostic — Swappable LLM backends (OpenAI, Anthropic, or rule-based fallback). The agent logic doesn't depend on any specific API.

  2. Structured output — Forces JSON responses with a predefined schema. This makes the output parseable and actionable, not just free-text summaries.

  3. 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.

Tech Stack

Python, OpenAI API, Anthropic API

About

LLM agent that classifies emails by urgency & generates prioritized action plans

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages