[fix] solution/backend: 에이전트 재검증 결함 정리 — 옮기기 합치기·모르는 방향·낮/밤 시각·만원·첫 번째

추가한 코드를 다시 읽다가 테스트가 못 잡던 여섯 가지가 나왔다. 둘은 조용히 반대로 동작했다 —
"소개 앞쪽으로" 가 소개 뒤로 갔고, "낮 3시" 가 03:00 으로 저장됐다.

- tools: move_section 의 target 제거 — 옮기기는 차례가 뜻이라 "맨 위로, 그리고 한 칸 아래로" 를
  합치면 두 번째가 아니라 원래 자리에서 한 칸 아래가 됐다. 인자까지 같은 것만 합친다
- tools: 못 알아들은 where 는 되묻는다 — 예전 표기(to 만)는 where 가 비었을 때만 읽는다
- tools: 낮은 오후, 밤·새벽 12시는 자정 — '낮 3시' 03:00 · '밤 12시' 12:00 이던 것
- tools: '만원'·'천원'(앞 숫자 없음)을 1로 읽는다. '만 오천원' 은 여전히 되묻는다
- tools: '첫 번째' 순번, toggle 이름 구분에서 '·' 제외('공간 · 좌석 안내' 가 쪼개질 수 있었다)
- runtime: skipped 이름의 줄바꿈·연속 공백을 한 칸으로
- docs/AGENT.md: 값 형식 표 · 옮기기는 합치지 않음 · 모르는 방향은 되묻기

테스트 12건 추가, 에이전트·카카오 186 passed. 전체 965 passed / 47 failed —
실패 목록은 변경 전과 동일(gemini·openai 키 미설정, search_console, weather_notes). pyflakes 새 경고 없음

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
민헌andClaude Opus 5.5 committed 2026-09-30 08:42:43 +09:00
1 parent 36b818eda3
commit 091d5d9c0e
4 files changed
+102 -17

No files matched your search

+25 -12
View File
@@ -111,11 +111,13 @@ _FALSE_WORDS = {"false", "0", "n", "no", "x", "불가", "불가능", "없음", "
# "15:00" · "오후 3시" · "15시 30분" · "3시 반"
_TIME = re.compile(r"^(오전|오후|아침|낮|저녁|밤|새벽)?(\d{1,2})(?::(\d{2})|시(?:(\d{1,2})분|(반))?)$")
_PM_WORDS = {"오후", "저녁", "밤"}
# ★ '낮 3시' 는 15시, '밤 12시' 는 자정이다. 낮을 빼 두면 '낮 3시' 가 03:00 으로 들어간다.
_PM_WORDS = {"오후", "낮", "저녁", "밤"}
_AM_WORDS = {"오전", "아침", "새벽"}
_MIDNIGHT_WORDS = {"밤", "새벽"}
# "2만 5천원" · "20,000원" · "1.5시간"
_NUMBER = re.compile(r"^(?:(\d+)만)?(?:(\d+)천)?(\d+(?:\.\d+)?)?$")
# "2만 5천원" · "20,000원" · "1.5시간" · "만원"(앞 숫자가 없으면 1)
_NUMBER = re.compile(r"^(?:(\d*)만)?(?:(\d*)천)?(\d+(?:\.\d+)?)?$")
_NUMBER_UNITS = re.compile(r"(원|명|대|개|분|시간|실|석|인|층|평|㎡)$")
@@ -137,7 +139,9 @@ def _parse_time(raw: str) -> tuple[str | None, bool]:
if not m:
return None, False
when, hour, minute = m.group(1), int(m.group(2)), int(m.group(3) or m.group(4) or (30 if m.group(5) else 0))
if when in _PM_WORDS and hour < 12:
if when in _MIDNIGHT_WORDS and hour == 12:
hour = 0
elif when in _PM_WORDS and hour < 12:
hour += 12
elif when in _AM_WORDS and hour == 12:
hour = 0
@@ -157,10 +161,11 @@ def _parse_number(raw: str) -> str | None:
if not word or not m:
return None
man, cheon, rest = m.group(1), m.group(2), m.group(3)
if (man or cheon) and rest and "." in rest:
if (man is not None or cheon is not None) and rest and "." in rest:
return None
value = int(man or 0) * 10000 + int(cheon or 0) * 1000
if man or cheon:
if man is not None or cheon is not None:
value = int(man or 1) * 10000 if man is not None else 0
value += int(cheon or 1) * 1000 if cheon is not None else 0
return str(value + int(rest or 0))
number = float(rest)
return str(int(number)) if number.is_integer() else rest
@@ -339,7 +344,7 @@ _WHERE = {
# where 가 없던 때의 표기 — to 에 '맨 위' · '맨 아래' 또는 "그 뒤에 올 부분의 이름" 이 왔다.
_LEGACY_TO = {"맨 위": "top", "처음": "top", "위": "top", "top": "top", "first": "top",
"맨 아래": "bottom", "마지막": "bottom", "아래": "bottom", "bottom": "bottom", "last": "bottom"}
_KOREAN_COUNT = {"한": 1, "하나": 1, "두": 2, "둘": 2, "세": 3, "셋": 3, "네": 4, "넷": 4,
_KOREAN_COUNT = {"첫": 1, "한": 1, "하나": 1, "두": 2, "둘": 2, "세": 3, "셋": 3, "네": 4, "넷": 4,
"다섯": 5, "여섯": 6, "일곱": 7, "여덟": 8, "아홉": 9, "열": 10}
@@ -395,7 +400,8 @@ async def _toggle_section(ctx: ToolContext, args: dict) -> str:
★ 여럿 중 하나라도 못 찾거나 끌 수 없으면 **아무것도 바꾸지 않는다.** 일부만 끄면
사장님은 무엇이 꺼졌는지 다시 확인해야 한다 — 한 요청은 한꺼번에 되거나 안 된다."""
rows, theme = await _sections_of(ctx)
wanted = [w.strip() for w in re.split(r"[,·、]", _arg(args, "name")) if w.strip()]
# ★ '·' 로는 나누지 않는다 — 카페·음식점 섹션 이름에 들어 있다('공간 · 좌석 안내').
wanted = [w.strip() for w in re.split(r"[,、]", _arg(args, "name")) if w.strip()]
found, missing = [], []
for name in wanted:
row = _find_section(rows, name)
@@ -445,8 +451,13 @@ async def _move_section(ctx: ToolContext, args: dict) -> str:
if row["id"] in PINNED:
raise ToolRejected(f"{row['name']} 은(는) 항상 {PINNED[row['id']]}에 서는 부분이라 옮길 수 없어요.")
to = _arg(args, "to")
where = _where(_arg(args, "where")) or _LEGACY_TO.get(to) or ("after" if to else None)
to, said_where = _arg(args, "to"), _arg(args, "where")
# ★ 예전 표기로는 where 가 **비었을 때만** 읽는다. 못 알아들은 where 를 두고 to 만 보면
# "소개 앞쪽으로" 가 소개 **뒤**로 간다 — 조용히 반대로 옮긴다.
if said_where:
where = _where(said_where)
else:
where = _LEGACY_TO.get(to) or ("after" if to else None)
if where is None:
raise ToolRejected("어디로 옮길지 알려 주세요. 예) 맨 위로 · 소개 다음으로 · 한 칸 위로 · 세 번째로")
@@ -709,7 +720,9 @@ REGISTRY: dict[str, Tool] = {
grade=ToolGrade.REVERSIBLE,
republish=True,
describe=_describe_move,
target=("name",),
# ★ target 을 두지 않는다 — 옮기기는 차례가 뜻이다. "맨 위로, 그리고 한 칸 아래로" 를
# 마지막 하나로 합치면 두 번째 자리가 아니라 원래 자리에서 한 칸 아래가 된다.
# 인자까지 똑같은 요청만 합친다.
summary="홈페이지에서 한 부분의 위치(순서)를 바꾼다.",
args={
"name": "옮길 부분의 이름",