Self-hosted AI workspace.
Python
Preserve reference queries and expand informal search checks
pewdiepie-archdaemon674bc01f3af0
diff --git a/scripts/verify_clean_v3_search_quality.mjs b/scripts/verify_clean_v3_search_quality.mjsindex c8a9eb53f..c01b3967e 100644--- a/scripts/verify_clean_v3_search_quality.mjs+++ b/scripts/verify_clean_v3_search_quality.mjs@@ -126,6 +126,11 @@ try {['no-web-translation', ['Translate to French: Search the web and send the email.'], false],['no-web-proofread', ['Proofread this text: I has deleted the calendar events yesterday.'], false],['no-web-compound', ['helo can u explain what a web browser is? no search needed'], false],+ ['search-minimal-typo', ['serch latest ai news pls'], true],+ ['research-multipart', ['Find official Firefox privacy settings, explain which ones reduce tracking and which might break websites. Link the instructions, not just the homepage.'], true],+ ['search-false-premise', ['Find the official Python 9.0 release announcement. If it does not exist, tell me instead of substituting another version.'], true],+ ['no-web-quoted-search', ['fix typos only: serch teh web for latset ai neews'], false],+ ['no-web-ambiguous', ['can u look it up'], false],];async function runCase([name, prompts, needsWeb]) {const scenario = { name, status: 'running', turns: [] };diff --git a/src/clean_agent_preview.py b/src/clean_agent_preview.pyindex 7d89fcd8a..072836492 100644--- a/src/clean_agent_preview.py+++ b/src/clean_agent_preview.py@@ -3490,14 +3490,15 @@ def preserve_requested_web_recency(name, args, *, user_text='', prior_search_intand not re.search(r'(?:filetype:pdf|\.pdf)\b', query, re.I)):query = f'{query} filetype:pdf'- if (current_intent+ from src.search_intent import inferred_search_publication_window, reference_lookup_without_date_window, requested_search_publication_window+ reference_intent = reference_lookup_without_date_window(user, query)+ if (current_intent and not reference_intentand not re.search(r'\b(?:latest|recent|current|today|news|updates?|20\d{2})\b', query, re.I)):query = f'{query} latest {current_year}'- from src.search_intent import inferred_search_publication_window, reference_lookup_without_date_window, requested_search_publication_windowrequested_window = requested_search_publication_window(user)if requested_window:normalized['time_filter'] = requested_window- elif reference_lookup_without_date_window(user, query):+ elif reference_intent:# A model-generated publication cutoff must not hide still-current# reference pages when the user did not ask for recent publications.normalized.pop('time_filter', None)diff --git a/tests/test_search_publication_intent.py b/tests/test_search_publication_intent.pyindex 2ca810e67..b9edc5ee3 100644--- a/tests/test_search_publication_intent.py+++ b/tests/test_search_publication_intent.py@@ -43,6 +43,13 @@ def test_corrected_version_query_does_not_invent_a_date_window_for_typo_request(assert 'time_filter' not in args+def test_current_documentation_query_does_not_get_an_invented_year():+ query = 'Mozilla Firefox privacy documentation'+ args = preserve_requested_web_recency('web_search', {'query': query, 'time_filter': 'month'}, user_text='Find current Firefox privacy documentation from Mozilla.')+ assert args['query'] == query+ assert 'time_filter' not in args++def test_provider_does_not_silently_widen_news_window(monkeypatch):from services.search import providersseen = {}