The Triage Agent
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
The Triage Agent serves as the primary entry point for all inbound messages within the BrightPath AI Operations system. Its fundamental role is to act as a classification and routing engine, ensuring that every customer interaction is analyzed for intent, urgency, and sentiment before being directed to a specialized downstream agent. By operating as the first stage of the multi-agent pipeline, it provides the necessary context and metadata required for specialized agents (such as Sales or Customer Service) to process requests efficiently.
Sources: agents/triage_agent.md:3-8, README.md:10-12, app.py:539-548
As part of the broader system architecture, the Triage Agent doesn't just categorize messages; it also performs entity extraction for names and companies and checks persistent memory to identify returning customers. This initial processing stage is critical for maintaining consistency across the BrightPath operations pipeline, allowing for automated handling of routine tasks while flagging high-value opportunities or urgent escalations for human oversight.
Sources: agents/triage_agent.md:10-14, orchestrator.py:249-255
System Architecture and Integration
The Triage Agent is integrated into the system via both a Streamlit web interface and a terminal-based orchestrator. It functions as the first of three logical steps in a message processing pipeline.
Pipeline Flow
The following diagram illustrates how the Triage Agent initiates the operation flow by processing raw inbound messages and passing structured JSON to the next stage.
The Triage Agent receives the raw message along with the current system memory and CRM data to make informed routing decisions.
Sources: app.py:539-555, orchestrator.py:317-345, README.md:10-15
Core Implementation
The agent is implemented as a Claude-powered LLM call using a specialized system prompt defined in Markdown. In app.py and orchestrator.py, the run_triage function assembles this prompt by combining the agent's core instructions with live memory files and CRM data.
def run_triage(message, memory):
system = f"{load_agent('triage_agent')}\n\n--- MEMORY ---\n{memory}\n\n--- CRM ---\n{load_crm()}"
return call_claude(system, f"Inbound message:\n\n{message}")
Sources: app.py:494-496, orchestrator.py:238-247
Data Processing and Logic
The Triage Agent applies a specific set of rules to categorize data into structured fields. It is strictly required to output valid JSON for programmatic consumption by the orchestrator.py or app.py logic.
Classification Categories
The agent assigns messages to one of five primary categories which determine the subsequent routing:
| Category | Description |
|---|---|
sales | New leads, pricing inquiries, corporate training, callback requests. |
customer_service | Booking changes, complaints, refunds, invoices, FAQs. |
escalation | Angry customers, legal threats, safeguarding, repeated complaints. |
admin | Internal requests, manager commands, reporting requests. |
complex | Messages containing multiple categories. |
Sources: agents/triage_agent.md:16-21
Priority and Sentiment Detection
The agent assesses the emotional state and time-sensitivity of the message using defined levels:
- Urgency: Classified as
high(deadlines, angry tone, VIPs),medium(week-long window), orlow(general info). - Sentiment: Classified as
positive,neutral,negative, orhostile.
Logic Rule: If sentiment is detected as hostile, the agent is instructed to automatically set the urgency level to high.
Sources: agents/triage_agent.md:23-35, agents/triage_agent.md:52
Extraction and Flagging
The agent extracts customer_name and company_name and applies specific "flags" that trigger specialized UI elements or database logs in the dashboard.
- High Value: If a company size of 10+ people is mentioned, it is flagged as a potential high-value lead.
- Competitor Awareness: Mention of a competitor triggers the
competitor_mentionflag. - Other Flags: Includes
vip,duplicate_lead,upsell_opportunity, andpolicy_exception_needed.
Sources: agents/triage_agent.md:46-56, app.py:557-560
Output Schema
The Triage Agent's response must strictly follow a JSON format. This structure is used to update the events table in the SQLite database and to determine which specialist agent is invoked next.
{
"category": "sales|customer_service|escalation|admin|complex",
"sub_categories": ["list if complex"],
"urgency": "high|medium|low",
"sentiment": "positive|neutral|negative|hostile",
"customer_name": "extracted name or null",
"company_name": "extracted company or null",
"key_request": "one sentence summary of what they want",
"next_agent": "sales_agent|customer_service_agent|manager_briefing_agent",
"flags": ["vip", "duplicate_lead", "upsell_opportunity"],
"triage_notes": "brief notes for the next agent"
}
Sources: agents/triage_agent.md:37-50, app.py:276-285, orchestrator.py:76-85
Memory Interaction
The Triage Agent is "memory-aware." During its execution, it checks customer_history.md and crm.json. If a customer is identified in memory, the agent notes their history in the triage_notes field. This allows the system to handle complex scenarios like repeat complaints (Scenario 11) or duplicate leads from the same company (Scenario 16).
Sources: agents/triage_agent.md:55-56, scenarios.py:58-61, memory_utils.py:157-166
Conclusion
The Triage Agent is the intelligence layer that governs the flow of the BrightPath AI Operations system. By transforming unstructured inbound communication into a strictly defined JSON metadata object, it enables the system to scale its response logic, prioritize high-value clients, and maintain a consistent corporate tone across different specialized departments. Its ability to reconcile inbound messages with historical memory ensures that BrightPath provides a personalized and contextually aware service to its customers.
Sources: README.md:10-12, app.py:550-570