Recognize standalone casual citation requests without topic false positives

This commit is contained in:
pewdiepie-archdaemon
2026-09-17 21:41:50 +00:00
parent 1df606d0b5
commit d0eae8b2e7
2 changed files with 6 additions and 2 deletions
+1
View File
@@ -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'
+5 -2
View File
@@ -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