mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-10-06 06:52:20 +02:00
support tools with DeepSeek Flash thinking mode
This commit is contained in:
@@ -182,6 +182,15 @@ def search_tool_choice_request(request):
|
||||
return {**request, 'tools': selected, 'tool_choice': 'required'}
|
||||
|
||||
|
||||
def provider_compatible_tool_choice_request(request, model):
|
||||
"""Keep tools but avoid forced choice unsupported by thinking providers."""
|
||||
if canonical(model) == 'deepseek-flash' and 'tool_choice' in request:
|
||||
compatible = dict(request)
|
||||
compatible.pop('tool_choice', None)
|
||||
return compatible
|
||||
return request
|
||||
|
||||
|
||||
def bounded_search_observation(output, budget=8000):
|
||||
from src.search_passages import bounded_search_observation as compact
|
||||
return compact(output, budget)
|
||||
@@ -4287,6 +4296,7 @@ async def stream_preview(*, endpoint_url, model, messages, headers, turn_contrac
|
||||
pending, content = {}, ''
|
||||
streamed_round_text = False
|
||||
request = search_tool_choice_request(request)
|
||||
request = provider_compatible_tool_choice_request(request, model)
|
||||
async with preview_model_response(client, endpoint_url, headers, request, context_recovery) as response:
|
||||
response.raise_for_status()
|
||||
async for line in response.aiter_lines():
|
||||
|
||||
@@ -5,7 +5,7 @@ import jsonschema
|
||||
import pytest
|
||||
import re
|
||||
|
||||
from src.clean_agent_preview import conversation, readonly_call, preview_call_allowed, evaluate_preview_call, authorized_write_families, compact_schemas, normalize_preview_function_args, normalize_preview_call_args, private_browser_dom_batch, private_browser_state_transition, private_browser_success_repeat_limit, stream_preview, denied_response, execution_has_write_effect, requests_mutation, claims_completion, recent_successful_write_families, scope_preview_contract, multimodal_image_count, attachment_reference_count, active_document_context_message, active_email_context_message, targets_active_editor, active_editor_whole_draft_request, active_editor_suggestion_request, scope_active_editor_contract, native_execution_limits, interactive_execution_limit, runtime_required_artifacts, execution_targets_required_artifact, document_suggestions_event, document_suggestion_quality_error, required_read_tool_choice, required_active_editor_tool_choice, sealed_read_arguments, email_identifier_error, requested_item_limit, contract_item_limit, notes_terminal_response, documents_terminal_response, shell_listing_terminal_response, shell_output_terminal_response, ui_panel_terminal_response, ui_toggle_state_result, calendar_terminal_response, memory_terminal_response, tasks_terminal_response, task_list_requires_synthesis, skills_terminal_response, cookbook_servers_terminal_response, prior_short_answer_for_no_tool_summary, prior_collection_repeat_answer, prior_failed_operation_answer, prior_cookbook_server_answer, prior_workspace_path_answer, prior_web_source_answer, bounded_web_evidence_answer, inherit_referential_read_arguments, normalized_search_intent, requested_web_source_links, web_source_links, requested_web_link_limit, preserve_requested_web_recency, ground_referenced_note_content, note_search_result_empty, note_referent_error, research_referent_error, private_browser_open_url, private_browser_effective_url, web_fetch_observation_is_boilerplate, broad_current_web_request, record_tool_execution, align_structured_tool_history, provider_request_messages, offered_tool_alias, dependent_write_prerequisite_error, bounded_research_tool_policy, retrieved_source_urls, serialize_required_email_attachment_chain
|
||||
from src.clean_agent_preview import conversation, readonly_call, preview_call_allowed, evaluate_preview_call, authorized_write_families, compact_schemas, normalize_preview_function_args, normalize_preview_call_args, private_browser_dom_batch, private_browser_state_transition, private_browser_success_repeat_limit, stream_preview, denied_response, execution_has_write_effect, requests_mutation, claims_completion, recent_successful_write_families, scope_preview_contract, multimodal_image_count, attachment_reference_count, active_document_context_message, active_email_context_message, targets_active_editor, active_editor_whole_draft_request, active_editor_suggestion_request, scope_active_editor_contract, native_execution_limits, interactive_execution_limit, runtime_required_artifacts, execution_targets_required_artifact, document_suggestions_event, document_suggestion_quality_error, required_read_tool_choice, required_active_editor_tool_choice, sealed_read_arguments, email_identifier_error, requested_item_limit, contract_item_limit, notes_terminal_response, documents_terminal_response, shell_listing_terminal_response, shell_output_terminal_response, ui_panel_terminal_response, ui_toggle_state_result, calendar_terminal_response, memory_terminal_response, tasks_terminal_response, task_list_requires_synthesis, skills_terminal_response, cookbook_servers_terminal_response, prior_short_answer_for_no_tool_summary, prior_collection_repeat_answer, prior_failed_operation_answer, prior_cookbook_server_answer, prior_workspace_path_answer, prior_web_source_answer, bounded_web_evidence_answer, inherit_referential_read_arguments, normalized_search_intent, requested_web_source_links, web_source_links, requested_web_link_limit, preserve_requested_web_recency, ground_referenced_note_content, note_search_result_empty, note_referent_error, research_referent_error, private_browser_open_url, private_browser_effective_url, web_fetch_observation_is_boilerplate, broad_current_web_request, record_tool_execution, align_structured_tool_history, provider_request_messages, provider_compatible_tool_choice_request, offered_tool_alias, dependent_write_prerequisite_error, bounded_research_tool_policy, retrieved_source_urls, serialize_required_email_attachment_chain
|
||||
from src.tool_capabilities import capabilities_for_tool
|
||||
|
||||
|
||||
@@ -97,6 +97,20 @@ def test_provider_wire_messages_drops_empty_assistant_placeholder():
|
||||
assert provider_wire_messages(history) == [history[1]]
|
||||
|
||||
|
||||
def test_deepseek_flash_keeps_tools_but_drops_unsupported_forced_choice():
|
||||
request = {
|
||||
'model': 'deepseek-flash',
|
||||
'tools': [{'type': 'function', 'function': {'name': 'inspect_media'}}],
|
||||
'tool_choice': {'type': 'function', 'function': {'name': 'inspect_media'}},
|
||||
}
|
||||
|
||||
compatible = provider_compatible_tool_choice_request(request, 'deepseek-flash')
|
||||
assert compatible['tools'] == request['tools']
|
||||
assert 'tool_choice' not in compatible
|
||||
assert request['tool_choice']['function']['name'] == 'inspect_media'
|
||||
assert provider_compatible_tool_choice_request(request, 'qwen3.5-9b') is request
|
||||
|
||||
|
||||
def test_private_browser_observations_do_not_advance_page_revision():
|
||||
assert private_browser_state_transition({'action': 'snapshot'}, 'https://example.org') == (
|
||||
False, 'https://example.org')
|
||||
|
||||
Reference in New Issue
Block a user