[fix] solution/backend: 대화 수정의 값 형식 검증 · 여러 요청의 못 한 것·남은 것 안내 — 조용히 틀리던 경로 정리

말로 고친 값이 형식 검증 없이 저장됐다 — "반려동물 이제 돼요" 가 "가능" 으로 들어가면
화면엔 "가능" 이 뜨는데 factBool 은 'true' 만 참으로 읽어 구조화 데이터가 거짓이 된다.
여러 요청을 한 번에 받을 때도 할 수 없는 것·멈춘 뒤의 것이 말없이 사라져 사장님은
전부 된 줄 알았다(message 는 actions 가 있으면 버려졌다).

- tools: set_fact 값을 스키마 형식으로 맞춘다(bool true/false · time HH:MM · number 숫자) —
  "3시" 처럼 오전·오후를 모르면 저장하지 않고 되묻는다. 알림 문구는 가능·불가로 말한다
- tools: enabled 를 모르면 끄지 않고 되묻는다 — "" 를 끄기로 읽어 "다시 보여줘" 가 섹션을 껐다
- tools: 대표 지정·사진 목록·프롬프트를 '나가는 사진' 기준으로 — 내린 사진을 대표로 지정하고
  "바꿨습니다" 라고 하던 것. 정확히 맞는 이름을 부분 일치보다 먼저 고른다
- tools: Unchanged 표시 — "이미 켜져 있어요" 에 재발행 안내·카톡 발행 대기가 붙던 것
- tools/runtime: 인자가 문자열·dict 가 아니어도 죽지 않는다(모델의 스키마 위반)
- runtime: 같은 대상은 마지막 하나로 합친다(Tool.target, 상한 세기 전). 멈춘 뒤 남은 요청과
  지어낸 도구를 코드가 만든 이름으로 알린다. 발행 확인 문구는 맨 끝에 선다
- prompts: 항목마다 형식을 싣고 skipped(할 수 없는 요청의 이름) 칸 추가 — 문장은 런타임이 만든다.
  다른 가게 이야기면 되묻는 규칙
- channel: 발화에 다른 내 가게 이름이 나오면 모델을 부르기 전에 고르게 한다. 기억한 가게가
  목록에 없으면 비우고 목록으로. 확인 경로의 AgentError 를 사장님 말로 옮긴다
- docs/AGENT.md: 값 형식 · 못 한 것·남은 것·겹친 것 · 나가는 사진 기준

테스트 48건 추가, 에이전트·카카오 153 passed. 전체 932 passed / 47 failed —
실패 47건은 변경 전과 동일(gemini·openai 키 미설정, search_console KeyError, weather_notes)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
민헌andClaude Opus 5.5 committed 2026-09-29 15:11:00 +09:00
1 parent 86d870bab5
commit aaf97f2797
7 files changed
+827 -41

No files matched your search

+35 -2
View File
@@ -181,12 +181,41 @@ async def _pick_place(user: UserInfo, row, utterance: str):
await _update_link(row.channel_user_key, current_place_id=rows[0].place_id)
return str(rows[0].place_id), None
# ★ 기억한 가게를 목록과 대조한다. 그 가게가 없어졌는데 그대로 쓰면 매번
# "그 가게를 찾지 못했어요" 만 돌아오고, 사장님은 '목록' 을 쳐야 풀린다는 걸 모른다.
current = next((r for r in rows if r.place_id == row.current_place_id), None)
if current is not None:
other = _other_named(rows, current, utterance)
if other is not None:
return None, _say(
f"지금은 '{current.name}' 홈페이지를 고치고 있어요. "
f"'{other.name}' 을(를) 고치시려면 먼저 골라 주세요 — 고른 뒤 다시 말씀해 주시면 됩니다.",
[other.name, current.name],
)
return str(current.place_id), None
if row.current_place_id is not None:
return str(row.current_place_id), None
await _update_link(row.channel_user_key, current_place_id=None)
return None, _list_reply(rows, "관리 중인 홈페이지입니다.")
def _other_named(rows: list, current, utterance: str):
"""발화에 **지금 가게가 아닌** 내 가게 이름이 나오면 그 가게.
★ 프롬프트에는 지금 가게 하나만 실린다. "둘째가게 휴무 바꿔줘" 를 그대로 넘기면 첫째가게가
바뀌고, 사장님은 둘째가게가 바뀐 줄 안다 — 모델에 맡기지 않고 여기서 끊는다.
★ 지금 가게 이름에 들어 있는 이름은 보지 않는다('스테이' 와 '스테이 군산점') — 지금 가게를
부른 말인지 가려낼 수 없다."""
mine = (current.name or "").strip()
for r in rows:
name = (r.name or "").strip()
if r.place_id == current.place_id or len(name) < 2 or name in mine:
continue
if name in utterance:
return r
return None
async def handle(utterance: str, channel_user_key: str) -> dict:
"""대화 한 턴. 예외를 던지지 않는다 — 메신저에서는 500 도 침묵으로 보인다."""
utterance = (utterance or "").strip()
@@ -240,7 +269,11 @@ async def handle(utterance: str, channel_user_key: str) -> dict:
if pending is not None:
if utterance in _YES:
await _clear_pending(channel_user_key)
result = await runtime.chat(user, str(row.current_place_id), "", confirm=pending)
try:
result = await runtime.chat(user, str(row.current_place_id), "", confirm=pending)
except runtime.AgentError as ex:
# 아래 도구 경로와 같은 말로 옮긴다 — "처리할 수 없어요" 로는 원인을 모른다.
return _say(_ERRORS.get(str(ex), "지금은 처리할 수 없어요. 잠시 뒤 다시 말씀해 주세요."))
return _say(result["reply"])
if utterance in _NO:
await _clear_pending(channel_user_key)