mirror of
https://github.com/openswarm-ai/openswarm.git
synced 2026-09-08 18:57:43 +02:00
[eric] browser: possessive apostrophes no longer break skill sig matching
This commit is contained in:
@@ -160,7 +160,10 @@ def normalize_task(task: str) -> str:
|
||||
# value is filled from the LIVE task at replay (so the value is never stored on
|
||||
# disk, a redaction win, and the skill generalizes). Quoting is the explicit,
|
||||
# high-precision signal that this token is a parameter; we never guess.
|
||||
_QUOTE_RE = re.compile(r'["“”‘’\']([^"“”‘’\']{1,200})["“”‘’\']')
|
||||
# Lookarounds keep word-internal apostrophes (chen's, don't) from opening a
|
||||
# span; without them every possessive made each task wording a unique sig and
|
||||
# silently disabled skill matching for those tasks.
|
||||
_QUOTE_RE = re.compile(r'(?<!\w)["“”‘’\']([^"“”‘’\']{1,200})["“”‘’\'](?!\w)')
|
||||
_SLOT_TOKEN = " slotvalue "
|
||||
|
||||
|
||||
|
||||
@@ -514,3 +514,14 @@ def test_first_unsafe_step_splits_send_skills():
|
||||
assert i == 2 and "irreversible" in why
|
||||
safe, _ = replay_safety(send_flow)
|
||||
assert not safe
|
||||
|
||||
|
||||
def test_template_task_ignores_possessive_apostrophes():
|
||||
from backend.apps.agents.browser.browser_skills import template_task, _sig
|
||||
r14 = "go to tyler chen's linkedin hes in entrepreneurs first and text him '[test] hello world r14-os'"
|
||||
r15 = "go to tyler chen's linkedin hes in entrepreneurs first and text him '[test] hello world r15-os'"
|
||||
t14, v14 = template_task(r14)
|
||||
assert v14 == ["[test] hello world r14-os"]
|
||||
assert "chen's linkedin" in t14
|
||||
assert _sig(r14) == _sig(r15)
|
||||
assert template_task("no quotes here at all") == ("no quotes here at all", [])
|
||||
|
||||
Reference in New Issue
Block a user