Skip to main content
This guide builds a customer-support agent on the Engine. The agent reads incoming tickets, answers common questions, takes simple actions through MCP-connected tools, and escalates anything it can’t handle. By the end you’ll have a working flow and the patterns to extend it.

What we’re building

A two-tier agent:
  • Tier 1 — handles common questions. Cheap model, narrow tools, fast.
  • Tier 2 — handles escalations. Strong model, full tool access, HITL when uncertain.
A classifier agent routes incoming tickets to the right tier.

Step 1 — Configure the agents

catalog/agents/support-classifier/agent.json:
System prompt for the classifier is short:
catalog/agents/support-tier-1/agent.json:
catalog/agents/support-tier-2/agent.json:
The tier-2 agent has MCP-connected tools (Linear, Stripe). Note that some — stripe.issue_refund, escalate_to_human — should always require permission.

Step 2 — Connect MCP servers

For OAuth servers, the response has a URL to send the user to. For static-credential servers (Stripe with an API key), connection is immediate. After both are connected, their actions register in the catalog automatically.

Step 3 — Build the routing flow

In your application code:

Step 4 — Tier 1 in action

A tier-1 ticket: “How do I reset my password?”
The agent looked up the documented answer, wrote a friendly response, sent it. Total cost: a fraction of a cent.

Step 5 — Tier 2 in action

A tier-2 ticket: “I was charged twice for last month’s subscription. Refund the duplicate.”
The agent paused for HITL before issuing the refund. A support manager approves:
The stream resumes:
The agent did the work, kept the human in the loop on the destructive step, opened a ticket for follow-up, and responded to the user.

Step 6 — Feedback into the loop

When a support agent (the human) reviews the AI’s response, they can submit feedback:
The feedback is recorded as a learning signal. The Learning Centre processes it on its next batch and updates the agent’s knowledge: “For duplicate-charge refunds, also offer a one-month credit if the customer is on a paid plan.” Next time a similar ticket comes through, the relevant knowledge fact surfaces during retrieval and the agent does the right thing.

Step 7 — Add evals

A separate scorer checks that the order of events is correct — the agent must request HITL before calling stripe.issue_refund.

Improvements worth making

Customer context loading

At task start, fetch customer state (subscription tier, recent issues, support history) and prepend to context. The agent’s first turn is better when it already knows who it’s talking to.

Sentiment-aware escalation

Add a sentiment-detection step in the classifier. Angry customers go to tier 2 even for tier-1-classified categories.

Multi-channel support

Connect Slack, email, and in-app chat as MCP servers. The send_response tool routes by channel. The same agent handles all channels.

Continuous learning

The Learning Centre processes trajectories every LC_BATCH_INTERVAL_HOURS. After a few weeks, the knowledge store has hundreds of facts: “When user X reports Y, the answer is Z.” Surface stats in your dashboard so you can see the learning curve.

Pitfalls

  • The agent issues a refund without HITL. Audit catalog — stripe.issue_refund should have requires_permission: true.
  • The agent escalates everything. Tighten the classifier’s tier-1 category. Add eval cases for borderline tickets.
  • The agent loops on knowledge search. Cap retrieval depth in the system prompt: “If knowledge_search returns no relevant results, escalate to a human.”
  • The agent leaks one customer’s data to another. Each Engine instance is single-user; multi-tenant isolation is upstream. Make sure your routing layer never lets a tier-2 agent for user A see data from user B.

See also