π Try the demo: https://github.com/LM-Kit/lm-kit-net-samples/tree/main/console_net/agents/email_triage_agent
Email Triage & Response Agent for C# .NET Applications
π― Purpose of the Demo
Email Triage & Response Agent demonstrates how to use LM-Kit.NET to build an intelligent email processing system using supervisor-based multi-agent orchestration. A supervisor agent coordinates three specialist workers to classify, analyze, and draft responses to incoming emails, all running locally with no cloud dependency.
The sample shows how to:
- Build a SupervisorOrchestrator with
SupervisorOrchestratorfor coordinating specialist agents. - Create multiple worker agents with focused personas using
Agent.CreateBuilder(). - Use streaming execution with
RunStreamingAsync()for real-time output. - Handle different
OrchestrationStreamTokenTypevalues for rich UI display. - Process multi-line input (full email bodies) in a console application.
- Combine multiple AI capabilities (classification, extraction, generation) in a coordinated workflow.
Why an Email Triage Agent with LM-Kit.NET?
- Email privacy: sensitive email content stays on your infrastructure.
- Supervisor pattern: demonstrates real-world multi-agent coordination.
- Streaming output: see each specialist agent work in real time.
- Production-ready pattern: the same architecture scales to enterprise email systems.
π₯ Who Should Use This Demo
- Enterprise Developers: build email automation tools for customer service teams.
- Customer Support Teams: automate triage and draft responses for faster resolution.
- IT Departments: process internal support tickets with AI-powered classification.
- AI/ML Engineers: learn supervisor-based orchestration with streaming output.
- SaaS Builders: integrate intelligent email handling into products.
π What Problem It Solves
- Email overload: automatically classify and prioritize incoming emails.
- Response time: draft professional responses in seconds instead of minutes.
- Consistent quality: ensure all responses address every question and follow best practices.
- Escalation detection: automatically flag urgent issues, angry customers, and security concerns.
- Information extraction: pull structured data (order numbers, deadlines, contacts) from unstructured email text.
π» Demo Application Overview
Console app that:
- Lets you choose from multiple models optimized for reasoning and text generation.
- Downloads models if needed, with live progress updates.
- Creates a SupervisorOrchestrator with three specialist workers (Classifier, Extractor, Drafter).
- Enters an interactive loop where you can:
- Paste a full email or type
samplefor a built-in example. - Watch the supervisor delegate to each specialist in real time.
- See streaming output with color-coded agent identification.
- Receive classification, extracted information, and a draft response.
- Paste a full email or type
- Displays execution statistics (workers used, duration).
- Loops until you type
quit.
Key Features
- SupervisorOrchestrator: Intelligent delegation to specialist workers.
- Streaming Execution: Real-time output as each agent works.
- Built-In Sample Email: Try instantly with a realistic customer complaint scenario.
- Multi-Line Input: Paste full emails directly into the console.
- Color-Coded Output: Delegation (yellow), agent start (cyan), content (white), completion (green).
- Structured Classification: Category, urgency, sentiment, and escalation flags.
- Ready-to-Send Responses: Professional emails matching the appropriate tone.
ποΈ Architecture
ββββββββββββββββ
β Supervisor β
β Agent β
ββββββββ¬ββββββββ
β delegates
ββββββββββββββΌβββββββββββββ
βΌ βΌ βΌ
ββββββββββββββ ββββββββββββ ββββββββββββ
β Classifier β βExtractor β β Drafter β
β Agent β β Agent β β Agent β
βββββββ¬βββββββ ββββββ¬ββββββ ββββββ¬ββββββ
β β β
βΌ βΌ βΌ
βββββββββββββ βββββββββββββ βββββββββββββ
β Category β β Intent β β Draft β
β Urgency β β Questions β β Email β
β Sentiment β β Deadlines β β Response β
β Escalationβ β Referencesβ β β
βββββββββββββ βββββββββββββ βββββββββββββ
Worker Agents
| Agent | Planning | Role | Output |
|---|---|---|---|
| Classifier | None | Triage and prioritize | Category, urgency, sentiment, escalation flag |
| Extractor | None | Information mining | Sender intent, questions, actions, deadlines, references |
| Drafter | None | Response composition | Subject line + professional email body |
| Supervisor | Chain-of-Thought | Coordination | Delegates tasks, combines results |
Agent Configuration
using LMKit.Agents;
using LMKit.Agents.Orchestration;
using LMKit.Model;
LM model = LM.LoadFromModelID("qwen3:8b");
// Create specialist workers
var classifier = Agent.CreateBuilder(model)
.WithPersona("Email Classifier - ...")
.WithPlanning(PlanningStrategy.None)
.Build();
var extractor = Agent.CreateBuilder(model)
.WithPersona("Email Information Extractor - ...")
.WithPlanning(PlanningStrategy.None)
.Build();
var drafter = Agent.CreateBuilder(model)
.WithPersona("Email Response Drafter - ...")
.WithPlanning(PlanningStrategy.None)
.Build();
// Create supervisor
var supervisorAgent = Agent.CreateBuilder(model)
.WithPersona("Email Triage Supervisor - ...")
.WithPlanning(PlanningStrategy.ChainOfThought)
.Build();
// Orchestrate
var supervisor = new SupervisorOrchestrator(supervisorAgent)
.AddWorker(classifier)
.AddWorker(extractor)
.AddWorker(drafter);
// Execute with streaming
var result = await supervisor.RunStreamingAsync(
emailContent,
streamHandler,
cancellationToken: cts.Token);
Example Use Cases
Try the built-in sample (sample command) or paste your own emails:
- Customer complaints: damaged products, billing errors, service issues
- Support requests: technical problems, how-to questions, account access
- Sales inquiries: pricing questions, feature comparisons, demo requests
- Bug reports: software errors, unexpected behavior, crash reports
- Partnership proposals: collaboration requests, integration inquiries
Understanding the Output
| Color | Content Type | Description |
|---|---|---|
| Yellow | Delegation | Supervisor delegating to a worker |
| Cyan | Agent Started | Worker agent beginning its task |
| White | Content | Agent output (classification, extraction, email draft) |
| Green | Agent Completed | Worker finished its task |
| Blue | Thinking | Supervisor reasoning about next steps |
| Magenta | Tool Calls | Any tool invocations |
| Red | Errors | Error messages |
βοΈ Getting Started
Prerequisites
- .NET 8.0 or later
- Sufficient VRAM for the selected model (6-18 GB depending on model choice)
Download
git clone https://github.com/LM-Kit/lm-kit-net-samples
cd lm-kit-net-samples/console_net/agents/email_triage_agent
Run
dotnet build
dotnet run
Then:
- Select a model from the menu, or paste a custom model URI.
- Wait for the model to download (first run) and load.
- Type
samplefor a built-in email, or paste your own email (end with empty line). - Watch the supervisor delegate to each specialist in real time.
- Receive classification, extraction, and draft response.
- Type
quitto exit.
π§ Troubleshooting
Supervisor doesn't delegate properly
- Try a larger model (14B+) for better coordination.
- Chain-of-Thought planning requires strong reasoning capability.
Classification is inaccurate
- Provide more email context (include subject, sender, full body).
- Larger models produce more nuanced classification.
Draft response misses details
- Ensure the full email is pasted (not truncated).
- Check that the extractor identified all relevant information.
Timeout errors
- Three agents execute sequentially; each needs inference time.
- Increase timeout or use a smaller, faster model.
π Extend the Demo
- RAG integration: ground responses in a product knowledge base for accurate support answers.
- Email file ingestion: read .eml files directly using built-in document tools.
- Batch processing: process a queue of emails from a folder or mailbox.
- Priority dashboard: aggregate classification results into a triage dashboard.
- Response templates: combine with prompt templates for consistent brand voice.
- Sentiment tracking: monitor customer sentiment trends over time.
- Escalation workflows: trigger alerts when escalation is detected.
π Additional Resources
- LM-Kit.NET Documentation
- SupervisorOrchestrator API Reference
- Agent API Reference
- OrchestrationStreamTokenType API Reference
- LM-Kit Samples Repository
π Related Content
- How-To: Delegate Tasks Between Agents: Learn how a supervisor agent routes work to specialist workers.
- How-To: Build Multi-Agent Workflow: Step-by-step guide to building orchestrated multi-agent systems.
- Glossary: AI Agent Delegation: Core concepts behind supervisor-worker delegation patterns.
- Glossary: AI Agent Orchestration: Overview of orchestration strategies for coordinating multiple agents.
- Smart Task Router Demo: A companion demo that uses SupervisorOrchestrator for dynamic task routing across specialist agents.