Menu
CoddyTech

지원 에스컬레이션

Coddy AI Engineering 여정의 도구와 에이전트 섹션에 포함된 레슨. 22개 중 22번째.

challenge icon

챌린지

어려움

주문을 추적하고 스스로 해결할 수 없는 경우 담당자에게 건을 전달하는 지원 에이전트를 작성하세요. 시작 코드에는 ORDERS와 빈 리스트인 TICKETS가 포함되어 있으며 요청을 읽습니다.

  1. 두 도구를 정의하세요. track_order: 설명 Track a customer's order by its order number, 설명이 The order number인 필수 정수 속성 order_number 하나. escalate: 설명 Hand the case to a human support agent, 설명이 Why the customer wants help인 필수 문자열 속성 reason 하나.
  2. track_order는 Order <number>: <status>를 반환하거나 ValueError("No order with number <number>")를 발생시킵니다. escalate는 사유를 TICKETS에 추가하고 Ticket T<count> opened for a human: <reason>를 반환하며, 여기서 count는 TICKETS의 길이입니다.
  3. 각 호출에 대해 Tool: 줄을 출력하고 ValueError를 "is_error": True가 포함된 메시지로 다시 보내면서 에이전트 루프(model="claude-opus-5-5", max_tokens=500, 최대 4라운드)를 실행하세요.
  4. Agent: 및 답변 텍스트를 출력하세요.
  5. 도구에서 오류가 발생했거나 루프가 제한에 도달했고 티켓이 생성되지 않은 경우, 전체 요청으로 escalate를 직접 호출하고 Escalated: 및 반환 값을 출력하세요.
  6. Tickets: 및 티켓 수를 출력하세요.

예를 들어 Where is order 9999? 입력에 대해 프로그램은 다음을 출력합니다:

Tool: track_order {'order_number': 9999}
Agent: Sorry, I could not finish: No order with number 9999
Escalated: Ticket T1 opened for a human: Where is order 9999?
Tickets: 1

직접 해보기

import coddy_ai as anthropic  # 프로덕션 환경: import anthropic

client = anthropic.Anthropic()

ORDERS = {
    1042: "shipped, arriving Friday",
    2077: "delayed at the warehouse",
    3155: "delivered on Monday",
}
TICKETS = []

request = input()

# 아래에 코드를 작성하세요

도구와 에이전트의 모든 레슨

직접 연습해 보세요: 온라인 Python 컴파일러