Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/489.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**Watch tasks understand a few more ways of saying which changes you want.** "Ignore all the tiny changes" or "Please don't bother me with every little change" now asks for important changes only, "Don't notify me at night, but tell me about every change" asks for every change, and a question such as "Could you tell me about the changes today?" no longer switches the watch to every change.
15 changes: 11 additions & 4 deletions sentient/tasks/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,15 +499,20 @@ def normalize_script(
return out


# Text up to the end of a clause: a comma or semicolon, or a full stop, question or exclamation mark followed by
# a space (a URL's dots don't end it).
_WITHIN_CLAUSE = r"(?:[^\n,;.!?]|[.!?](?=\S))"

# The newest request about updates wins. A question about a page is not a request to change its watch setting;
# neither is a bare use of "change" as a verb. Requests for every update must say that positively.
_NOTEWORTHY_REQUEST = re.compile(
r"\b(?:only\s+)?(?:important|big|major|significant|meaningful)\s+(?:\w+\s+)?"
r"(?:changes?|updates?|stuff|ones?)\b"
r"|\b(?:ignore|skip|don't|do not)\s+(?:(?:all|the)\s+){0,2}(?:minor|small|little)\s+"
r"(?:changes?|updates?)\b"
r"|\b(?:ignore|skip|(?:don't|do not)(?:\s+bother(?:\s+me)?\s+with)?)\s+(?:(?:all|the|every)\s+){0,2}"
r"(?:minor|small|little|tiny|trivial)\s+(?:changes?|updates?)\b"
r"|\b(?:not|never)\s+(?:any|every|all)\s+(?:\w+\s+){0,3}?(?:changes?|updates?)\b"
r"|\b(?:don't|do not)\s+(?:tell me|notify me|let me know|alert me|report)\b[^\n]{0,160}?"
# within one clause: "Don't notify me at night, but tell me about every change" asks for every change
r"|\b(?:don't|do not)\s+(?:tell me|notify me|let me know|alert me|report)\b" + _WITHIN_CLAUSE + r"{0,160}?"
r"\b(?:any|every|all)\s+(?:\w+\s+){0,3}?(?:changes?|updates?)\b",
re.IGNORECASE,
)
Expand All @@ -521,7 +526,9 @@ def normalize_script(
r"\b(?:any|every|all)\s+(?:\w+\s+){0,3}?(?:changes?|updates?)\b"
r"|\b(?:when|whenever|if)\b[^\n]{0,160}?\b(?:changes?|updates?)\b"
r"|\b(?:tell me|notify me|let me know|alert me|report)\b"
r"(?!\s+(?:what|which)\s+(?:changes?|updates?)\b)[^\n]{0,160}?\b(?:changes?|updates?)\b"
# "tell me about the changes (today)" asks about particular changes, not for every future one
r"(?!\s+(?:what|which)\s+(?:changes?|updates?)\b|\s+(?:about|of)\s+the\s+(?:\w+\s+)?(?:changes?|updates?)\b)"
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
+ _WITHIN_CLAUSE + r"{0,160}?\b(?:changes?|updates?)\b"
r"|\b(?:tell me|notify me|let me know|alert me|report)\b[^\n]{0,160}?\b"
r"(?:anything|everything)\s+(?:at\s+all|new)\b",
re.IGNORECASE,
Expand Down
17 changes: 17 additions & 0 deletions tests/tasks/test_scripts_triggers_retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,11 +447,28 @@ def test_planner_default_uses_the_last_preference_in_one_message():
("Don't tell me about every change", "noteworthy"),
("Thanks for all the updates", None),
("Can you tell me what changes were made?", None),
# #489
("Don't notify me at night, but tell me about every change", "changed"),
("Ignore all the tiny changes", "noteworthy"),
("Ignore all trivial changes", "noteworthy"),
("Don't bother with all the minor changes", "noteworthy"),
("Please don't bother me with every little change", "noteworthy"),
("Could you tell me about the changes today?", None),
])
def test_change_preference_requires_an_explicit_watch_request(message, preference):
assert scripts._change_preference(message) == preference


@pytest.mark.parametrize(("message", "condition"), [
("Don't notify me at night, but tell me about every change", "changed"),
("Please don't bother me with every little change", "noteworthy"),
("Could you tell me about the changes today?", "noteworthy"),
])
def test_planner_default_reads_the_new_phrasings(message, condition):
changed = normalize_script({"code": PAGE_CODE, "condition": "changed"})
assert scripts.planner_default(changed, message)["condition"] == condition


async def test_planner_watch_default_gives_later_chat_priority_over_answers(make_app):
watch = {**PLAN_SCRIPT, "script": {"code": PAGE_CODE, "condition": "changed", "then": "notify"}}
app = await make_app(FakeProvider(json_replies=[watch]))
Expand Down
Loading