











This question is not about writing code, but about determining when to stop the Agent.
Customer Support Resolution Agent is one of the six scenarios in the CCA-F (Claude Certified Architect Foundations) exam and the scenario with the highest frequency. It connects all five knowledge areas for testing: Agenda loop, MCP tool integration, upgrade logic, context management, and Human-in-the-loop.
Main idea of the original title:
Customer Support Resolution Agent
Design a customer service Agent to handle user inquiries, solve problems, and upgrade to manual personnel in complex situations. Assessment points: Agent SDK, MCP tools, escalation logic.
Many people answer this question in the same place: focus on "how to get agents to solve problems" and ignoreHow to let agents know they should upgrade。The core of CCA-F's scoring is precisely the latter. Below, click the exam points in Exam Guide to break them down layer by layer.
Compared with the five major knowledge domain weights of Exam Guide, the score distribution for this question is roughly:
| test sites | Corresponding Domain | weight | Points for this question |
|---|---|---|---|
| Agentic loop design | Domain 1 (27%) | high | core |
| Tool interfaces and boundaries | Domain 2 (18%) | 高 | 核心 |
| 何时升级人工 | Domain 1 + 5 | 高 | 拉分项 |
| MCP server 集成 | Domain 2 | 中 | 区分项 |
| 上下文与会话状态 | Domain 5 (15%) | 中 | 加分项 |
| Human-in-the-loop | Domain 5 | in | plus item |
Exam Guide's exact words for this scenario are: Agents mustKnow when to use tools and when to upgrade to humans(knows when to use a tool versus when to escalate to a human)。Note that it is "versus"-this is an alternative judgment, not the default process of "try the tool first and then upgrade".
There are three clear escalation triggers, which are listed in the Exam Guide:
Remember these three, they must be explicitly implemented in the code and cannot be judged by the model itself.
The core of customer service Agent is aAutonomous execution cycle: Understand user intent → select tool → execute → observe results → decide next step (continue/upgrade/complete). Implementing this cycle with the Claude Agent SDK is the core assessment point of Domain 1.
There are two principles emphasized in Exam Guide when designing loops:
First, the cycle must have clear termination conditions。It cannot be an infinite loop of "trying until success". Each round requires the maximum number of attempts, and if you exceed it, you will upgrade. Infinite loop is the number one production accident in Agent systems.
Second, tool calls must be observable and interceptable。The Agent SDK's hooks mechanism allows you to insert logic before and after each tool call-logging, auditing, and forcing parameter verification. Customer service scenarios involve sensitive operations such as refunds and account changes and must be auditable.
from claude_agent_sdk import Agent, tool
# 客服 Agent 的 agentic loop
@tool
def check_order_status(order_id: str) -> dict:
"""Check the status of a customer order.
Use when: customer asks about order status, shipping, or delivery.
Do NOT use when: customer wants to cancel (use cancel_order instead).
"""
# 查订单系统(通常通过 MCP server 暴露)
return {"order_id": order_id, "status": "shipped", "eta": "2 days"}
@tool
def issue_refund(order_id: str, amount: float) -> dict:
"""Issue a refund for an order.
Use when: customer requests a refund AND amount <= 50.0.
HARD LIMIT: refuses any refund above $50 automatically.
For amounts above $50, the agent MUST escalate to human.
"""
if amount > 50.0:
return {"error": "REFUND_LIMIT_EXCEEDED", "max_auto": 50.0}
# 执行退款
return {"order_id": order_id, "refunded": amount, "status": "done"}
@tool
def escalate_to_human(reason: str, summary: str) -> dict:
"""Hand the conversation to a human agent.
Use when: ANY of these is true:
- policy limit exceeded (e.g. refund > $50)
- customer explicitly requests human
- agent made 3+ attempts without resolution
"""
return {"escalated": True, "ticket_id": "TKT-7821", "reason": reason}
agent = Agent(
model="claude-sonnet-4-5",
tools=[check_order_status, issue_refund, escalate_to_human],
max_turns=10, # 明确的循环上限,超过由兜底逻辑处理
)
Pay attention to the docstring for each tool. Exam Guide repeatedly emphasizes that tool descriptions must be clear "when to use"and"When not to use", rather than just writing functions. the above issue_refund It is clearly written amount <= 50.0 Only use it, and upgrade it if it exceeds it-this is the tool boundary.
In the real customer service system, data such as orders, refunds, and accounts are stored in the back-end system, and the Agent uses the MCP(Model Context Protocol)server Visit them. Domain 2 teaches you how to design and integrate these tools.
MERMAID_BLOCK_0
MCP tool design has four key requirements in Exam Guide:
Structured error response。Tool error cannot return an ambiguous string. Instead, a structure with an error category and a retriable flag should be returned. For example, if the refund exceeds the limit, the refund will be returned {"error": "REFUND_LIMIT_EXCEEDED", "max_auto": 50.0, "retryable": false}At a glance, the Agent knows that this is not a temporary failure, but a hard limit, and that it should be upgraded rather than retried.
Tool authority allocation across agents。A customer service Agent should not have the authority to delete an account. The principle of minimum authority-the toolset given to the Agent must accurately match its responsibility boundaries.
Tool descriptions distinguish similar tools。cancel_order and issue_refund Both involve orders, and the trigger conditions must be clearly stated in the description, otherwise the model will be selected incorrectly. In the code above check_order_status It clearly states "Do not use it to cancel orders" to prevent this.
MCP server 集成进 Agent loop。Instead of treating MCP as an independent service, it registers its tools into the tools list of the Agent SDK, allowing the Agent to choose and call them independently in the loop.
This is where this question really gets points. Most people can write loops and tools, but the upgrade logic is vague. Exam Guide wantsExplicit, decidable, with triggersThe upgrade is not a black box like "Agents upgrade if they feel that they can't handle it."
def run_support_loop(agent, user_message: str, history: list):
attempts = 0
MAX_ATTEMPTS = 3 # 无法推进的硬阈值
while attempts < MAX_ATTEMPTS:
result = agent.run(user_message, history=history)
# 触发器 1:客户主动要求人工
if "escalate" in result.tool_calls:
return {"outcome": "escalated", "reason": "customer_request"}
# 触发器 2:策略上限超出(工具返回硬限制错误)
for call in result.tool_calls:
if call.result.get("error") == "REFUND_LIMIT_EXCEEDED":
agent.run_tool(escalate_to_human,
reason="refund_limit_exceeded",
summary=result.summary)
return {"outcome": "escalated", "reason": "policy_limit"}
# 触发器 3:问题已解决
if result.is_complete:
return {"outcome": "resolved", "answer": result.answer}
attempts += 1
history.append(result)
# 触发器 4:达到最大尝试次数仍无进展
agent.run_tool(escalate_to_human,
reason="max_attempts_exceeded",
summary="Agent tried 3 times without resolution")
return {"outcome": "escalated", "reason": "no_progress"}
This code explicitly implements all three upgrade triggers in Exam Guide, plus a "maximum attempt" indication. The examiner saw thisDeterministic upgrade logic, it will determine that you understand the limits of an Agent-this is the watershed where the CCA-F wants to distinguish between "being able to use tools" and "being able to design security systems."
There are two more details not to lose points when upgrading:
Upgrade requires a contextual summary。put escalate_to_human the summary Parameters are filled-previous conversations, solutions tried, why they failed. There is no need to ask the customer again when taking over manually. This is about Domain 5 context management.
Upgrade is a final state, not a branch。Once you decide to upgrade, the Agent should not continue to try. After the upgrade, loop must be terminated and control must be completely handed over to humans. Many people write "Keep running while upgrading", which is wrong.
Combine the three layers to create a complete skeleton of customer service Agent that conforms to the CCA-F standard:
from claude_agent_sdk import Agent, tool, hook
SYSTEM_PROMPT = """You are a customer support agent.
Resolve customer issues using the provided tools.
You MUST escalate to a human when:
1. A refund request exceeds $50 (policy limit)
2. The customer explicitly asks for a human agent
3. You cannot resolve the issue after 3 attempts
Never attempt workarounds for policy limits. Never promise
refunds above $50 without human approval."""
@hook(event="before_tool_call")
def audit_sensitive_calls(call):
"""Log every refund and account change for compliance audit."""
if call.tool_name in ("issue_refund", "update_account"):
audit_log.record(call.tool_name, call.params, call.timestamp)
return call # 放行
agent = Agent(
model="claude-sonnet-4-5",
system_prompt=SYSTEM_PROMPT,
tools=[
check_order_status, # MCP: order system
issue_refund, # MCP: billing, $50 hard limit
update_account, # MCP: CRM, scoped permissions
escalate_to_human, # native: human queue
],
hooks=[audit_sensitive_calls],
max_turns=10,
)
# 运行时
result = run_support_loop(agent, user_message, history=[])
Four noteworthy designs:
Write dead upgrade rules in system prompt。Instead of expecting the model to infer from the tool description, it uses system prompts to clearly inform the three upgrade rules. This is the test point of Domain 4 (Prompt Engineering)-high-risk judgments must be solidified in system prompt.
hook conducts compliance audits。For operations such as refunds and account modifications, an audit log is recorded for each call. This is standard for enterprise-level Agents, and Exam Guide emphasizes observability in Domain 5 (Reliability).
Mixed tool sources。check_order_status From MCP server (accessing backend systems),escalate_to_human is a native tool (a queue built into the Agent SDK). The mixed source is a real scene, and the test is your understanding of the boundary between MCP and native tool.
max_turns as the last line of defense。Even if the upgrade logic has a bug, the loop will not run endlessly. This is defensive design-any Agent system should have a hard upper limit.
Trap 1: Write upgrades as "last resort"。The error is "Agent tries its best to solve it first, and then upgrades it if it is really impossible." The correct way to write it is to upgrade with a clear trigger, and upgrade immediately after hitting the trigger, regardless of order. Refunds exceeding $50 are not a "last resort" but the "first response."
Trap 2: Tools have no hard boundaries。The wrong thing is to let issue_refund Accept any amount and rely on system prompt to remind the model not to refund too much. The correct way is to verify the tool internally, and an error will be returned directly if the limit is exceeded. Models make mistakes, code does not.
Trap 3: Upgrade without context。The wrong way to do this is to just pass a reason string. The right thing to do is to bring a complete summary-customer issues, solutions tried, reasons for failure. The examiner is looking to see if you understand the cost of "taking over manually".
Design a customer service Agent based on the Claude Agent SDK, integrating MCP tools into the agency loop to access the order/billing/CRM system; each tool has clear usage boundaries and hard quotas (For example, the $50 limit for refunds); three types of upgrade triggers are explicitly implemented-the policy limit exceeds, the customer proactively requests, and the inability to advance-the loop is terminated when hit and transferred to manual with a context summary; sensitive operations are subject to compliance audit through hooks, and the max_turns hard upper limit is set as the last resort of defense.
Remember this passage and the code skeleton above, and this scene question is basically stable. The core is not how beautiful the code is, but to let the examiner see youUnderstand where the boundaries of Agent capabilities are and how to use deterministic logic to defend that boundary。
To prepare for CCA-F, have you mastered the upgrade logic of this customer service Agent scenario question? Tell me your solution in the comment area, and I will answer any questions. If you think it is useful, just like it so that more people who prepare for the exam can see it.
author: itech001
source: Public Account: AI Artificial Intelligence Era
website: _ _ JHSNS _ URL _ 0 _ _
Share the most cutting-edge AI news and technical research every day.
This article was first published in the era of AI artificial intelligence. Please indicate the source for reprinting.
This content is automatically aggregated by InertiaRSS (RSS Reader) for reading reference only. Original from — Copyright belongs to the original author.