mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-10-06 06:52:20 +02:00
Use single-tool required choice for reliable forced search arguments
This commit is contained in:
@@ -1283,9 +1283,8 @@ async def test_stream_retries_an_obviously_truncated_broad_web_answer(monkeypatc
|
||||
events = [json.loads(chunk[6:]) for chunk in raw if '[DONE]' not in chunk]
|
||||
|
||||
assert len(requests) == (4 if embedded_article or empty_second_search else 5)
|
||||
assert requests[2]['tool_choice'] == {
|
||||
'type': 'function', 'function': {'name': 'web_search'},
|
||||
}
|
||||
assert requests[2]['tool_choice'] == 'required'
|
||||
assert [s['function']['name'] for s in requests[2]['tools']] == ['web_search']
|
||||
if not embedded_article and not empty_second_search:
|
||||
assert requests[3]['tool_choice'] == {
|
||||
'type': 'function', 'function': {'name': 'web_fetch'},
|
||||
@@ -4351,9 +4350,8 @@ async def test_blocked_search_engine_browser_forces_native_web_search(monkeypatc
|
||||
)]
|
||||
|
||||
assert executions == ['private_browser', 'web_search']
|
||||
assert requests[1]['tool_choice'] == {
|
||||
'type': 'function', 'function': {'name': 'web_search'},
|
||||
}
|
||||
assert requests[1]['tool_choice'] == 'required'
|
||||
assert [s['function']['name'] for s in requests[1]['tools']] == ['web_search']
|
||||
events = [json.loads(chunk[6:]) for chunk in raw if '[DONE]' not in chunk]
|
||||
assert any(
|
||||
event.get('type') == 'tool_loop_recovery'
|
||||
|
||||
@@ -4,6 +4,23 @@ import json
|
||||
import pytest
|
||||
|
||||
|
||||
def test_forced_search_dispatch_preserves_schema_without_mutating_request():
|
||||
from src.clean_agent_preview import search_tool_choice_request
|
||||
search = {'type': 'function', 'function': {'name': 'web_search', 'parameters': {'required': ['query']}}}
|
||||
other = {'type': 'function', 'function': {'name': 'web_fetch'}}
|
||||
request = {'tools': [search, other], 'tool_choice': {'type': 'function', 'function': {'name': 'web_search'}}, 'messages': []}
|
||||
converted = search_tool_choice_request(request)
|
||||
assert converted['tools'] == [search]
|
||||
assert converted['tools'][0] is search
|
||||
assert converted['tool_choice'] == 'required'
|
||||
assert len(request['tools']) == 2
|
||||
for choice in ['auto', 'none', 'required', {'type': 'function', 'function': {'name': 'web_fetch'}}]:
|
||||
other_request = {**request, 'tool_choice': choice}
|
||||
assert search_tool_choice_request(other_request) is other_request
|
||||
missing = {**request, 'tools': [other]}
|
||||
assert search_tool_choice_request(missing) is missing
|
||||
|
||||
|
||||
@pytest.mark.parametrize('prompt', [
|
||||
'Explain the settings and link the instructions, not just the homepage.',
|
||||
'Can you link to the original studies?',
|
||||
|
||||
Reference in New Issue
Block a user