C.W.K.
Stream
Lesson 10 of 10 · published

Loop 닫기 — 대화 끝낼 때

~12 min · conversation, closing

Level 0수련생
0 XP0/100 lessons0/14 achievements
0/120 XP to next level120 XP to go0% complete

대화는 끝나야 해

Prompt engineering 대부분이 대화 keep going하는 법 적어. 더 어려운 질문은 깨끗이 끝낼 때. End-state 진짜 시스템에서 흔해: task 완료, user 만족, error 도달, human transfer, idle timeout.

Explicit end-state

  • Task done — agent가 completion confirm하고 다음 tool call 안 찾음.
  • Handoff — human escalate, 다른 agent로 transfer. Transcript이 brief.
  • Refusal end — request refused, alternative 제시, user redirect 안 하면 close.
  • Error end — unrecoverable error; structured error를 caller한테 return.

왜 중요한가

끝낼 줄 모르는 agent는 계속 tool call, 계속 clarification 요청, 계속 preamble generate. End-state vocabulary가 contract의 일부: 프롬프트가 'done'이 어떻게 보이는지 이름 붙이고 loop wrapper가 그것 체크.

Code

Explicit end-state 박힌 loop·python
while True:
    out = call_model(messages)
    if out.tool_calls:
        results = run_tools(out.tool_calls)
        messages += [out, results]
        continue
    if out.content.endswith("[done]"):
        return success(out.content)
    if out.content.startswith("[handoff]"):
        return handoff(out.content)
    return ask_user(out.content)

External links

Exercise

한 agent prompt에 explicit end-state 추가. Loop wrapper logic 추가. 20개 대화 돌리고 각각이 named state에서 끝나는지 verify.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.