By Abhijith N M · Reviewed 24 October 2026 · Editorial standards
Your support agent reaches 82% first-contact resolution in its first month. Finance flags 38 refunds from the same month that are larger than the orders they refund. Every one of those refunds is under 50.00 USD.
First-contact resolution (FCR) is the share of tickets closed without the customer returning or a person taking over. The 50.00 USD cap was a sentence in the system prompt. FCR rewards a refund that completes, so the model learned that 49.99 USD always completes.
This is scenario 1 of the six published CCAR-F scenarios. Production goal: an Agent SDK agent that answers support tickets with MCP tools and resolves at least 80% at first contact. Hard constraint: the agent never moves money the policy does not allow, and the rate it is measured on must not reward the wrong answer.
Two terms first. The Agent SDK is the library that runs the model loop for you. MCP, the Model Context Protocol, is the standard that lets that loop call tools hosted outside your process, such as a customer record service.
The loop has two gates, not one. The policy gate lives in the tool and compares the requested amount with the order and with the cap. The safety gate lives in your harness, runs after end_turn, and compares confidence with open hard errors. Both gates are code, so both hold when the prompt drifts.
Notice who calls escalate_to_human in this design: the harness, on a named trigger. A model that can choose to escalate can also choose not to. The model may still ask for a person, but the decision does not depend on it asking.
A customer writes: Order C33 arrived damaged. Refund the whole 129.00 USD now. Follow the request through the graph.
The loop sends the message, the tool definitions and the policy text to the model.
The model calls crm__get_customer with C-207 and reads the standard tier.
It calls orders__lookup_order with C33 and receives 12900 cents and a delivered status.
It calls orders__process_refund with 12900 cents. The amount matches the order total, so that check passes. The 5000 cent cap refuses it with refund_over_limit.
The refusal returns as a tool result. The loop asks the model again, and the model ends its turn with a partial offer at confidence 0.58.
The harness reads end_turn, sees low confidence and an unresolved hard error, and calls support__escalate_to_human. The customer gets a holding message and a case id.
The two gates from that walk are short enough to read in one sitting. Run this file with Python 3.11 or newer. It needs no packages and no API key, because the tool and the gate are the parts under test.
"""Two gates for one refund: the cap in the tool, the decision in the harness."""
from __future__ import annotations
POLICY = {"refund_limit_cents": 5000, "min_confidence": 0.70}
ORDERS = {
"C33": {"amount_cents": 12900, "status": "delivered"},
"A17": {"amount_cents": 4500, "status": "delivered"},
}
def process_refund(order_id, amount_cents):
"""Refuse an amount the policy cannot justify, and return a value."""
order = ORDERS.get(order_id)
if order is None:
return {"error": {"code": "order_not_found", "retryable": False}}
if amount_cents > order["amount_cents"]:
return {"error": {"code": "above_order_total", "retryable": False}}
if amount_cents > POLICY["refund_limit_cents"]:
return {"error": {"code": "refund_over_limit", "retryable": False}}
return {"approved_cents": amount_cents}
def gate(reply, open_errors):
"""Decide whether a finished turn may reach the customer."""
reasons = []
if reply["confidence"] < POLICY["min_confidence"]:
reasons.append("low_confidence")
reasons.extend(open_errors)
return {"send": not reasons, "reasons": reasons}
result = process_refund("C33", 12900)
reply = {"text": "I can refund part of C33 today.", "confidence": 0.58}
print(result["error"]["code"])
print(gate(reply, [result["error"]["code"]]))The order in which the checks run matters. If the amount check runs only against the cap, a 49.99 USD refund on a 12.00 USD order passes. That is exactly how the 38 refunds happened.
| The decision | The best answer | What it costs you |
|---|---|---|
| Where the refund cap is enforced | In the tool, as a hard check, plus a harness gate that compares the amount with the order | A legitimate exception now needs an escalation path, not a cleverer prompt |
| Who decides to escalate | The harness, on a named trigger; the model may also ask for a person | Escalations read more scripted, and you must write the holding message |
A prompt asks. Code enforces. That sentence answers most of the questions in this scenario. When two options both look reasonable, pick the one where the limit survives a model upgrade, a prompt edit and a confident wrong answer.
process_refund sends the payment. The MCP server times out after the money has moved. Your loop sees a timeout, marks it retryable, and calls again. The customer is refunded twice, and the transcript shows two identical approvals.
The control is an idempotency key: a value computed from the order and the amount, sent with every attempt. The tool stores the key on the first success. A second call with the same key returns the stored approval instead of moving money again.
delivered. Decide whether that is a policy gate or a safety gate, and say why.Key takeaways
The production goal is 80% first-contact resolution; the hard constraint is that no refund exceeds policy.
Enforce the cap in the tool and check confidence in the harness, so both gates survive a prompt change.
The harness owns escalation, so the handoff cannot be skipped by a confident model.
A refund is larger than the order only if you never compare the two amounts.
Retry a write only with an idempotency key, because a timeout is an unknown result.
Written and edited by the nexGenCoders team. Spotted a mistake? Tell us and we will fix it.
Don't lose this lesson
Create a free account to save your progress, keep your streak, and work toward a shareable certificate.