Merge pull request #10 from warren618/fix/evolver-confirmation-parsing

fix(evolver): use word-boundary matching in _parse_confirmation to prevent false positives
This commit is contained in:
Dennis-yxchen 2026-03-27 21:37:08 +08:00 committed by GitHub
commit 800aa6b074
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -652,10 +652,21 @@ 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.
# - 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\w*\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\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")