[fix] solution/backend: 카톡 가게 정보 조회를 요약으로 — 발행 주소와 업종 핵심 항목만

"가게 정보 알려줘" 에 저장값을 20개까지 그대로 늘어놓아, 순환 문구 한 항목이 20줄을
넘겨 답을 덮었고 가능·불가 값은 'true' 로 나왔다(2026-10-21 카톡 캡처). 발행 주소는
다른 도구에만 있었다.

- tools.py: 키워드 없으면 상호·업종 · 발행 여부·시각·주소 · 스키마 critical 항목만 한 줄씩
  (첫 줄 30자에서 자름), 나머지는 개수로. 키워드가 있으면 그 항목을 자르지 않고.
  값은 _display 로 사장님 말(가능/불가·단위)로. 요약은 코드가 만든다 — LLM 호출 없음
- docs/AGENT_GUIDE.md: 가게 정보 조회 동작 갱신

테스트 3건 추가, test_agent_runtime·test_kakao_webhook 164 passed.
전체 1116 passed · 48 failed(gemini·search_console·weather_notes — 기존 실패와 동일)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
HyeongBaeYangandClaude Opus 5.5 committed 2026-10-23 15:54:42 +09:00
1 parent 9c107fa895
commit b948b09ba1
3 files changed
+115 -17

No files matched your search

@@ -1116,3 +1116,54 @@ async def test_못_한_요청_이름의_줄바꿈은_한_칸으로_편다(client
choose({"actions": [], "skipped": ["전화번호\n변경"], "message": ""})
reply = (await client.post(f"/v1/agent/chat/{pid}", headers=h, json={"message": "전화번호"})).json()["reply"]
assert "'전화번호 변경' 은(는)" in reply
# ── 가게 정보 요약 (2026-10-23) ─────────────────────────────────────────
async def _say(client, h, pid, choose, actions, message="해줘"):
choose({"actions": actions, "message": ""})
return (await client.post(f"/v1/agent/chat/{pid}", headers=h, json={"message": message})).json()["reply"]
async def _fill(client, h, pid, choose):
await _say(client, h, pid, choose, [
{"tool": "set_fact", "args": {"key": "check_in_time", "value": "15:00"}},
{"tool": "set_fact", "args": {"key": "pet_allowed", "value": "가능"}},
{"tool": "set_fact", "args": {"key": "cancel_policy", "value": "이용 7일 전까지 전액 환불, 3일 전까지 50% 환불, 이후 환불 불가\n당일 취소 불가"}},
{"tool": "set_fact", "args": {"key": "wifi", "value": "가능"}},
])
async def test_가게_정보는_핵심_항목만_요약한다(client, auth_headers, choose, db_engine):
"""캡처(2026-10-21): 순환 문구 한 항목이 20줄을 넘겨 요약을 덮었고, 바비큐가 'true' 로 나왔다."""
h, pid = await seed(client, auth_headers, name="요약숙소")
await _fill(client, h, pid, choose)
reply = await _say(client, h, pid, choose, [{"tool": "list_facts", "args": {}}], "가게 정보 알려줘")
assert reply.startswith("요약숙소 · 숙박")
assert "아직 발행 전이에요." in reply
assert "· 체크인 시간: 15:00" in reply
assert "· 반려동물 동반: 가능" in reply
assert "true" not in reply
assert "와이파이" not in reply # critical 아님 → 개수로만
assert "그 밖에 1개 항목이 저장돼 있어요." in reply
assert "당일 취소 불가" not in reply # 둘째 줄은 싣지 않는다
line = next(x for x in reply.splitlines() if x.startswith("· 취소·환불 규정"))
assert line.endswith("…") and len(line.split(": ", 1)[1]) <= tools.SUMMARY_VALUE_MAX + 1
async def test_발행됐으면_요약에_주소가_붙는다(client, auth_headers, choose, db_engine, monkeypatch):
h, pid = await seed(client, auth_headers)
monkeypatch.setattr(tools, "_published", AsyncMock(return_value=("https://host/s/x", "2026-10-21 14:30")))
reply = await _say(client, h, pid, choose, [{"tool": "list_facts", "args": {}}], "가게 정보 알려줘")
assert "발행됨 · 2026-10-21 14:30\nhttps://host/s/x" in reply
assert "저장된 핵심 정보가 아직 없어요." in reply
async def test_항목을_물으면_자르지_않고_보여준다(client, auth_headers, choose, db_engine):
h, pid = await seed(client, auth_headers)
await _fill(client, h, pid, choose)
reply = await _say(client, h, pid, choose, [{"tool": "list_facts", "args": {"keyword": "취소"}}], "취소 규정 보여줘")
assert "당일 취소 불가" in reply
reply = await _say(client, h, pid, choose, [{"tool": "list_facts", "args": {"keyword": "와이파이"}}], "와이파이 보여줘")
assert "· 와이파이: 가능" in reply