mirror of
https://github.com/HKUDS/OpenSpace.git
synced 2026-09-05 08:06:05 +00:00
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:
commit
800aa6b074
1 changed files with 14 additions and 3 deletions
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue