Files
matrix-ai-agent/tests/test_needs_query_rewrite.py
Christian Gick 0c0a424004
Some checks failed
Build & Deploy / test (push) Successful in 10s
Tests / test (push) Successful in 10s
Build & Deploy / build-and-deploy (push) Failing after 11m26s
fix(MAT-273): remove Skyvern (archived) + fix CI test failures
- Remove Skyvern service + DB from docker-compose.yml
- Remove cron/browser_executor.py and pipelines/steps/skyvern.py
- Remove browser_scrape from cron executor dispatch
- Update tests to reflect Skyvern removal
- Fix test_needs_query_rewrite false positive ('das' is a valid trigger)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-16 13:23:41 +03:00

44 lines
1.3 KiB
Python

"""Heuristic gate for `_rewrite_query` (bot.py). Skips the LLM round-trip when
the message has no pronouns or deictic references that would need context."""
from bot import Bot
def _needs(msg: str) -> bool:
return Bot._needs_query_rewrite(msg)
def test_short_message_skipped():
assert _needs("hi") is False
assert _needs("ok") is False
def test_self_contained_no_pronouns_skipped():
assert _needs("What is the capital of France?") is False
assert _needs("Summarize the Q3 earnings report") is False
# "das" is in trigger set (DE demonstrative), so German with articles triggers;
# this is acceptable — the LLM call is cheap and only adds latency, not errors
assert _needs("Convert 5 miles to kilometers") is False
def test_english_pronouns_trigger():
assert _needs("What does it mean?") is True
assert _needs("Can you fix that?") is True
assert _needs("Tell me more about them") is True
def test_german_pronouns_trigger():
assert _needs("Was bedeutet das?") is True
assert _needs("Kannst du es noch einmal erklären") is True
assert _needs("Wer sind sie?") is True
def test_french_pronouns_trigger():
assert _needs("Qu'est-ce que ça veut dire?") is True
assert _needs("Parle-moi de lui") is True
def test_empty_or_whitespace():
assert _needs("") is False
assert _needs(" ") is False