Table of Contents

πŸ‘‰ 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 SupervisorOrchestrator for coordinating specialist agents.
  • Create multiple worker agents with focused personas using Agent.CreateBuilder().
  • Use streaming execution with RunStreamingAsync() for real-time output.
  • Handle different OrchestrationStreamTokenType values 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 sample for 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.
  • 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:

  1. Select a model from the menu, or paste a custom model URI.
  2. Wait for the model to download (first run) and load.
  3. Type sample for a built-in email, or paste your own email (end with empty line).
  4. Watch the supervisor delegate to each specialist in real time.
  5. Receive classification, extraction, and draft response.
  6. Type quit to 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

Share