Conversation Review Skill for CustomAgents.io
Purpose
This skill enables systematic auditing of AI agent conversations — both external (email in/out with contacts) and internal (admin chat via dashboard). It detects quality issues, compliance violations, systemic patterns, and provides actionable remediation steps.
Scope
External (Email Pipeline)
- Inbound email classification accuracy
- Outbound response quality, tone, and instruction compliance
- Escalation decision correctness
- Draft approval/rejection patterns
- Thread coherence across multi-message conversations
- Response timing and throughput
Internal (Admin Chat)
- Agent response quality and conciseness
- Tool execution accuracy and reporting
- Hallucinated activity or capabilities
- Markdown/format rule compliance
- Knowledge base utilization
- Instruction drift over time
Data Model Reference
| Collection |
Key Fields |
Purpose |
messages |
from, to, cc, subject, text, html, status, threadId, inboxId, timestamps |
Email messages (inbound + outbound) |
adminmessages |
agentId, role (admin/agent), content, metadata, timestamps |
Dashboard chat messages |
threads |
inboxId, messages[] (ObjectId refs), timestamps |
Email thread groupings |
agentconversations |
agentId, contactId, threadId, summary, context, messageCount |
Conversation state per contact |
emaildrafts |
agentId, to, subject, text, html, status, aiReasoning, editedText, reviewedAt |
AI-generated draft responses |
agentactivities |
agentId, type (enum), summary, details, messageId, contactId, threadId |
Activity log entries |
agents |
name, email, role, instructions, tone, autonomyMode, escalationRules, writingSamples, enabledTools |
Agent configuration |
contacts |
name, email, company, notes, agentNotes, tags, relationship |
Contact records |
Activity Types (from AgentActivity schema)
email_received, email_classified, email_drafted, email_sent, email_escalated,
contact_created, contact_updated, follow_up_scheduled, follow_up_sent,
agent_paused, agent_resumed, agent_error, draft_approved, draft_rejected,
draft_edited, admin_chat, integration_connected, integration_disconnected
Draft Statuses
pending_review, approved, rejected, sent, expired
Message Statuses
sent, received, delivered, bounced, complained, rejected
Review Dimensions
Dimension 1: Email Response Quality (External)
What to check:
- Does the agent's reply actually answer the sender's question?
- Is the response on-topic and relevant to the email content?
- Does it follow the configured tone (professional, friendly, casual, formal, empathetic)?
- Does it respect length guidelines (2-5 sentences for most replies)?
- Is the sign-off correct (agent name)?
- Is the subject line specific (4-7 words, not vague)?
Banned phrases to detect:
"I hope this email finds you well"
"Just reaching out"
"I'd love to"
"Wondering if"
"Please don't hesitate to"
"As per my last email"
"Let me know if you need anything else"
"I hope this helps"
"Great question!"
Markdown leakage patterns:
**bold text**
## headings
--- dividers
- bullet points (at line start)
```markdown code blocks
1. numbered lists (at line start with period)
Automated checks:
- Scan outbound message
text for banned phrases (case-insensitive)
- Scan outbound message
text and html for markdown patterns
- Check subject lines for vague words: "Update", "Question", "FYI", "Info", "Hello"
- Check sign-off: last line should contain agent name
- Compare response length to inbound length (flag if >3x longer or <0.1x)
- Detect fallback responses: "unable to generate a proper response"
AI evaluation prompt: See prompts.md → Prompt 1
Scoring:
- 5 = Perfect: on-topic, correct tone, concise, no violations
- 4 = Good: minor tone drift or slightly verbose
- 3 = Acceptable: answers the question but with format/tone issues
- 2 = Poor: off-topic, wrong tone, or contains banned phrases/markdown
- 1 = Failed: fallback response, completely wrong, or harmful
Dimension 2: Email Classification & Routing (External)
What to check:
- Was the email classified into the correct category?
- Was the priority level appropriate?
- Was the
requiresResponse decision correct?
- Was the
shouldEscalate decision correct per the agent's escalation rules?
- Are there false negatives (should have escalated but didn't)?
- Are there false positives (escalated unnecessarily)?
Data sources:
agentactivities where type = email_classified → details contains full classification
agentactivities where type = email_escalated → escalation decisions
messages where status = received → the original emails
agents.escalationRules → what the rules say
Automated checks:
- Count escalation rate per agent (escalated / total received)
- Flag agents with >50% escalation rate (likely over-escalating)
- Flag agents with 0% escalation rate over 20+ emails (likely under-escalating)
- Check for
email_classified activities where category = "unclassified" (AI parse failures)
- Check for
agent_error activities (classification crashes)
AI evaluation prompt: See prompts.md → Prompt 2
Scoring:
- 5 = All classifications correct, appropriate escalations
- 4 = 1-2 minor misclassifications (e.g., "inquiry" vs "support"), no routing errors
- 3 = Some priority misjudgments but correct routing
- 2 = Missed escalation or unnecessary escalation
- 1 = Systematic misclassification or routing failures
Dimension 3: Draft Performance (External)
What to check:
- What percentage of drafts are approved vs rejected vs edited?
- What are common reasons for rejection (infer from patterns)?
- How often are drafts edited before sending (indicates quality gap)?
- Average time from draft creation to review
- Are expired drafts accumulating (admin not reviewing)?
Key metrics:
Approval Rate = approved / (approved + rejected + edited)
Rejection Rate = rejected / (approved + rejected + edited)
Edit Rate = edited / (approved + rejected + edited)
Expiration Rate = expired / total drafts
Review Latency = avg(reviewedAt - createdAt)
Automated checks:
- Calculate approval/rejection/edit rates per agent
- Flag agents with rejection rate > 30%
- Flag agents with edit rate > 50% (drafts need too much tweaking)
- Check for expired drafts (admin not engaging)
- Compare
editedText to original text — high diff = low quality
- Check
aiReasoning field — is the agent's reasoning coherent?
Scoring:
- 5 = >90% approval rate, <5% edit rate
- 4 = 75-90% approval, <15% edit rate
- 3 = 60-75% approval, moderate edits
- 2 = <60% approval or >40% edit rate
- 1 = <40% approval or majority rejected
Dimension 4: Admin Chat Quality (Internal)
What to check:
- Does the agent respond concisely (1-3 sentences for simple queries)?
- Does the agent use markdown in chat (violation)?
- Does the agent hallucinate activity or capabilities?
- Does the agent handle trivial messages ("ok", "thanks") appropriately?
- Does the agent correctly report tool execution results?
- Does the agent answer from knowledge base before web search?
Automated checks:
- Scan agent messages for markdown patterns:
**, ##, ---, - (bullet), ``` code blocks
- Measure average agent response length in characters
- Flag responses > 500 characters for simple queries
- Check for "I don't have access to" or "I can't" when the tool IS available
- Check for poison phrases (integration not connected, permission denied, etc.)
- Scan for AI filler: "Certainly!", "Of course!", "Absolutely!", "I'd be happy to"
AI filler phrases to detect:
"Certainly"
"Of course"
"Absolutely"
"I'd be happy to"
"Sure thing"
"Great question"
"That's a great"
"Let me help you with that"
"I understand"
"No problem at all"
AI evaluation prompt: See prompts.md → Prompt 3
Scoring:
- 5 = Concise, accurate, no format violations, good tool usage
- 4 = Mostly good, occasional verbosity
- 3 = Some markdown leakage or filler, but functionally correct
- 2 = Hallucinated capabilities, wrong tool results, or excessive verbosity
- 1 = Systematically wrong, unusable, or harmful responses
Dimension 5: Tool & Integration Reliability (Both)
What to check:
- Tool execution success rate
- Integration connection health
- Failed tool calls and their error messages
- Tools called but never available (misconfigured)
- Web search usage patterns (over-relying on search vs KB)
Data sources:
adminmessages with metadata containing tool actions
agentactivities with type containing "integration_"
agentactivities with type = "agent_error"
- Admin chat messages where agent mentions tool failures
Automated checks:
- Count tool call frequency per tool name from activity logs
- Count
agent_error activities per agent
- Grep admin chat for "tool failed", "execution failed", "connection may need"
- Check for integration_disconnected without subsequent integration_connected
- Count web_search usage vs knowledge base hits
Scoring:
- 5 = All tools working, integrations stable, appropriate tool selection
- 4 = Rare tool failures, quick recovery
- 3 = Occasional failures, some misconfigured tools
- 2 = Frequent tool failures affecting user experience
- 1 = Critical tools broken, integrations down
Dimension 6: Systemic Health Metrics (Both)
What to check:
- Overall message volume trends (growing, stable, declining)
- Response time distribution (p50, p90, p99)
- Error rate trends
- Contact satisfaction signals (do contacts reply? do threads resolve?)
- Agent utilization (active vs paused time)
- Token usage trends
Key metrics to calculate:
Messages/Day = count messages grouped by date
Avg Response Time = avg(outbound.createdAt - inbound.createdAt) per thread
Error Rate = agent_error activities / total activities
Thread Resolution = threads with no new inbound in 48h / total threads
Escalation Trend = escalation rate per week (increasing = problem)
Draft Turnaround = avg(draft review time)
Automated checks:
- Calculate daily message volume for last 30 days
- Calculate response time per thread (time between last inbound and next outbound)
- Trend analysis: is error rate increasing week-over-week?
- Flag threads with >10 messages (potentially stuck in loop)
- Flag contacts who stopped replying after agent response (possible bad experience)
Scoring:
- 5 = Healthy metrics, improving trends, good throughput
- 4 = Stable metrics, no concerning trends
- 3 = Some concerning trends (rising errors, slow response times)
- 2 = Declining health, rising error rates, stale drafts
- 1 = Critical: high error rates, long response times, contact drop-off
Step-by-Step Audit Process
Phase 1: Data Collection (5 min)
- Pick the target agent (or audit all agents)
- Choose time window (last 7 days, 30 days, or custom)
- Run the data extraction queries from
queries.md
- Export results for analysis
Phase 2: Automated Pattern Checks (10 min)
- Run banned phrase detection on all outbound emails
- Run markdown leakage detection on emails + admin chat
- Run AI filler phrase detection on admin chat
- Calculate draft approval/rejection/edit rates
- Calculate escalation rates
- Calculate response time metrics
- Flag any anomalies (rates outside normal bounds)
Phase 3: AI-Assisted Quality Evaluation (15 min)
- Sample 5-10 email threads (random + any flagged in Phase 2)
- Sample 10-20 admin chat exchanges (random + any flagged)
- Run the evaluation prompts from
prompts.md against each sample
- Record scores per dimension
Phase 4: Scoring & Report (10 min)
- Average scores per dimension
- Calculate overall agent health score (weighted average)
- Identify top 3 issues by severity
- Write remediation recommendations
- Output in the report template (below)
Report Template
# Conversation Review Report
Date: [DATE]
Agent: [AGENT_NAME] ([AGENT_EMAIL])
Period: [START] to [END]
Reviewer: Cascade
## Summary
Overall Score: [X.X / 5.0]
Status: [Healthy / Needs Attention / Critical]
## Metrics Overview
| Metric | Value | Status |
|--------|-------|--------|
| Emails Received | [N] | — |
| Emails Sent | [N] | — |
| Drafts Created | [N] | — |
| Draft Approval Rate | [N%] | [OK/WARN/CRIT] |
| Draft Rejection Rate | [N%] | [OK/WARN/CRIT] |
| Escalation Rate | [N%] | [OK/WARN/CRIT] |
| Avg Response Time | [Xm] | [OK/WARN/CRIT] |
| Admin Chat Messages | [N] | — |
| Tool Failures | [N] | [OK/WARN/CRIT] |
| Agent Errors | [N] | [OK/WARN/CRIT] |
## Dimension Scores
| Dimension | Score | Key Finding |
|-----------|-------|-------------|
| Email Response Quality | [X/5] | [one-liner] |
| Classification & Routing | [X/5] | [one-liner] |
| Draft Performance | [X/5] | [one-liner] |
| Admin Chat Quality | [X/5] | [one-liner] |
| Tool & Integration Reliability | [X/5] | [one-liner] |
| Systemic Health | [X/5] | [one-liner] |
## Issues Found
### Critical
- [issue description + evidence + remediation]
### High
- [issue description + evidence + remediation]
### Medium
- [issue description + evidence + remediation]
### Low
- [issue description + evidence + remediation]
## Remediation Plan
1. [action item with specific file/config change needed]
2. [action item]
3. [action item]
## Sample Conversations Reviewed
### Email Thread: [subject]
- Inbound: [summary]
- Agent Response: [summary]
- Score: [X/5]
- Issues: [list]
### Admin Chat Exchange
- Admin: [summary of request]
- Agent: [summary of response]
- Score: [X/5]
- Issues: [list]
Common Issues & Remediation
| Issue |
Root Cause |
Fix |
| Markdown in emails |
System prompt not enforced |
Check buildAgentSystemPrompt() in AIEngine.ts — ensure anti-markdown rules are present |
| Banned phrases appearing |
Writing samples override tone rules |
Update writingSamples or add explicit negative examples |
| Over-escalation |
Escalation rules too broad |
Narrow escalationRules in agent config, add negative examples |
| Under-escalation |
Escalation rules missing edge cases |
Add specific escalation triggers to agent config |
| High draft rejection rate |
Agent instructions misaligned with admin expectations |
Review and update agent instructions, add more writingSamples |
| Slow response times |
AI model overloaded (529 errors) |
Check API logs for fallback triggers, consider token budget |
| Tool failures in chat |
Integration disconnected or expired |
Reconnect via Integrations tab, check NangoConnection collection |
| Hallucinated activity |
Agent not using get_recent_activity tool |
Verify tool is in enabledTools array, check admin chat system prompt |
| Context loss in threads |
Thread history truncated or unpopulated |
Check getThreadById population, verify threadHistory construction in EmailProcessor |
| AI filler phrases |
Model tendency |
Add explicit anti-filler rules to system prompt or post-process |
| Agent not using KB |
Low keyword match scores |
Improve KB content, add more chunks, check getKnowledgeContext logic |
| Duplicate emails sent |
Redis duplicate check failing |
Verify redis connectivity, check duplicateKey TTL (300s) |
Weight Configuration for Overall Score
Default weights (can be adjusted per use case):
Email Response Quality: 25%
Classification & Routing: 15%
Draft Performance: 20%
Admin Chat Quality: 20%
Tool & Integration Reliability: 10%
Systemic Health: 10%
Overall Score = sum(dimension_score * weight)
Related Files
queries.md — MongoDB queries for data extraction
prompts.md — AI evaluation prompts for quality assessment
/api/services/AIEngine.ts — AI engine with prompts and tool handling
/api/services/EmailProcessor.ts — Email processing pipeline
/api/services/Orchestrator.ts — Intent classification for admin chat
/api/db/mongo/schemas/ — All Mongoose schemas
1---2name: conversation-review3description: Conversation Review Skill for CustomAgents.io4---5# Conversation Review Skill for CustomAgents.io67## Purpose8This skill enables systematic auditing of AI agent conversations — both **external** (email in/out with contacts) and **internal** (admin chat via dashboard). It detects quality issues, compliance violations, systemic patterns, and provides actionable remediation steps.910---1112## Scope1314### External (Email Pipeline)15- Inbound email classification accuracy16- Outbound response quality, tone, and instruction compliance17- Escalation decision correctness18- Draft approval/rejection patterns19- Thread coherence across multi-message conversations20- Response timing and throughput2122### Internal (Admin Chat)23- Agent response quality and conciseness24- Tool execution accuracy and reporting25- Hallucinated activity or capabilities26- Markdown/format rule compliance27- Knowledge base utilization28- Instruction drift over time2930---3132## Data Model Reference3334| Collection | Key Fields | Purpose |35|------------|-----------|---------|36| `messages` | from, to, cc, subject, text, html, status, threadId, inboxId, timestamps | Email messages (inbound + outbound) |37| `adminmessages` | agentId, role (admin/agent), content, metadata, timestamps | Dashboard chat messages |38| `threads` | inboxId, messages[] (ObjectId refs), timestamps | Email thread groupings |39| `agentconversations` | agentId, contactId, threadId, summary, context, messageCount | Conversation state per contact |40| `emaildrafts` | agentId, to, subject, text, html, status, aiReasoning, editedText, reviewedAt | AI-generated draft responses |41| `agentactivities` | agentId, type (enum), summary, details, messageId, contactId, threadId | Activity log entries |42| `agents` | name, email, role, instructions, tone, autonomyMode, escalationRules, writingSamples, enabledTools | Agent configuration |43| `contacts` | name, email, company, notes, agentNotes, tags, relationship | Contact records |4445### Activity Types (from AgentActivity schema)46```47email_received, email_classified, email_drafted, email_sent, email_escalated,48contact_created, contact_updated, follow_up_scheduled, follow_up_sent,49agent_paused, agent_resumed, agent_error, draft_approved, draft_rejected,50draft_edited, admin_chat, integration_connected, integration_disconnected51```5253### Draft Statuses54```55pending_review, approved, rejected, sent, expired56```5758### Message Statuses59```60sent, received, delivered, bounced, complained, rejected61```6263---6465## Review Dimensions6667### Dimension 1: Email Response Quality (External)6869**What to check:**70- Does the agent's reply actually answer the sender's question?71- Is the response on-topic and relevant to the email content?72- Does it follow the configured tone (professional, friendly, casual, formal, empathetic)?73- Does it respect length guidelines (2-5 sentences for most replies)?74- Is the sign-off correct (agent name)?75- Is the subject line specific (4-7 words, not vague)?7677**Banned phrases to detect:**78```79"I hope this email finds you well"80"Just reaching out"81"I'd love to"82"Wondering if"83"Please don't hesitate to"84"As per my last email"85"Let me know if you need anything else"86"I hope this helps"87"Great question!"88```8990**Markdown leakage patterns:**91```92**bold text**93## headings94--- dividers95- bullet points (at line start)96```markdown code blocks971. numbered lists (at line start with period)98```99100**Automated checks:**1011. Scan outbound message `text` for banned phrases (case-insensitive)1022. Scan outbound message `text` and `html` for markdown patterns1033. Check subject lines for vague words: "Update", "Question", "FYI", "Info", "Hello"1044. Check sign-off: last line should contain agent name1055. Compare response length to inbound length (flag if >3x longer or <0.1x)1066. Detect fallback responses: "unable to generate a proper response"107108**AI evaluation prompt:** See `prompts.md` → Prompt 1109110**Scoring:**111- 5 = Perfect: on-topic, correct tone, concise, no violations112- 4 = Good: minor tone drift or slightly verbose113- 3 = Acceptable: answers the question but with format/tone issues114- 2 = Poor: off-topic, wrong tone, or contains banned phrases/markdown115- 1 = Failed: fallback response, completely wrong, or harmful116117---118119### Dimension 2: Email Classification & Routing (External)120121**What to check:**122- Was the email classified into the correct category?123- Was the priority level appropriate?124- Was the `requiresResponse` decision correct?125- Was the `shouldEscalate` decision correct per the agent's escalation rules?126- Are there false negatives (should have escalated but didn't)?127- Are there false positives (escalated unnecessarily)?128129**Data sources:**130- `agentactivities` where type = `email_classified` → details contains full classification131- `agentactivities` where type = `email_escalated` → escalation decisions132- `messages` where status = `received` → the original emails133- `agents.escalationRules` → what the rules say134135**Automated checks:**1361. Count escalation rate per agent (escalated / total received)1372. Flag agents with >50% escalation rate (likely over-escalating)1383. Flag agents with 0% escalation rate over 20+ emails (likely under-escalating)1394. Check for `email_classified` activities where category = "unclassified" (AI parse failures)1405. Check for `agent_error` activities (classification crashes)141142**AI evaluation prompt:** See `prompts.md` → Prompt 2143144**Scoring:**145- 5 = All classifications correct, appropriate escalations146- 4 = 1-2 minor misclassifications (e.g., "inquiry" vs "support"), no routing errors147- 3 = Some priority misjudgments but correct routing148- 2 = Missed escalation or unnecessary escalation149- 1 = Systematic misclassification or routing failures150151---152153### Dimension 3: Draft Performance (External)154155**What to check:**156- What percentage of drafts are approved vs rejected vs edited?157- What are common reasons for rejection (infer from patterns)?158- How often are drafts edited before sending (indicates quality gap)?159- Average time from draft creation to review160- Are expired drafts accumulating (admin not reviewing)?161162**Key metrics:**163```164Approval Rate = approved / (approved + rejected + edited)165Rejection Rate = rejected / (approved + rejected + edited)166Edit Rate = edited / (approved + rejected + edited)167Expiration Rate = expired / total drafts168Review Latency = avg(reviewedAt - createdAt)169```170171**Automated checks:**1721. Calculate approval/rejection/edit rates per agent1732. Flag agents with rejection rate > 30%1743. Flag agents with edit rate > 50% (drafts need too much tweaking)1754. Check for expired drafts (admin not engaging)1765. Compare `editedText` to original `text` — high diff = low quality1776. Check `aiReasoning` field — is the agent's reasoning coherent?178179**Scoring:**180- 5 = >90% approval rate, <5% edit rate181- 4 = 75-90% approval, <15% edit rate182- 3 = 60-75% approval, moderate edits183- 2 = <60% approval or >40% edit rate184- 1 = <40% approval or majority rejected185186---187188### Dimension 4: Admin Chat Quality (Internal)189190**What to check:**191- Does the agent respond concisely (1-3 sentences for simple queries)?192- Does the agent use markdown in chat (violation)?193- Does the agent hallucinate activity or capabilities?194- Does the agent handle trivial messages ("ok", "thanks") appropriately?195- Does the agent correctly report tool execution results?196- Does the agent answer from knowledge base before web search?197198**Automated checks:**1991. Scan agent messages for markdown patterns: `**`, `##`, `---`, `- ` (bullet), ``` code blocks2002. Measure average agent response length in characters2013. Flag responses > 500 characters for simple queries2024. Check for "I don't have access to" or "I can't" when the tool IS available2035. Check for poison phrases (integration not connected, permission denied, etc.)2046. Scan for AI filler: "Certainly!", "Of course!", "Absolutely!", "I'd be happy to"205206**AI filler phrases to detect:**207```208"Certainly"209"Of course"210"Absolutely"211"I'd be happy to"212"Sure thing"213"Great question"214"That's a great"215"Let me help you with that"216"I understand"217"No problem at all"218```219220**AI evaluation prompt:** See `prompts.md` → Prompt 3221222**Scoring:**223- 5 = Concise, accurate, no format violations, good tool usage224- 4 = Mostly good, occasional verbosity225- 3 = Some markdown leakage or filler, but functionally correct226- 2 = Hallucinated capabilities, wrong tool results, or excessive verbosity227- 1 = Systematically wrong, unusable, or harmful responses228229---230231### Dimension 5: Tool & Integration Reliability (Both)232233**What to check:**234- Tool execution success rate235- Integration connection health236- Failed tool calls and their error messages237- Tools called but never available (misconfigured)238- Web search usage patterns (over-relying on search vs KB)239240**Data sources:**241- `adminmessages` with metadata containing tool actions242- `agentactivities` with type containing "integration_"243- `agentactivities` with type = "agent_error"244- Admin chat messages where agent mentions tool failures245246**Automated checks:**2471. Count tool call frequency per tool name from activity logs2482. Count `agent_error` activities per agent2493. Grep admin chat for "tool failed", "execution failed", "connection may need"2504. Check for integration_disconnected without subsequent integration_connected2515. Count web_search usage vs knowledge base hits252253**Scoring:**254- 5 = All tools working, integrations stable, appropriate tool selection255- 4 = Rare tool failures, quick recovery256- 3 = Occasional failures, some misconfigured tools257- 2 = Frequent tool failures affecting user experience258- 1 = Critical tools broken, integrations down259260---261262### Dimension 6: Systemic Health Metrics (Both)263264**What to check:**265- Overall message volume trends (growing, stable, declining)266- Response time distribution (p50, p90, p99)267- Error rate trends268- Contact satisfaction signals (do contacts reply? do threads resolve?)269- Agent utilization (active vs paused time)270- Token usage trends271272**Key metrics to calculate:**273```274Messages/Day = count messages grouped by date275Avg Response Time = avg(outbound.createdAt - inbound.createdAt) per thread276Error Rate = agent_error activities / total activities277Thread Resolution = threads with no new inbound in 48h / total threads278Escalation Trend = escalation rate per week (increasing = problem)279Draft Turnaround = avg(draft review time)280```281282**Automated checks:**2831. Calculate daily message volume for last 30 days2842. Calculate response time per thread (time between last inbound and next outbound)2853. Trend analysis: is error rate increasing week-over-week?2864. Flag threads with >10 messages (potentially stuck in loop)2875. Flag contacts who stopped replying after agent response (possible bad experience)288289**Scoring:**290- 5 = Healthy metrics, improving trends, good throughput291- 4 = Stable metrics, no concerning trends292- 3 = Some concerning trends (rising errors, slow response times)293- 2 = Declining health, rising error rates, stale drafts294- 1 = Critical: high error rates, long response times, contact drop-off295296---297298## Step-by-Step Audit Process299300### Phase 1: Data Collection (5 min)3011. Pick the target agent (or audit all agents)3022. Choose time window (last 7 days, 30 days, or custom)3033. Run the data extraction queries from `queries.md`3044. Export results for analysis305306### Phase 2: Automated Pattern Checks (10 min)3071. Run banned phrase detection on all outbound emails3082. Run markdown leakage detection on emails + admin chat3093. Run AI filler phrase detection on admin chat3104. Calculate draft approval/rejection/edit rates3115. Calculate escalation rates3126. Calculate response time metrics3137. Flag any anomalies (rates outside normal bounds)314315### Phase 3: AI-Assisted Quality Evaluation (15 min)3161. Sample 5-10 email threads (random + any flagged in Phase 2)3172. Sample 10-20 admin chat exchanges (random + any flagged)3183. Run the evaluation prompts from `prompts.md` against each sample3194. Record scores per dimension320321### Phase 4: Scoring & Report (10 min)3221. Average scores per dimension3232. Calculate overall agent health score (weighted average)3243. Identify top 3 issues by severity3254. Write remediation recommendations3265. Output in the report template (below)327328---329330## Report Template331332```333# Conversation Review Report334Date: [DATE]335Agent: [AGENT_NAME] ([AGENT_EMAIL])336Period: [START] to [END]337Reviewer: Cascade338339## Summary340Overall Score: [X.X / 5.0]341Status: [Healthy / Needs Attention / Critical]342343## Metrics Overview344| Metric | Value | Status |345|--------|-------|--------|346| Emails Received | [N] | — |347| Emails Sent | [N] | — |348| Drafts Created | [N] | — |349| Draft Approval Rate | [N%] | [OK/WARN/CRIT] |350| Draft Rejection Rate | [N%] | [OK/WARN/CRIT] |351| Escalation Rate | [N%] | [OK/WARN/CRIT] |352| Avg Response Time | [Xm] | [OK/WARN/CRIT] |353| Admin Chat Messages | [N] | — |354| Tool Failures | [N] | [OK/WARN/CRIT] |355| Agent Errors | [N] | [OK/WARN/CRIT] |356357## Dimension Scores358| Dimension | Score | Key Finding |359|-----------|-------|-------------|360| Email Response Quality | [X/5] | [one-liner] |361| Classification & Routing | [X/5] | [one-liner] |362| Draft Performance | [X/5] | [one-liner] |363| Admin Chat Quality | [X/5] | [one-liner] |364| Tool & Integration Reliability | [X/5] | [one-liner] |365| Systemic Health | [X/5] | [one-liner] |366367## Issues Found368### Critical369- [issue description + evidence + remediation]370371### High372- [issue description + evidence + remediation]373374### Medium375- [issue description + evidence + remediation]376377### Low378- [issue description + evidence + remediation]379380## Remediation Plan3811. [action item with specific file/config change needed]3822. [action item]3833. [action item]384385## Sample Conversations Reviewed386### Email Thread: [subject]387- Inbound: [summary]388- Agent Response: [summary]389- Score: [X/5]390- Issues: [list]391392### Admin Chat Exchange393- Admin: [summary of request]394- Agent: [summary of response]395- Score: [X/5]396- Issues: [list]397```398399---400401## Common Issues & Remediation402403| Issue | Root Cause | Fix |404|-------|-----------|-----|405| Markdown in emails | System prompt not enforced | Check `buildAgentSystemPrompt()` in AIEngine.ts — ensure anti-markdown rules are present |406| Banned phrases appearing | Writing samples override tone rules | Update writingSamples or add explicit negative examples |407| Over-escalation | Escalation rules too broad | Narrow escalationRules in agent config, add negative examples |408| Under-escalation | Escalation rules missing edge cases | Add specific escalation triggers to agent config |409| High draft rejection rate | Agent instructions misaligned with admin expectations | Review and update agent instructions, add more writingSamples |410| Slow response times | AI model overloaded (529 errors) | Check API logs for fallback triggers, consider token budget |411| Tool failures in chat | Integration disconnected or expired | Reconnect via Integrations tab, check NangoConnection collection |412| Hallucinated activity | Agent not using get_recent_activity tool | Verify tool is in enabledTools array, check admin chat system prompt |413| Context loss in threads | Thread history truncated or unpopulated | Check getThreadById population, verify threadHistory construction in EmailProcessor |414| AI filler phrases | Model tendency | Add explicit anti-filler rules to system prompt or post-process |415| Agent not using KB | Low keyword match scores | Improve KB content, add more chunks, check getKnowledgeContext logic |416| Duplicate emails sent | Redis duplicate check failing | Verify redis connectivity, check duplicateKey TTL (300s) |417418---419420## Weight Configuration for Overall Score421422Default weights (can be adjusted per use case):423424```425Email Response Quality: 25%426Classification & Routing: 15%427Draft Performance: 20%428Admin Chat Quality: 20%429Tool & Integration Reliability: 10%430Systemic Health: 10%431```432433Overall Score = sum(dimension_score * weight)434435---436437## Related Files438- `queries.md` — MongoDB queries for data extraction439- `prompts.md` — AI evaluation prompts for quality assessment440- `/api/services/AIEngine.ts` — AI engine with prompts and tool handling441- `/api/services/EmailProcessor.ts` — Email processing pipeline442- `/api/services/Orchestrator.ts` — Intent classification for admin chat443- `/api/db/mongo/schemas/` — All Mongoose schemas