Hermes-agent
This commit is contained in:
@@ -0,0 +1,207 @@
|
||||
"""Unit tests for the DeepSeek provider profile's thinking-mode wiring.
|
||||
|
||||
DeepSeek V4 (and the legacy ``deepseek-reasoner``) expects every request to
|
||||
carry an explicit ``extra_body.thinking`` parameter. Omitting it makes the
|
||||
server default to thinking-mode ON, which then enforces the
|
||||
``reasoning_content``-must-be-echoed-back contract on subsequent turns and
|
||||
breaks the conversation with HTTP 400 (#15700, #17212, #17825).
|
||||
|
||||
These tests pin the profile's wire-shape contract so DeepSeek requests stay
|
||||
correctly shaped without going live.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def deepseek_profile():
|
||||
"""Resolve the registered DeepSeek profile.
|
||||
|
||||
Going through ``providers.get_provider_profile`` keeps the test honest —
|
||||
if someone later replaces the registered class with a plain
|
||||
``ProviderProfile``, every assertion below collapses.
|
||||
"""
|
||||
# ``model_tools`` triggers plugin discovery on import, which is what
|
||||
# registers the DeepSeek profile in the global provider registry.
|
||||
import model_tools # noqa: F401
|
||||
import providers
|
||||
|
||||
profile = providers.get_provider_profile("deepseek")
|
||||
assert profile is not None, "deepseek provider profile must be registered"
|
||||
return profile
|
||||
|
||||
|
||||
class TestDeepSeekThinkingWireShape:
|
||||
"""``build_api_kwargs_extras`` produces DeepSeek's exact wire format."""
|
||||
|
||||
def test_v4_pro_default_enables_thinking_without_effort(self, deepseek_profile):
|
||||
"""No reasoning_config → thinking enabled, server picks default effort."""
|
||||
extra_body, top_level = deepseek_profile.build_api_kwargs_extras(
|
||||
reasoning_config=None, model="deepseek-v4-pro"
|
||||
)
|
||||
assert extra_body == {"thinking": {"type": "enabled"}}
|
||||
assert top_level == {}
|
||||
|
||||
def test_v4_pro_enabled_with_high_effort(self, deepseek_profile):
|
||||
extra_body, top_level = deepseek_profile.build_api_kwargs_extras(
|
||||
reasoning_config={"enabled": True, "effort": "high"},
|
||||
model="deepseek-v4-pro",
|
||||
)
|
||||
assert extra_body == {"thinking": {"type": "enabled"}}
|
||||
assert top_level == {"reasoning_effort": "high"}
|
||||
|
||||
@pytest.mark.parametrize("effort", ["low", "medium", "high"])
|
||||
def test_standard_efforts_pass_through(self, deepseek_profile, effort):
|
||||
_, top_level = deepseek_profile.build_api_kwargs_extras(
|
||||
reasoning_config={"enabled": True, "effort": effort},
|
||||
model="deepseek-v4-pro",
|
||||
)
|
||||
assert top_level == {"reasoning_effort": effort}
|
||||
|
||||
@pytest.mark.parametrize("effort", ["xhigh", "max", "MAX", " Max "])
|
||||
def test_xhigh_and_max_normalize_to_max(self, deepseek_profile, effort):
|
||||
_, top_level = deepseek_profile.build_api_kwargs_extras(
|
||||
reasoning_config={"enabled": True, "effort": effort},
|
||||
model="deepseek-v4-pro",
|
||||
)
|
||||
assert top_level == {"reasoning_effort": "max"}
|
||||
|
||||
def test_explicitly_disabled_sends_disabled_marker(self, deepseek_profile):
|
||||
"""``reasoning_config.enabled=False`` → ``thinking.type=disabled``.
|
||||
|
||||
The crucial bit is that the parameter is *sent* at all — DeepSeek
|
||||
defaults to thinking-on when ``thinking`` is absent.
|
||||
"""
|
||||
extra_body, top_level = deepseek_profile.build_api_kwargs_extras(
|
||||
reasoning_config={"enabled": False}, model="deepseek-v4-pro"
|
||||
)
|
||||
assert extra_body == {"thinking": {"type": "disabled"}}
|
||||
# No effort when disabled — DeepSeek rejects it.
|
||||
assert top_level == {}
|
||||
|
||||
def test_disabled_ignores_effort_field(self, deepseek_profile):
|
||||
"""Effort silently dropped when thinking is off."""
|
||||
_, top_level = deepseek_profile.build_api_kwargs_extras(
|
||||
reasoning_config={"enabled": False, "effort": "high"},
|
||||
model="deepseek-v4-pro",
|
||||
)
|
||||
assert top_level == {}
|
||||
|
||||
def test_unknown_effort_omits_top_level(self, deepseek_profile):
|
||||
"""Garbage effort → omit reasoning_effort so DeepSeek applies its default."""
|
||||
_, top_level = deepseek_profile.build_api_kwargs_extras(
|
||||
reasoning_config={"enabled": True, "effort": "garbage"},
|
||||
model="deepseek-v4-pro",
|
||||
)
|
||||
assert top_level == {}
|
||||
|
||||
def test_empty_effort_omits_top_level(self, deepseek_profile):
|
||||
_, top_level = deepseek_profile.build_api_kwargs_extras(
|
||||
reasoning_config={"enabled": True, "effort": ""},
|
||||
model="deepseek-v4-pro",
|
||||
)
|
||||
assert top_level == {}
|
||||
|
||||
|
||||
class TestDeepSeekModelGating:
|
||||
"""V4 family + ``deepseek-reasoner`` get thinking; V3 stays untouched."""
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"model",
|
||||
[
|
||||
"deepseek-v4-pro",
|
||||
"deepseek-v4-flash",
|
||||
"deepseek-v4-future-variant",
|
||||
"deepseek-reasoner",
|
||||
"DEEPSEEK-V4-PRO", # case-insensitive
|
||||
],
|
||||
)
|
||||
def test_thinking_capable_models_emit_thinking(self, deepseek_profile, model):
|
||||
extra_body, _ = deepseek_profile.build_api_kwargs_extras(
|
||||
reasoning_config=None, model=model
|
||||
)
|
||||
assert extra_body == {"thinking": {"type": "enabled"}}
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"model",
|
||||
[
|
||||
"deepseek-chat", # V3 alias
|
||||
"deepseek-v3-0324", # explicit V3
|
||||
"deepseek-v3.1", # V3 minor revisions
|
||||
"", # bare/unknown
|
||||
None, # missing
|
||||
"deepseek-unknown", # unrecognized
|
||||
],
|
||||
)
|
||||
def test_non_thinking_models_emit_nothing(self, deepseek_profile, model):
|
||||
extra_body, top_level = deepseek_profile.build_api_kwargs_extras(
|
||||
reasoning_config={"enabled": True, "effort": "high"}, model=model
|
||||
)
|
||||
assert extra_body == {}
|
||||
assert top_level == {}
|
||||
|
||||
|
||||
class TestDeepSeekFullKwargsIntegration:
|
||||
"""End-to-end: the transport's full kwargs match DeepSeek's live wire format.
|
||||
|
||||
The live test harness in ``tests/run_agent/test_deepseek_v4_thinking_live.py``
|
||||
sends ``{"reasoning_effort": "high", "extra_body": {"thinking": {"type":
|
||||
"enabled"}}}``. Confirm the transport produces that exact shape when wired
|
||||
through the registered DeepSeek profile.
|
||||
"""
|
||||
|
||||
def test_full_kwargs_match_live_wire_shape(self, deepseek_profile):
|
||||
from agent.transports.chat_completions import ChatCompletionsTransport
|
||||
|
||||
kwargs = ChatCompletionsTransport().build_kwargs(
|
||||
model="deepseek-v4-pro",
|
||||
messages=[{"role": "user", "content": "ping"}],
|
||||
tools=None,
|
||||
provider_profile=deepseek_profile,
|
||||
reasoning_config={"enabled": True, "effort": "high"},
|
||||
base_url="https://api.deepseek.com/v1",
|
||||
provider_name="deepseek",
|
||||
)
|
||||
assert kwargs["model"] == "deepseek-v4-pro"
|
||||
assert kwargs["reasoning_effort"] == "high"
|
||||
assert kwargs["extra_body"] == {"thinking": {"type": "enabled"}}
|
||||
|
||||
def test_v3_chat_full_kwargs_omit_thinking(self, deepseek_profile):
|
||||
from agent.transports.chat_completions import ChatCompletionsTransport
|
||||
|
||||
kwargs = ChatCompletionsTransport().build_kwargs(
|
||||
model="deepseek-chat",
|
||||
messages=[{"role": "user", "content": "ping"}],
|
||||
tools=None,
|
||||
provider_profile=deepseek_profile,
|
||||
reasoning_config={"enabled": True, "effort": "high"},
|
||||
base_url="https://api.deepseek.com/v1",
|
||||
provider_name="deepseek",
|
||||
)
|
||||
assert "reasoning_effort" not in kwargs
|
||||
assert "extra_body" not in kwargs or "thinking" not in kwargs.get("extra_body", {})
|
||||
|
||||
|
||||
class TestDeepSeekAuxModel:
|
||||
"""DeepSeek aux model is set on the profile so users stop seeing the
|
||||
bogus 'No auxiliary LLM provider configured' warning (#26924).
|
||||
|
||||
Pinned at the profile layer rather than the legacy
|
||||
`_API_KEY_PROVIDER_AUX_MODELS_FALLBACK` dict — new providers are
|
||||
expected to set `default_aux_model` on `ProviderProfile`, and the
|
||||
fallback dict only exists for providers that predate the profiles
|
||||
system.
|
||||
"""
|
||||
|
||||
def test_profile_advertises_deepseek_chat(self, deepseek_profile):
|
||||
assert deepseek_profile.default_aux_model == "deepseek-chat"
|
||||
|
||||
def test_consumer_api_returns_deepseek_chat(self):
|
||||
from agent.auxiliary_client import _get_aux_model_for_provider
|
||||
assert _get_aux_model_for_provider("deepseek") == "deepseek-chat"
|
||||
|
||||
def test_consumer_api_returns_non_empty(self):
|
||||
from agent.auxiliary_client import _get_aux_model_for_provider
|
||||
assert _get_aux_model_for_provider("deepseek") != ""
|
||||
@@ -0,0 +1,130 @@
|
||||
"""Unit tests for the Kimi/Moonshot provider profile's reasoning wiring.
|
||||
|
||||
Moonshot's OpenAI-compat endpoint (``api.moonshot.ai/v1``) treats
|
||||
``extra_body.thinking`` and a top-level ``reasoning_effort`` as mutually
|
||||
exclusive. The profile must send at most one of them — never both — so a
|
||||
request can't trip "cannot specify both 'thinking' and 'reasoning_effort'".
|
||||
|
||||
This mirrors the kimi-k2 handling already shipped for the opencode-go relay
|
||||
(see ``tests/plugins/model_providers/test_opencode_go_profile.py``).
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def kimi_profile():
|
||||
"""Resolve the registered Kimi profile via the provider registry.
|
||||
|
||||
Importing ``model_tools`` triggers plugin discovery, which registers the
|
||||
Kimi profile. Going through ``get_provider_profile`` keeps the test honest:
|
||||
if the registered class is ever swapped for a plain ``ProviderProfile`` the
|
||||
assertions below collapse.
|
||||
"""
|
||||
import model_tools # noqa: F401
|
||||
import providers
|
||||
|
||||
profile = providers.get_provider_profile("kimi-coding")
|
||||
assert profile is not None, "kimi-coding provider profile must be registered"
|
||||
return profile
|
||||
|
||||
|
||||
class TestKimiReasoningWireShape:
|
||||
"""``build_api_kwargs_extras`` never emits thinking + reasoning_effort together."""
|
||||
|
||||
def test_no_config_enables_thinking_without_effort(self, kimi_profile):
|
||||
"""No reasoning_config → thinking on, server picks the depth.
|
||||
|
||||
Regression guard: this path previously also sent
|
||||
``reasoning_effort="medium"``, pairing thinking + effort on every
|
||||
default call.
|
||||
"""
|
||||
extra_body, top_level = kimi_profile.build_api_kwargs_extras(reasoning_config=None)
|
||||
assert extra_body == {"thinking": {"type": "enabled"}}
|
||||
assert top_level == {}
|
||||
|
||||
@pytest.mark.parametrize("effort", ["low", "medium", "high"])
|
||||
def test_explicit_effort_sends_effort_only(self, kimi_profile, effort):
|
||||
extra_body, top_level = kimi_profile.build_api_kwargs_extras(
|
||||
reasoning_config={"enabled": True, "effort": effort}
|
||||
)
|
||||
assert top_level == {"reasoning_effort": effort}
|
||||
assert "thinking" not in extra_body
|
||||
|
||||
def test_enabled_without_effort_falls_back_to_thinking(self, kimi_profile):
|
||||
extra_body, top_level = kimi_profile.build_api_kwargs_extras(
|
||||
reasoning_config={"enabled": True}
|
||||
)
|
||||
assert extra_body == {"thinking": {"type": "enabled"}}
|
||||
assert top_level == {}
|
||||
|
||||
@pytest.mark.parametrize("effort", ["", "garbage", "xhigh", "max"])
|
||||
def test_unrecognized_effort_falls_back_to_thinking(self, kimi_profile, effort):
|
||||
"""Unknown/strong efforts aren't in Moonshot's low|medium|high set, so
|
||||
we drop to the thinking toggle rather than sending an invalid effort."""
|
||||
extra_body, top_level = kimi_profile.build_api_kwargs_extras(
|
||||
reasoning_config={"enabled": True, "effort": effort}
|
||||
)
|
||||
assert extra_body == {"thinking": {"type": "enabled"}}
|
||||
assert top_level == {}
|
||||
|
||||
def test_disabled_sends_thinking_disabled_only(self, kimi_profile):
|
||||
extra_body, top_level = kimi_profile.build_api_kwargs_extras(
|
||||
reasoning_config={"enabled": False}
|
||||
)
|
||||
assert extra_body == {"thinking": {"type": "disabled"}}
|
||||
assert top_level == {}
|
||||
|
||||
def test_disabled_ignores_effort(self, kimi_profile):
|
||||
extra_body, top_level = kimi_profile.build_api_kwargs_extras(
|
||||
reasoning_config={"enabled": False, "effort": "high"}
|
||||
)
|
||||
assert extra_body == {"thinking": {"type": "disabled"}}
|
||||
assert top_level == {}
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"reasoning_config",
|
||||
[
|
||||
None,
|
||||
{"enabled": True},
|
||||
{"enabled": True, "effort": "high"},
|
||||
{"enabled": True, "effort": "garbage"},
|
||||
{"enabled": False},
|
||||
{"enabled": False, "effort": "low"},
|
||||
],
|
||||
)
|
||||
def test_never_emits_both(self, kimi_profile, reasoning_config):
|
||||
"""The core invariant: thinking and reasoning_effort are never both set."""
|
||||
extra_body, top_level = kimi_profile.build_api_kwargs_extras(
|
||||
reasoning_config=reasoning_config
|
||||
)
|
||||
assert not ("thinking" in extra_body and "reasoning_effort" in top_level)
|
||||
|
||||
|
||||
class TestKimiFullKwargsIntegration:
|
||||
"""The transport's full kwargs carry at most one reasoning knob."""
|
||||
|
||||
def _build(self, kimi_profile, reasoning_config):
|
||||
from agent.transports.chat_completions import ChatCompletionsTransport
|
||||
|
||||
return ChatCompletionsTransport().build_kwargs(
|
||||
model="kimi-k2-turbo-preview",
|
||||
messages=[{"role": "user", "content": "ping"}],
|
||||
tools=None,
|
||||
provider_profile=kimi_profile,
|
||||
reasoning_config=reasoning_config,
|
||||
base_url="https://api.moonshot.ai/v1",
|
||||
provider_name="kimi-coding",
|
||||
)
|
||||
|
||||
def test_explicit_effort_omits_thinking(self, kimi_profile):
|
||||
kwargs = self._build(kimi_profile, {"enabled": True, "effort": "high"})
|
||||
assert kwargs["reasoning_effort"] == "high"
|
||||
assert "thinking" not in kwargs.get("extra_body", {})
|
||||
|
||||
def test_no_config_omits_effort(self, kimi_profile):
|
||||
kwargs = self._build(kimi_profile, None)
|
||||
assert "reasoning_effort" not in kwargs
|
||||
assert kwargs["extra_body"] == {"thinking": {"type": "enabled"}}
|
||||
@@ -0,0 +1,120 @@
|
||||
"""Unit tests for the MiniMax provider profile.
|
||||
|
||||
Three MiniMax provider profiles (`minimax` direct API, `minimax-cn` China direct
|
||||
API, `minimax-oauth` browser OAuth) all advertise a `default_aux_model` on
|
||||
their `ProviderProfile`. The previous M2.7 / M2.7-highspeed values were
|
||||
stale relative to the current frontier model (M3, released 2026-06-01) and
|
||||
inconsistent with the `_PROVIDER_MODELS["minimax"]` catalog top entry in
|
||||
`hermes_cli/models.py`.
|
||||
|
||||
This file pins the new defaults so the choice is reviewable and any future
|
||||
revert shows up in a failing test rather than silent behavior drift.
|
||||
|
||||
Refs:
|
||||
- Issue #36196: M3 support request
|
||||
- PR #36205 (closed unmerged): Csrayz's M3 + 1M context work
|
||||
- PR #36212 (open): adds M3 to `_PROVIDER_MODELS["minimax"]` catalog
|
||||
- PR #6082: M2.7-highspeed → M2.7 for aux model (half-price fix)
|
||||
- Commit 773a0faca: same profile-layer fix pattern for `deepseek`
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture(params=["minimax", "minimax-cn", "minimax-oauth"])
|
||||
def minimax_profile(request):
|
||||
"""Resolve each registered MiniMax profile.
|
||||
|
||||
Going through ``providers.get_provider_profile`` keeps the test honest —
|
||||
if someone later replaces the registered class with a plain
|
||||
``ProviderProfile``, every assertion below collapses.
|
||||
"""
|
||||
import model_tools # noqa: F401 -- triggers plugin discovery
|
||||
import providers
|
||||
|
||||
profile = providers.get_provider_profile(request.param)
|
||||
assert profile is not None, f"{request.param} provider profile must be registered"
|
||||
return profile, request.param
|
||||
|
||||
|
||||
class TestMinimaxAuxModelM3:
|
||||
"""MiniMax profile aux model is the new frontier M3, not the stale M2.7.
|
||||
|
||||
The catalog top entry is ``MiniMax-M3`` in
|
||||
``hermes_cli.models._PROVIDER_MODELS['minimax']`` and the
|
||||
user-facing ``model.default`` for a Token-Plan install is M3,
|
||||
so pinning the aux default to the same model keeps the runtime
|
||||
consistent (same auth, same billing pool, same rate limits, no
|
||||
surprise 2x-cost highspeed variant). M3 was released 2026-06-01
|
||||
— picking it as the aux default matches the forward-looking
|
||||
catalog order rather than the pre-M3 era.
|
||||
"""
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"provider_id,expected",
|
||||
[
|
||||
("minimax", "MiniMax-M3"),
|
||||
("minimax-cn", "MiniMax-M3"),
|
||||
# minimax-oauth sticks with M2.7: the OAuth / Coding Plan
|
||||
# tier historically used -highspeed (PR #6082 collapsed that
|
||||
# to plain M2.7 to avoid the 2x TPS surcharge). M3 is not on
|
||||
# the OAuth/Coding Plan tier per platform docs as of this PR,
|
||||
# so the safe choice is the cheapest generally-available
|
||||
# M2.7 — matching PR #6082's intent.
|
||||
("minimax-oauth", "MiniMax-M2.7"),
|
||||
],
|
||||
)
|
||||
def test_profile_advertises_expected_aux_model(
|
||||
self, provider_id, expected
|
||||
):
|
||||
import model_tools # noqa: F401
|
||||
import providers
|
||||
|
||||
profile = providers.get_provider_profile(provider_id)
|
||||
assert profile is not None
|
||||
assert profile.default_aux_model == expected, (
|
||||
f"{provider_id} default_aux_model drifted to "
|
||||
f"{profile.default_aux_model!r}, expected {expected!r}"
|
||||
)
|
||||
|
||||
def test_consumer_api_returns_non_empty_for_each_provider(self, minimax_profile):
|
||||
from agent.auxiliary_client import _get_aux_model_for_provider
|
||||
|
||||
profile, provider_id = minimax_profile
|
||||
resolved = _get_aux_model_for_provider(provider_id)
|
||||
assert resolved != "", (
|
||||
f"_get_aux_model_for_provider({provider_id!r}) returned empty — "
|
||||
"the 'No auxiliary LLM provider configured' warning will fire on "
|
||||
f"every {provider_id} session even though the profile advertises "
|
||||
f"default_aux_model={profile.default_aux_model!r}"
|
||||
)
|
||||
assert resolved == profile.default_aux_model, (
|
||||
f"_get_aux_model_for_provider({provider_id!r}) returned "
|
||||
f"{resolved!r} but profile advertises {profile.default_aux_model!r} "
|
||||
"— the consumer API and the profile have drifted out of sync"
|
||||
)
|
||||
|
||||
|
||||
class TestMinimaxAuxModelNotHighspeed:
|
||||
"""Regression guard against re-introducing the M2.7-highspeed aux default.
|
||||
|
||||
PR #6082 collapsed the highspeed aux choice to plain M2.7 because the
|
||||
highspeed variant costs 2x with no real benefit for compression / vision /
|
||||
session-search aux tasks. None of the three MiniMax profiles should
|
||||
silently re-introduce that 2x-cost path.
|
||||
"""
|
||||
|
||||
@pytest.mark.parametrize("provider_id", ["minimax", "minimax-cn", "minimax-oauth"])
|
||||
def test_default_aux_model_is_not_highspeed(self, provider_id):
|
||||
import model_tools # noqa: F401
|
||||
import providers
|
||||
|
||||
profile = providers.get_provider_profile(provider_id)
|
||||
assert profile is not None
|
||||
assert "highspeed" not in profile.default_aux_model.lower(), (
|
||||
f"{provider_id} default_aux_model={profile.default_aux_model!r} "
|
||||
"is a -highspeed variant — that costs 2x for the same model and "
|
||||
"broke #4082 the first time. Revert to plain M2.7 or M3."
|
||||
)
|
||||
@@ -0,0 +1,180 @@
|
||||
"""Unit tests for OpenCode Go reasoning-control wiring."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def opencode_go_profile():
|
||||
"""Resolve the registered OpenCode Go provider profile."""
|
||||
import model_tools # noqa: F401
|
||||
import providers
|
||||
|
||||
profile = providers.get_provider_profile("opencode-go")
|
||||
assert profile is not None, "opencode-go provider profile must be registered"
|
||||
return profile
|
||||
|
||||
|
||||
class TestOpenCodeGoKimiReasoning:
|
||||
"""Kimi K2 models use Moonshot's thinking + reasoning_effort shape on OpenCode Go."""
|
||||
|
||||
def test_high_effort_emits_thinking_and_effort(self, opencode_go_profile):
|
||||
extra_body, top_level = opencode_go_profile.build_api_kwargs_extras(
|
||||
reasoning_config={"enabled": True, "effort": "high"},
|
||||
model="kimi-k2.6",
|
||||
)
|
||||
assert extra_body == {}
|
||||
assert top_level == {"reasoning_effort": "high"}
|
||||
|
||||
def test_disabled_emits_thinking_disabled_without_effort(self, opencode_go_profile):
|
||||
extra_body, top_level = opencode_go_profile.build_api_kwargs_extras(
|
||||
reasoning_config={"enabled": False},
|
||||
model="kimi-k2.6",
|
||||
)
|
||||
assert extra_body == {"thinking": {"type": "disabled"}}
|
||||
assert top_level == {}
|
||||
|
||||
def test_minimal_effort_enables_thinking_without_effort(self, opencode_go_profile):
|
||||
# "minimal" is not a Moonshot-supported value — drop it, keep thinking on.
|
||||
extra_body, top_level = opencode_go_profile.build_api_kwargs_extras(
|
||||
reasoning_config={"enabled": True, "effort": "minimal"},
|
||||
model="kimi-k2.6",
|
||||
)
|
||||
assert extra_body == {"thinking": {"type": "enabled"}}
|
||||
assert top_level == {}
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"effort",
|
||||
[
|
||||
"xhigh",
|
||||
"max",
|
||||
],
|
||||
)
|
||||
def test_strong_efforts_clamp_to_high(self, opencode_go_profile, effort):
|
||||
extra_body, top_level = opencode_go_profile.build_api_kwargs_extras(
|
||||
reasoning_config={"enabled": True, "effort": effort},
|
||||
model="moonshotai/kimi-k2.6",
|
||||
)
|
||||
assert extra_body == {}
|
||||
assert top_level == {"reasoning_effort": "high"}
|
||||
|
||||
def test_low_and_medium_pass_through(self, opencode_go_profile):
|
||||
for effort in ("low", "medium"):
|
||||
extra_body, top_level = opencode_go_profile.build_api_kwargs_extras(
|
||||
reasoning_config={"enabled": True, "effort": effort},
|
||||
model="kimi-k2.5",
|
||||
)
|
||||
assert extra_body == {}
|
||||
assert top_level == {"reasoning_effort": effort}
|
||||
|
||||
def test_no_config_preserves_server_default(self, opencode_go_profile):
|
||||
extra_body, top_level = opencode_go_profile.build_api_kwargs_extras(
|
||||
reasoning_config=None,
|
||||
model="kimi-k2.6",
|
||||
)
|
||||
assert extra_body == {}
|
||||
assert top_level == {}
|
||||
|
||||
|
||||
class TestOpenCodeGoDeepSeekThinking:
|
||||
"""DeepSeek V4 models use DeepSeek-style thinking controls on OpenCode Go."""
|
||||
|
||||
def test_high_effort_emits_thinking_and_effort(self, opencode_go_profile):
|
||||
extra_body, top_level = opencode_go_profile.build_api_kwargs_extras(
|
||||
reasoning_config={"enabled": True, "effort": "high"},
|
||||
model="deepseek-v4-pro",
|
||||
)
|
||||
assert extra_body == {}
|
||||
assert top_level == {"reasoning_effort": "high"}
|
||||
|
||||
def test_disabled_emits_thinking_disabled_without_effort(self, opencode_go_profile):
|
||||
extra_body, top_level = opencode_go_profile.build_api_kwargs_extras(
|
||||
reasoning_config={"enabled": False, "effort": "high"},
|
||||
model="deepseek-v4-pro",
|
||||
)
|
||||
assert extra_body == {"thinking": {"type": "disabled"}}
|
||||
assert top_level == {}
|
||||
|
||||
def test_no_config_emits_thinking_enabled_without_effort(self, opencode_go_profile):
|
||||
extra_body, top_level = opencode_go_profile.build_api_kwargs_extras(
|
||||
reasoning_config=None,
|
||||
model="deepseek-v4-pro",
|
||||
)
|
||||
assert extra_body == {"thinking": {"type": "enabled"}}
|
||||
assert top_level == {}
|
||||
|
||||
def test_minimal_effort_enables_thinking_without_effort(self, opencode_go_profile):
|
||||
extra_body, top_level = opencode_go_profile.build_api_kwargs_extras(
|
||||
reasoning_config={"enabled": True, "effort": "minimal"},
|
||||
model="deepseek-v4-pro",
|
||||
)
|
||||
assert extra_body == {"thinking": {"type": "enabled"}}
|
||||
assert top_level == {}
|
||||
|
||||
def test_xhigh_and_max_normalize_to_max(self, opencode_go_profile):
|
||||
for effort in ("xhigh", "max"):
|
||||
extra_body, top_level = opencode_go_profile.build_api_kwargs_extras(
|
||||
reasoning_config={"enabled": True, "effort": effort},
|
||||
model="deepseek/deepseek-v4-pro",
|
||||
)
|
||||
assert extra_body == {}
|
||||
assert top_level == {"reasoning_effort": "max"}
|
||||
|
||||
|
||||
class TestOpenCodeGoModelGating:
|
||||
"""Other OpenCode Go models must not receive Kimi/DeepSeek controls."""
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"model",
|
||||
[
|
||||
"glm-5.1",
|
||||
"qwen3.6-plus",
|
||||
"minimax-m2.7",
|
||||
"deepseek-v3.1",
|
||||
"deepseek-chat",
|
||||
"",
|
||||
None,
|
||||
],
|
||||
)
|
||||
def test_non_target_models_emit_nothing(self, opencode_go_profile, model):
|
||||
extra_body, top_level = opencode_go_profile.build_api_kwargs_extras(
|
||||
reasoning_config={"enabled": True, "effort": "high"},
|
||||
model=model,
|
||||
)
|
||||
assert extra_body == {}
|
||||
assert top_level == {}
|
||||
|
||||
|
||||
class TestOpenCodeGoFullKwargsIntegration:
|
||||
"""End-to-end transport kwargs include the profile-provided controls."""
|
||||
|
||||
def test_kimi_reasoning_reaches_extra_body_and_top_level(self, opencode_go_profile):
|
||||
from agent.transports.chat_completions import ChatCompletionsTransport
|
||||
|
||||
kwargs = ChatCompletionsTransport().build_kwargs(
|
||||
model="kimi-k2.6",
|
||||
messages=[{"role": "user", "content": "ping"}],
|
||||
tools=None,
|
||||
provider_profile=opencode_go_profile,
|
||||
reasoning_config={"enabled": True, "effort": "high"},
|
||||
base_url="https://opencode.ai/zen/go/v1",
|
||||
)
|
||||
assert "extra_body" not in kwargs
|
||||
assert kwargs["reasoning_effort"] == "high"
|
||||
|
||||
def test_deepseek_thinking_reaches_extra_body_and_top_level(
|
||||
self, opencode_go_profile
|
||||
):
|
||||
from agent.transports.chat_completions import ChatCompletionsTransport
|
||||
|
||||
kwargs = ChatCompletionsTransport().build_kwargs(
|
||||
model="deepseek-v4-pro",
|
||||
messages=[{"role": "user", "content": "ping"}],
|
||||
tools=None,
|
||||
provider_profile=opencode_go_profile,
|
||||
reasoning_config={"enabled": True, "effort": "high"},
|
||||
base_url="https://opencode.ai/zen/go/v1",
|
||||
)
|
||||
assert "extra_body" not in kwargs
|
||||
assert kwargs["reasoning_effort"] == "high"
|
||||
Reference in New Issue
Block a user