Require explicit initial search queries rather than copying whole requests

This commit is contained in:
pewdiepie-archdaemon
2026-09-17 21:24:02 +00:00
parent 51feedea6b
commit 40edb59864
2 changed files with 11 additions and 12 deletions
+7 -9
View File
@@ -3460,15 +3460,13 @@ def preserve_requested_web_recency(name, args, *, user_text='', prior_search_int
user = str(user_text or '')
query = str(args.get('query') or '').strip()
if not query:
if prior_search_intents:
raise ValueError(
'web_search requires an explicit query for a follow-up. Supply a '
'specific missing fact, entity, or corroboration question based on '
'the evidence already returned; do not repeat the original query.'
)
query = re.sub(r'\s+', ' ', user).strip().rstrip('?.!')
if not query:
return args
raise ValueError(
'web_search requires an explicit nonempty query. '
+ ('Supply a specific missing fact, entity, or corroboration question '
'based on the evidence already returned; do not repeat the original query.'
if prior_search_intents else
'Supply the subject to search for, not the full conversation or answer-format instructions.')
)
normalized = dict(args)
# Keep the user's explicit news intent when a model rewrites it to a
# subject plus "today". Freshness alone does not select the news vertical.
+4 -3
View File
@@ -2018,12 +2018,13 @@ def test_current_search_arguments_repair_stale_year_and_add_freshness():
@pytest.mark.parametrize('missing_query', [{}, {'query': ''}, {'query': ' ', 'time_filter': 'day'}])
def test_missing_refinement_query_is_not_fabricated(missing_query):
with pytest.raises(ValueError, match='explicit query for a follow-up'):
@pytest.mark.parametrize('prior_intents', [[], ['ai news']])
def test_missing_refinement_query_is_not_fabricated(missing_query, prior_intents):
with pytest.raises(ValueError, match='explicit nonempty query'):
preserve_requested_web_recency(
'web_search', missing_query,
user_text='serch latest ai news pls',
prior_search_intents=['ai news'],
prior_search_intents=prior_intents,
)