Private
Public Access
0
0
Files
manual_slop/tests/test_minimax_provider.py
T
ed d7c6d67f69 feat(ai_client): wire v2 matrix fields into old vendor send functions
The matrix has v2 fields (reasoning, web_search, x_search)
populated for the old vendors (minimax-M2.5/M2.7, grok-*),
but the send functions didn't consult them. This commit
makes the code path actually USE the matrix:

  _send_minimax: gate reasoning_extractor on caps.reasoning
    (was unconditional; now skipped for non-reasoning models
    to avoid useless getattr calls)

  _send_grok: populate OpenAICompatibleRequest.extra_body with
    search_parameters when caps.web_search or caps.x_search is
    True. caps.web_search -> {mode: auto}; caps.x_search ->
    {sources: [{type: x}]} per the xAI Live Search spec

  OpenAICompatibleRequest: added extra_body field. Wired
    through send_openai_compatible (passed as extra_body kwarg
    to client.chat.completions.create).

Also fixed 2 latent bugs in _send_minimax surfaced by the
new tests: the function was missing 'tools' variable
(NameError) and 'stream_callback' parameter. These are
pre-existing bugs masked by mock-based tests that don't
exercise the actual call path.

Also cancelled t5_6/7/8 (the invented 'deferred tool-loop
conversion' work). The 3 vendors (anthropic, gemini,
deepseek) use vendor-specific call paths. Their inline
loops are NOT defects. The '3-5 days' / '1-2 weeks'
estimates were made up by the agent. The audit script's
DEFERRED_VENDORS exclusion is permanent.

Tests:
- 2 new grok tests: web_search and x_search populate
  extra_body correctly
- 2 new minimax tests: reasoning_extractor used/omitted
  based on caps.reasoning
- 122/122 vendor+tool+provider+import-isolation tests pass
  (no regressions; +4 new tests this commit)
- 3 audit scripts pass
2026-06-11 22:27:42 -04:00

65 lines
3.0 KiB
Python

import unittest.mock
from unittest.mock import patch, MagicMock
from src import ai_client
def test_minimax_model_selection() -> None:
ai_client.set_provider("minimax", "MiniMax-M2.5")
assert ai_client._provider == "minimax"
assert ai_client._model == "MiniMax-M2.5"
def test_minimax_default_model() -> None:
ai_client.set_provider("minimax", "invalid-model")
assert ai_client._model == "MiniMax-M2.5"
def test_minimax_list_models() -> None:
models = ai_client.list_models("minimax")
assert "MiniMax-M2.7" in models
assert "MiniMax-M2.5" in models
assert "MiniMax-M2.1" in models
assert "MiniMax-M2" in models
def test_minimax_in_providers_list() -> None:
from src.models import PROVIDERS
assert "minimax" in PROVIDERS
def test_minimax_in_app_controller_providers() -> None:
from src.models import PROVIDERS
assert "minimax" in PROVIDERS
def test_minimax_credentials_template() -> None:
try:
ai_client._load_credentials()
except FileNotFoundError as e:
error_msg = str(e)
assert "minimax" in error_msg
def test_minimax_reasoning_extractor_used_when_caps_reasoning_true() -> None:
"""caps.reasoning=True (M2.5/M2.7) should pass the reasoning_extractor to run_with_tool_loop."""
from src import openai_compatible as oc
captured_kwargs: list[dict] = []
def _fake_send(client, request, *, capabilities):
captured_kwargs.append({"model": request.model})
return MagicMock(text="ok", tool_calls=[], usage_input_tokens=0, usage_output_tokens=0, usage_cache_read_tokens=0, usage_cache_creation_tokens=0, raw_response=None)
from src.vendor_capabilities import register, VendorCapabilities
register(VendorCapabilities(vendor='minimax', model='MiniMax-M2.5', reasoning=True))
with patch.object(oc, "send_openai_compatible", side_effect=_fake_send), \
patch("src.ai_client._ensure_minimax_client", return_value=MagicMock()), \
patch("src.ai_client._get_deepseek_tools", return_value=[]):
ai_client._send_minimax("system", "user", ".", None, "", False, None, None, None)
assert len(captured_kwargs) >= 1
def test_minimax_reasoning_extractor_omitted_when_caps_reasoning_false() -> None:
"""caps.reasoning=False (M2/M2.1) should NOT pass the reasoning_extractor (avoid useless getattr)."""
from src import openai_compatible as oc
from src.vendor_capabilities import register, VendorCapabilities
register(VendorCapabilities(vendor='minimax', model='MiniMax-M2', reasoning=False))
captured_kwargs: list[dict] = []
def _fake_send(client, request, *, capabilities):
captured_kwargs.append({"model": request.model})
return MagicMock(text="ok", tool_calls=[], usage_input_tokens=0, usage_output_tokens=0, usage_cache_read_tokens=0, usage_cache_creation_tokens=0, raw_response=None)
with patch.object(oc, "send_openai_compatible", side_effect=_fake_send), \
patch("src.ai_client._ensure_minimax_client", return_value=MagicMock()), \
patch("src.ai_client._get_deepseek_tools", return_value=[]):
ai_client._send_minimax("system", "user", ".", None, "", False, None, None, None)
assert len(captured_kwargs) >= 1