fix(evolver): use stem-style matching for confirm/reject/skip keywords

Per reviewer feedback: keep strict \byes\b / \bno\b word boundaries to
prevent false positives, but widen confirm/reject/skip to stem-style
\bconfirm\w*\b etc. so common LLM variants like "confirmed", "rejected",
"skipping" still parse correctly instead of falling through to the
default False path.
This commit is contained in:
warren618 2026-03-27 13:34:20 +08:00
parent 9333eaed42
commit 1257f4cfee

View file

@ -652,15 +652,21 @@ class SkillEvolver:
return bool(data.get("proceed", False))
except (json.JSONDecodeError, ValueError):
pass
# Fallback: look for keywords (use word boundaries to avoid
# false positives from substrings like "know" matching "no")
# Fallback: look for keywords.
# - yes/no use strict word boundaries to avoid false positives
# (e.g. "know" matching "no").
# - confirm/reject/skip use stem-style matching so that common
# LLM variants like "confirmed", "rejected", "skipping" still
# parse correctly.
_wb = re.search # shorthand
if any(w in response for w in ("\"proceed\": true", "proceed: true")) \
or _wb(r"\byes\b", response) or _wb(r"\bconfirm\b", response):
or _wb(r"\byes\b", response) \
or _wb(r"\bconfirm\w*\b", response):
return True
if any(w in response for w in ("\"proceed\": false", "proceed: false")) \
or _wb(r"\bno\b", response) or _wb(r"\breject\b", response) \
or _wb(r"\bskip\b", response):
or _wb(r"\bno\b", response) \
or _wb(r"\breject\w*\b", response) \
or _wb(r"\bskip\w*\b", response):
return False
# Default: skip — ambiguous response should not trigger costly evolution
logger.debug("LLM confirmation response was ambiguous, defaulting to skip")