Overview
In this example, the agent classifies emails into one of two categories:- Information Requests — messages requesting data such as account statements, balance history, or audit documents.
- Lien on Bank Account — notifications indicating a lien, freeze, or court order on a customer account.
There are no external integrations — just intelligent reasoning based on email content.
Key Features
- Autonomous Classification: The LLM performs all reasoning — no manual logic or regex
- Minimal Architecture: One Task, one prompt, one result
- Structured Output: Uses Pydantic models for type-safe responses
- Extendable: Easily add new categories or integrate with real email systems
Code Structure
Response Model
Agent Setup
Task Definition
Example Emails
The script includes two sample emails: Email 1 - Information Request:Complete Implementation
How It Works
- Input: The LLM receives the text of the email.
- Reasoning: The agent analyzes the content and context — e.g., requests vs. legal notifications.
- Output: Returns a structured JSON object with a single field:
category
:"information_request"
or"lien_on_bank_account"
Usage
Setup
Run the classifier
Example Output
Email 1:Use Cases
- Fintech Operations: Automatically sort incoming regulatory and legal emails
- Compliance Departments: Handle high email volume with intelligent routing
- Customer Support: Categorize support tickets and requests
- Legal Teams: Identify urgent legal notifications requiring immediate attention