Self-hosted AI workspace.
Python
Separate documentation freshness years from product identifiers
pewdiepie-archdaemon492dffa811ef
diff --git a/scripts/verify_clean_v3_search_quality.mjs b/scripts/verify_clean_v3_search_quality.mjsindex 433601a4b..c8a9eb53f 100644--- a/scripts/verify_clean_v3_search_quality.mjs+++ b/scripts/verify_clean_v3_search_quality.mjs@@ -86,6 +86,9 @@ async function send(page, prompt) {selection_mode: contract?.selection_mode ?? null,policy_decisions: metrics?.policy_decisions || [],proposed_calls: (metrics?.clean_v3_turn || []).flatMap(message => message.tool_calls || []),+ runtime_trace: metrics?.clean_v3_turn || [],+ actual_temperature: metrics?.temperature ?? null,+ actual_max_output_tokens: metrics?.max_output_tokens ?? null,tools: starts, outputs, final,evidence: events.filter(event => event.type === 'tool_output').map(event => ({tool: canonical(event.tool), arguments: event.command,diff --git a/services/search/core.py b/services/search/core.pyindex 871be886d..acc4d5b72 100644--- a/services/search/core.py+++ b/services/search/core.py@@ -260,6 +260,16 @@ def _result_has_query_overlap(query: str, result: dict) -> bool:if entity_terms and entity_terms[0] not in result_tokens:return Falsemodel_numbers = {token for token in ordered_query_tokens if token.isdigit()}+ # Temporal qualifiers are not product identifiers. In particular,+ # query normalization may append "latest 2026" to a documentation+ # lookup; an evergreen official page need not put that year in its+ # title/snippet/URL. Retain actual product numbers (including years+ # used as model names without an explicit temporal qualifier).+ temporal_years = set(re.findall(+ r'\b(?:latest|current|updated|as\s+of)\s+(20\d{2})\b',+ str(query or ''), re.I,+ ))+ model_numbers -= temporal_yearsif model_numbers and not model_numbers.issubset(result_tokens):return Falsediff --git a/src/clean_agent_preview.py b/src/clean_agent_preview.pyindex fab8aaf10..62dac9d87 100644--- a/src/clean_agent_preview.py+++ b/src/clean_agent_preview.py@@ -5662,6 +5662,8 @@ async def stream_preview(*, endpoint_url, model, messages, headers, turn_contrac'request_context_tokens': last_request_tokens,'tool_schema_count': len(offered),'agent_rounds': rounds_used,+ 'temperature': temperature,+ 'max_output_tokens': request_max_tokens,'tool_calls': calls,'tool_events': executions, 'clean_v3_turn': text_only_clean_trace(history[initial_length:]),'policy_decisions': policy_decisions,diff --git a/tests/test_search_empty_query_relaxation.py b/tests/test_search_empty_query_relaxation.pyindex a6efceedf..8a6a1f006 100644--- a/tests/test_search_empty_query_relaxation.py+++ b/tests/test_search_empty_query_relaxation.py@@ -2,6 +2,20 @@ from services.search import coreimport pytest+def test_documentation_freshness_year_is_not_a_product_model_number():+ result = {'title': 'Enhanced Tracking Protection in Firefox',+ 'url': 'https://support.mozilla.org/en-US/kb/enhanced-tracking-protection-firefox-desktop',+ 'snippet': 'Firefox privacy settings and tracking protection documentation.'}+ assert core._result_has_query_overlap('Mozilla Firefox privacy documentation latest 2026', result)+++def test_documentation_filter_keeps_real_product_number_requirements():+ result = {'title': 'WIKING Miro 3 manual', 'url': 'https://example.org/wiking-miro-3', 'snippet': 'WIKING Miro installation guide'}+ assert core._result_has_query_overlap('WIKING Miro 3 manual latest 2026', result)+ assert not core._result_has_query_overlap('WIKING Miro 4 manual latest 2026', result)+ assert not core._result_has_query_overlap('WIKING Miro 2026 manual', result)++@pytest.mark.parametrize('comprehensive', [False, True])@pytest.mark.parametrize('transient_error', [False, True])def test_empty_results_advance_provider_but_transport_errors_get_one_retry(monkeypatch, tmp_path, comprehensive, transient_error):diff --git a/tests/test_search_observation_budget.py b/tests/test_search_observation_budget.pyindex ff76d7a59..b6447b26a 100644--- a/tests/test_search_observation_budget.py+++ b/tests/test_search_observation_budget.py@@ -85,6 +85,9 @@ async def test_runtime_does_not_append_unverified_search_result_as_citation(monkassert 'old-release' not in finalassert '[Source:' not in finalassert not any(event.get('type') == 'error' for event in events)+ metrics = next(event['data'] for event in events if event.get('type') == 'metrics')+ assert metrics['temperature'] == 0.0+ assert metrics['max_output_tokens'] == 768def test_news_intent_survives_query_rewording_without_changing_other_fresh_queries():