Skip to content

The agent that grows with you

fix(providers): review fold for the LM Studio / TokenHub profiles

kshitijk4poord0c7bb9432ac
diff --git a/agent/transports/chat_completions.py b/agent/transports/chat_completions.py
index 40dcff6d6b6..e6789c238cc 100644
--- a/agent/transports/chat_completions.py
+++ b/agent/transports/chat_completions.py
@@ -490,7 +490,7 @@ class ChatCompletionsTransport(ProviderTransport):
reasoning_config = _reasoning_config_for_model(model, params.get("reasoning_config"))
_apply_max_tokens(api_kwargs, model, reasoning_config, params)
- # Kimi / TokenHub by host (base_url-only agents): top-level reasoning_effort (unless thinking disabled).
+ # Kimi / TokenHub by host (agents with no registered profile): top-level reasoning_effort (unless thinking disabled).
thinking_off = isinstance(reasoning_config, dict) and reasoning_config.get("enabled") is False
_e = requested_effort(reasoning_config)
if is_kimi and not thinking_off:
@@ -558,12 +558,15 @@ class ChatCompletionsTransport(ProviderTransport):
# Profiles fronting several backends override get_max_tokens() per model.
_apply_max_tokens(api_kwargs, model, reasoning_config, params, profile_max=profile.get_max_tokens(model))
+ # LM Studio's probed allowed_options ride only when present, so plugin hooks written
+ # against the older keyword set (no ``**context``) keep working.
+ _lm_options = params.get("lmstudio_reasoning_options")
extra_body_from_profile, top_level_from_profile = profile.build_api_kwargs_extras(
reasoning_config=reasoning_config, supports_reasoning=params.get("supports_reasoning", False),
qwen_session_metadata=params.get("qwen_session_metadata"), model=model,
base_url=params.get("base_url"), ollama_num_ctx=params.get("ollama_num_ctx"),
session_id=params.get("session_id"), cache_scope_id=params.get("cache_scope_id"),
- reasoning_options=params.get("lmstudio_reasoning_options"),
+ **({"lmstudio_reasoning_options": _lm_options} if _lm_options is not None else {}),
)
api_kwargs.update(top_level_from_profile)
diff --git a/plugins/model-providers/lmstudio/__init__.py b/plugins/model-providers/lmstudio/__init__.py
index 36c6dcac60d..44a282c1ea7 100644
--- a/plugins/model-providers/lmstudio/__init__.py
+++ b/plugins/model-providers/lmstudio/__init__.py
@@ -2,7 +2,7 @@
Request quirk: reasoning goes out as top-level ``reasoning_effort``, gated on and clamped to
the per-model ``allowed_options`` LM Studio publishes in ``/api/v1/models``. The agent probes
-and caches those options and passes them as ``reasoning_options``.
+and caches those options and passes them as ``lmstudio_reasoning_options``.
Everything else stays where it lives today: endpoint, ``LM_API_KEY`` / ``LM_BASE_URL`` and the
no-auth placeholder (``hermes_cli/auth.py`` registry row), the chat-model picker probe
@@ -23,12 +23,12 @@ class LMStudioProfile(ProviderProfile):
def build_api_kwargs_extras(
self, *, reasoning_config: dict | None = None, supports_reasoning: bool = False,
- reasoning_options: list[str] | None = None, **context: Any,
+ lmstudio_reasoning_options: list[str] | None = None, **context: Any,
) -> tuple[dict[str, Any], dict[str, Any]]:
"""``supports_reasoning`` is true only when the model publishes a non-``off`` option;
- ``reasoning_options`` is the agent's cached probe of them. Auxiliary calls have no probe
- (``None``) and keep the generic nested ``reasoning`` they always sent."""
- if reasoning_options is None:
+ ``lmstudio_reasoning_options`` is the agent's cached probe of them. Auxiliary calls have no
+ probe (``None``) and keep the generic nested ``reasoning`` they always sent."""
+ if lmstudio_reasoning_options is None:
if not reasoning_config or not isinstance(reasoning_config, dict):
return {}, {}
if reasoning_config.get("enabled") is False:
@@ -36,7 +36,7 @@ class LMStudioProfile(ProviderProfile):
return {"reasoning": {"enabled": True, "effort": reasoning_config.get("effort") or "medium"}}, {}
if not supports_reasoning:
return {}, {}
- effort = resolve_lmstudio_effort(reasoning_config, reasoning_options)
+ effort = resolve_lmstudio_effort(reasoning_config, lmstudio_reasoning_options)
return {}, ({"reasoning_effort": effort} if effort is not None else {})
diff --git a/plugins/model-providers/tencent-tokenhub/__init__.py b/plugins/model-providers/tencent-tokenhub/__init__.py
index e870ff6e977..e55225fe4fa 100644
--- a/plugins/model-providers/tencent-tokenhub/__init__.py
+++ b/plugins/model-providers/tencent-tokenhub/__init__.py
@@ -4,8 +4,9 @@ Request quirk: top-level ``reasoning_effort``, clamped to TokenHub's low/medium/
when thinking is off; a main-loop turn with no configured effort sends ``high``.
Endpoint, ``TOKENHUB_API_KEY``, aliases and the static Hy model list stay in
-``hermes_cli/auth.py`` / ``hermes_cli/models_catalog_static.py``; model listing and the doctor
-probe stay off so the picker keeps the curated list.
+``hermes_cli/auth.py`` / ``hermes_cli/models_catalog_static.py``. ``base_url`` is left empty so
+model listing keeps today's paths: first-time setup probes ``{base}/models`` through the generic
+fallback and the ``/model`` picker serves the curated list. The doctor probe stays off.
"""
from typing import Any
@@ -35,6 +36,5 @@ class TokenHubProfile(ProviderProfile):
register_provider(TokenHubProfile(
- name="tencent-tokenhub", display_name="Tencent TokenHub", base_url="https://tokenhub.tencentmaas.com/v1",
- supports_model_listing=False, supports_health_check=False,
+ name="tencent-tokenhub", display_name="Tencent TokenHub", supports_health_check=False,
))
diff --git a/tests/agent/transports/test_chat_completions.py b/tests/agent/transports/test_chat_completions.py
index 7f16f16c68f..0180ffc95f2 100644
--- a/tests/agent/transports/test_chat_completions.py
+++ b/tests/agent/transports/test_chat_completions.py
@@ -519,7 +519,7 @@ class TestChatCompletionsKimi:
class TestChatCompletionsLmStudioReasoning:
"""LM Studio publishes per-model reasoning ``allowed_options``. When the
user requests an effort the model can't honor (e.g. ``high`` on a
- toggle-style ``["off","on"]`` model), the transport omits
+ toggle-style ``["off","on"]`` model), the lmstudio profile omits
``reasoning_effort`` so LM Studio falls back to the model's default —
silently downgrading "high" to "low" would mislead the user.
"""
@@ -549,6 +549,24 @@ class TestChatCompletionsLmStudioReasoning:
+class TestProfileHookKeywordCompat:
+ """``lmstudio_reasoning_options`` is LM Studio-only: a plugin hook that names the older keywords
+ without ``**context`` must not start raising TypeError on every request."""
+
+ def test_hook_without_var_kwargs_still_called(self, transport):
+ from providers.base import ProviderProfile
+
+ class OldSignature(ProviderProfile):
+ def build_api_kwargs_extras(self, *, reasoning_config=None, supports_reasoning=False,
+ qwen_session_metadata=None, model=None, base_url=None,
+ ollama_num_ctx=None, session_id=None, cache_scope_id=None):
+ return {}, {"reasoning_effort": "low"}
+
+ kw = transport.build_kwargs(model="m", messages=[{"role": "user", "content": "Hi"}],
+ provider_profile=OldSignature(name="old-signature"))
+ assert kw["reasoning_effort"] == "low"
+
+
class TestChatCompletionsValidate:
def test_none(self, transport):
diff --git a/tests/agent/transports/test_provider_wire_snapshot.py b/tests/agent/transports/test_provider_wire_snapshot.py
index 2a1beaafc84..d3fb711a2c5 100644
--- a/tests/agent/transports/test_provider_wire_snapshot.py
+++ b/tests/agent/transports/test_provider_wire_snapshot.py
@@ -85,6 +85,8 @@ BASE_URL_ONLY = {
"base-url:kimi-coding": ("kimi-k3", "https://api.kimi.com/coding/v1"),
"base-url:tokenhub": ("hunyuan-t1", "https://tokenhub.tencentmaas.com/v1"),
"base-url:github-models": ("openai/gpt-5.5", "https://models.github.ai/inference"),
+ # o-series stays on chat completions and takes the GitHub reasoning branch; gpt-5.5 above goes to Responses.
+ "base-url:github-models-chat": ("openai/o4-mini", "https://models.github.ai/inference"),
"base-url:nvidia-nim": ("nvidia/nemotron-3-super", "https://integrate.api.nvidia.com/v1"),
"base-url:qwen-portal": ("qwen3-coder-plus", "https://portal.qwen.ai/v1"),
"base-url:lmstudio-port": ("qwen/qwen3-8b", "http://127.0.0.1:1234/v1"),
@@ -215,7 +217,10 @@ def test_provider_wire_matches_snapshot(offline, provider, model, base_url):
@pytest.mark.parametrize("key,model,base_url", BASE_URL_CELLS, ids=[c[0] for c in BASE_URL_CELLS])
def test_base_url_only_wire_matches_snapshot(offline, key, model, base_url):
- _check(key, _wire("", model, base_url), model, base_url)
+ actual = _wire("", model, base_url)
+ if key == "base-url:github-models-chat":
+ assert actual["api_mode"] == "chat_completions", "cell no longer reaches the chat-completions GitHub branch"
+ _check(key, actual, model, base_url)
def test_snapshot_covers_every_provider():
diff --git a/tests/fixtures/provider_wire_snapshot.json b/tests/fixtures/provider_wire_snapshot.json
index 45a1e6e5538..1af0cb1493e 100644
--- a/tests/fixtures/provider_wire_snapshot.json
+++ b/tests/fixtures/provider_wire_snapshot.json
@@ -2435,6 +2435,192 @@
]
}
},
+ "base-url:github-models-chat": {
+ "api_mode": "chat_completions",
+ "base_url": "https://models.github.ai/inference",
+ "high": {
+ "extra_body": {
+ "reasoning": {
+ "effort": "high"
+ }
+ },
+ "messages": [
+ {
+ "content": "You are a test agent.",
+ "role": "system"
+ },
+ {
+ "content": "list files",
+ "role": "user"
+ },
+ {
+ "content": "",
+ "role": "assistant",
+ "tool_calls": [
+ {
+ "function": {
+ "arguments": "{\"command\": \"ls\"}",
+ "name": "terminal"
+ },
+ "id": "call_1",
+ "type": "function"
+ }
+ ]
+ },
+ {
+ "content": "a.txt\nb.txt",
+ "role": "tool",
+ "tool_call_id": "call_1"
+ },
+ {
+ "content": "thanks, now summarize",
+ "role": "user"
+ }
+ ],
+ "model": "openai/o4-mini",
+ "timeout": 1800.0,
+ "tools": [
+ {
+ "function": {
+ "description": "Run a shell command.",
+ "name": "terminal",
+ "parameters": {
+ "properties": {
+ "command": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "command"
+ ],
+ "type": "object"
+ }
+ },
+ "type": "function"
+ }
+ ]
+ },
+ "model": "openai/o4-mini",
+ "off": {
+ "messages": [
+ {
+ "content": "You are a test agent.",
+ "role": "system"
+ },
+ {
+ "content": "list files",
+ "role": "user"
+ },
+ {
+ "content": "",
+ "role": "assistant",
+ "tool_calls": [
+ {
+ "function": {
+ "arguments": "{\"command\": \"ls\"}",
+ "name": "terminal"
+ },
+ "id": "call_1",
+ "type": "function"
+ }
+ ]
+ },
+ {
+ "content": "a.txt\nb.txt",
+ "role": "tool",
+ "tool_call_id": "call_1"
+ },
+ {
+ "content": "thanks, now summarize",
+ "role": "user"
+ }
+ ],
+ "model": "openai/o4-mini",
+ "timeout": 1800.0,
+ "tools": [
+ {
+ "function": {
+ "description": "Run a shell command.",
+ "name": "terminal",
+ "parameters": {
+ "properties": {
+ "command": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "command"
+ ],
+ "type": "object"
+ }
+ },
+ "type": "function"
+ }
+ ]
+ },
+ "unset": {
+ "extra_body": {
+ "reasoning": {
+ "effort": "medium"
+ }
+ },
+ "messages": [
+ {
+ "content": "You are a test agent.",
+ "role": "system"
+ },
+ {
+ "content": "list files",
+ "role": "user"
+ },
+ {
+ "content": "",
+ "role": "assistant",
+ "tool_calls": [
+ {
+ "function": {
+ "arguments": "{\"command\": \"ls\"}",
+ "name": "terminal"
+ },
+ "id": "call_1",
+ "type": "function"
+ }
+ ]
+ },
+ {
+ "content": "a.txt\nb.txt",
+ "role": "tool",
+ "tool_call_id": "call_1"
+ },
+ {
+ "content": "thanks, now summarize",
+ "role": "user"
+ }
+ ],
+ "model": "openai/o4-mini",
+ "timeout": 1800.0,
+ "tools": [
+ {
+ "function": {
+ "description": "Run a shell command.",
+ "name": "terminal",
+ "parameters": {
+ "properties": {
+ "command": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "command"
+ ],
+ "type": "object"
+ }
+ },
+ "type": "function"
+ }
+ ]
+ }
+ },
"base-url:kimi": {
"api_mode": "chat_completions",
"base_url": "https://api.moonshot.ai/v1",