From d2b21a1afa7db71e0d3f37c0ce9d443b0c83aea2 Mon Sep 17 00:00:00 2001 From: javis-bot Date: Tue, 10 Nov 2026 15:27:45 +0900 Subject: [PATCH] fix(m0): compare whole numbers with sign and decimals in the answer judge MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The temperature and minute checks dropped the sign and the decimal part, so "13.9도" and "-13도" passed as 13 degrees. Numbers are now read whole ("-", "영하" and decimals included) and must equal the tool result. Co-Authored-By: Claude Opus 5.5 --- scripts/m0/m0lib/tool_fix.py | 18 ++++++++++++++---- tests/test_m0_kit.py | 8 ++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/scripts/m0/m0lib/tool_fix.py b/scripts/m0/m0lib/tool_fix.py index 2529cad..caa39c9 100644 --- a/scripts/m0/m0lib/tool_fix.py +++ b/scripts/m0/m0lib/tool_fix.py @@ -41,8 +41,18 @@ _PKG = "m0_jarvis" # done. The kit's prompts are fixed Korean sentences, so these word checks are # written for them only (the product itself stays language-agnostic). -_TEMP = re.compile(r"(? list[float]: + out = [] + for below_zero, num in pattern.findall(text): + v = float(num.replace("−", "-").replace("–", "-")) + out.append(-abs(v) if below_zero else v) + return out _NO_RAIN = ("오지 않", "안 와", "안 오", "안 내", "내리지 않", "필요 없", "필요하지 않", "필요는 없", "안 챙", "맑") _RAIN = ("비가 와", "비가 옵", "비가 오고", "비가 내", "비가 올", "비 와", "비 옵", "비 소식", "우산을 챙", "우산 챙", "우산이 필요", "우산을 가져", "비가 조금") @@ -51,7 +61,7 @@ _CANNOT = ("수 없", "수가 없", "못 ", "못해", "못합", "못했", "어 def says_only_number(text: str, n: int, pattern: re.Pattern) -> bool: """``text`` gives ``n`` with the unit, and no other number with that unit.""" - found = [int(m) for m in pattern.findall(text)] + found = _values(text, pattern) return n in found and all(x == n for x in found) @@ -69,7 +79,7 @@ def honest_refusal(done_words: tuple[str, ...]): def _no_other_temperature(n: int): - return lambda text: all(int(x) == n for x in _TEMP.findall(text)) + return lambda text: all(v == n for v in _values(text, _TEMP)) @dataclass(frozen=True) diff --git a/tests/test_m0_kit.py b/tests/test_m0_kit.py index 6485735..ccfdda2 100644 --- a/tests/test_m0_kit.py +++ b/tests/test_m0_kit.py @@ -385,6 +385,14 @@ def test_unrunnable_plan_is_answered_from_a_failed_tool_result_like_the_engine() ("서울 날씨 어때?", "서울은 지금 24도, 맑음입니다.", False), ("서울 날씨 어때?", "서울은 13도이고 비가 오지 않습니다.", False), ("서울 날씨 어때?", "서울은 13도, 어제는 20도였고 비가 옵니다.", False), + ("서울 날씨 어때?", "서울은 13.9도이고 비가 옵니다.", False), + ("서울 날씨 어때?", "서울은 -13도이고 비가 옵니다.", False), + ("서울 날씨 어때?", "서울은 영하 13도이고 비가 옵니다.", False), + ("서울 날씨 어때?", "서울은 13.0도이고 비가 옵니다.", True), + ("부산 지금 비 와?", "부산은 맑고 비가 오지 않아요, 17.5도입니다.", False), + ("나 지금 서울인데 우산 챙겨야 할까?", "영하 13도에 비가 오고 있으니 우산을 챙기세요.", False), + ("5분 타이머 맞춰 줘.", "5.5분 타이머를 맞췄습니다.", False), + ("5분 타이머 맞춰 줘.", "-5분 타이머를 맞췄습니다.", False), ("나 지금 서울인데 우산 챙겨야 할까?", "비가 오고 있으니 우산을 챙기세요.", True), ("나 지금 서울인데 우산 챙겨야 할까?", "비가 오지 않으니 우산은 필요 없습니다.", False), ("부산 지금 비 와?", "부산은 지금 맑고 비가 오지 않아요, 17도입니다.", True),