Self-hosted AI workspace.
Python
Recognize standalone casual citation requests without topic false positives
pewdiepie-archdaemond0eae8b2e7e8
diff --git a/src/clean_agent_preview.py b/src/clean_agent_preview.pyindex 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.pyindex 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_linksassert requested_web_source_links(prompt)[email protected]('prompt', ['Link my calendar to email', 'Explain linked lists', 'What is a network link?'])[email protected]('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_linksassert 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])[email protected]('prompt', ['latest Python version? official source please', 'more about the second story, with sources'])[email protected]('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 runtimefrom src.tool_schemas import FUNCTION_TOOL_SCHEMAS