From d0eae8b2e7e8d196b5092961ed20e6959460ef48 Mon Sep 17 00:00:00 2001 From: pewdiepie-archdaemon Date: Thu, 17 Sep 2026 21:41:50 +0000 Subject: [PATCH] Recognize standalone casual citation requests without topic false positives --- src/clean_agent_preview.py | 1 + tests/test_search_observation_budget.py | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/clean_agent_preview.py b/src/clean_agent_preview.py index 5f9396ba8..86f1bf7eb 100644 --- a/src/clean_agent_preview.py +++ b/src/clean_agent_preview.py @@ -3267,6 +3267,7 @@ def repeated_search_refinement(query, prior_intents): def requested_web_source_links(user_text): return bool(re.search( r'\b(?:return|give|show|include|provide|cite|find)\b.{0,35}\b(?:source\s+)?links?\b' + r'|(?:^|[.!?;,\n])\s*(?:(?:pls|please)\s+)?(?:sources?|citations?|links?)\s*(?:pls|please)?\s*[.!?]*$' r'|\b(?:\d+|one|two|three|four|five)\s+(?:official\s+)?(?:source\s+)?links?\b' r'|\bofficial\s+source\b' r'|\b(?:with|include|provide|cite|show|give|find)\s+(?:the\s+)?(?:official\s+)?(?:sources|citations)\b' diff --git a/tests/test_search_observation_budget.py b/tests/test_search_observation_budget.py index 8ee1769ef..cc0ff9587 100644 --- a/tests/test_search_observation_budget.py +++ b/tests/test_search_observation_budget.py @@ -39,13 +39,16 @@ def test_forced_search_dispatch_preserves_schema_without_mutating_request(): 'Explain the settings and link the instructions, not just the homepage.', 'Can you link to the original studies?', 'Summarize this and link your sources.', + 'reserch sodium ion vs lithium batterys. whats the tradeof? sources pls', + 'Why does this matter? pls sources', + 'sources?', ]) def test_link_as_a_verb_requests_source_completion(prompt): from src.clean_agent_preview import requested_web_source_links assert requested_web_source_links(prompt) -@pytest.mark.parametrize('prompt', ['Link my calendar to email', 'Explain linked lists', 'What is a network link?']) +@pytest.mark.parametrize('prompt', ['Link my calendar to email', 'Explain linked lists', 'What is a network link?', 'Explain energy sources', 'Compare batteries. No sources please.']) def test_non_source_link_intent_does_not_require_citations(prompt): from src.clean_agent_preview import requested_web_source_links assert not requested_web_source_links(prompt) @@ -84,7 +87,7 @@ def test_external_edits_are_not_mistaken_for_inline_text(prompt): @pytest.mark.asyncio @pytest.mark.parametrize('repair_missing_link', [False, True]) -@pytest.mark.parametrize('prompt', ['latest Python version? official source please', 'more about the second story, with sources']) +@pytest.mark.parametrize('prompt', ['latest Python version? official source please', 'more about the second story, with sources', 'why does that matter? sources pls']) async def test_runtime_does_not_append_unverified_search_result_as_citation(monkeypatch, repair_missing_link, prompt): import src.clean_agent_preview as runtime from src.tool_schemas import FUNCTION_TOOL_SCHEMAS