fix(evolver): use word-boundary matching in _parse_confirmation to prevent false positives

This commit is contained in:
warren618 2026-03-26 12:06:11 +08:00
parent 38b51c8605
commit 9333eaed42

View file

@ -652,10 +652,15 @@ class SkillEvolver:
return bool(data.get("proceed", False))
except (json.JSONDecodeError, ValueError):
pass
# Fallback: look for keywords
if any(w in response for w in ("\"proceed\": true", "proceed: true", "yes", "confirm")):
# Fallback: look for keywords (use word boundaries to avoid
# false positives from substrings like "know" matching "no")
_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):
return True
if any(w in response for w in ("\"proceed\": false", "proceed: false", "no", "reject", "skip")):
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):
return False
# Default: skip — ambiguous response should not trigger costly evolution
logger.debug("LLM confirmation response was ambiguous, defaulting to skip")