The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(model-providers): compact reasoning-translation profiles (opencode, kimi, zai, minimax, nous, qwen, custom, upstage, nebius, meta-ai, deepseek, copilot, deepinfra, vertex, gemini), fold catalog tuples
Teknium9338e21093cb
diff --git a/plugins/model-providers/ai-gateway/__init__.py b/plugins/model-providers/ai-gateway/__init__.pyindex a89c7c2d33e..33a4c73ec55 100644--- a/plugins/model-providers/ai-gateway/__init__.py+++ b/plugins/model-providers/ai-gateway/__init__.py@@ -23,10 +23,7 @@ vercel = VercelAIGatewayProfile(aliases=("vercel", "vercel-ai-gateway", "ai_gateway", "aigateway"),env_vars=("AI_GATEWAY_API_KEY",),base_url="https://ai-gateway.vercel.sh/v1",- default_headers={- "HTTP-Referer": "https://hermes-agent.nousresearch.com",- "X-Title": "Hermes Agent",- },+ default_headers={"HTTP-Referer": "https://hermes-agent.nousresearch.com", "X-Title": "Hermes Agent"},default_aux_model="google/gemini-3-flash",)diff --git a/plugins/model-providers/alibaba/__init__.py b/plugins/model-providers/alibaba/__init__.pyindex 6ed2f58c45c..7dd5519e62a 100644--- a/plugins/model-providers/alibaba/__init__.py+++ b/plugins/model-providers/alibaba/__init__.py@@ -24,9 +24,6 @@ alibaba_cn = ProviderProfile(base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",)-register_provider(alibaba)-register_provider(alibaba_cn)-alibaba_token_plan = ProviderProfile(name="alibaba-token-plan",aliases=("dashscope-token-plan",),@@ -49,5 +46,7 @@ alibaba_token_plan_cn = ProviderProfile(auth_type="api_key",)+register_provider(alibaba)+register_provider(alibaba_cn)register_provider(alibaba_token_plan)register_provider(alibaba_token_plan_cn)diff --git a/plugins/model-providers/anthropic/__init__.py b/plugins/model-providers/anthropic/__init__.pyindex fbe5269f9f1..1647e16b778 100644--- a/plugins/model-providers/anthropic/__init__.py+++ b/plugins/model-providers/anthropic/__init__.py@@ -22,9 +22,8 @@ class AnthropicProfile(ProviderProfile):return Nonetry:req = urllib.request.Request("https://api.anthropic.com/v1/models")- req.add_header("x-api-key", api_key)- req.add_header("anthropic-version", "2023-06-01")- req.add_header("Accept", "application/json")+ for k, v in (("x-api-key", api_key), ("anthropic-version", "2023-06-01"), ("Accept", "application/json")):+ req.add_header(k, v)with open_credentialed_url(req, timeout=timeout) as resp:data = json.loads(resp.read().decode())return [m["id"] for m in data.get("data", []) if isinstance(m, dict) and "id" in m]diff --git a/plugins/model-providers/commandcode/__init__.py b/plugins/model-providers/commandcode/__init__.pyindex 960324060df..e4eb2dc4989 100644--- a/plugins/model-providers/commandcode/__init__.py+++ b/plugins/model-providers/commandcode/__init__.py@@ -64,17 +64,9 @@ commandcode = CommandCodeProfile(base_url=_COMMANDCODE_BASE,models_url=_COMMANDCODE_MODELS_URL,fallback_models=(- "deepseek/deepseek-v4-pro",- "deepseek/deepseek-v4-flash",- "Qwen/Qwen3.7-Max",- "Qwen/Qwen3.6-Plus",- "moonshotai/Kimi-K2.6",- "zai-org/GLM-5.1",- "MiniMaxAI/MiniMax-M2.7",- "stepfun/Step-3.5-Flash",- "xiaomi/mimo-v2.5-pro",- "google/gemini-3.5-flash",- "gpt-5.5",+ "deepseek/deepseek-v4-pro", "deepseek/deepseek-v4-flash", "Qwen/Qwen3.7-Max", "Qwen/Qwen3.6-Plus",+ "moonshotai/Kimi-K2.6", "zai-org/GLM-5.1", "MiniMaxAI/MiniMax-M2.7", "stepfun/Step-3.5-Flash",+ "xiaomi/mimo-v2.5-pro", "google/gemini-3.5-flash", "gpt-5.5",),default_aux_model="deepseek/deepseek-v4-flash",)diff --git a/plugins/model-providers/copilot-acp/__init__.py b/plugins/model-providers/copilot-acp/__init__.pyindex ef7d90ec466..86d8ee3009f 100644--- a/plugins/model-providers/copilot-acp/__init__.py+++ b/plugins/model-providers/copilot-acp/__init__.py@@ -1,10 +1,9 @@"""GitHub Copilot ACP provider profile.-copilot-acp does not speak OpenAI-over-HTTP: it drives an external ACP-subprocess over stdio, so the profile supplies its own client via-:meth:`ProviderProfile.create_client`. An out-of-tree ACP provider registered-from ``~/.hermes/plugins/model-providers/`` or a pip entry point uses the same-three lines without touching core.+copilot-acp does not speak OpenAI-over-HTTP: it drives an external ACP subprocess over+stdio, so the profile supplies its own client via :meth:`ProviderProfile.create_client`.+An out-of-tree ACP provider (``~/.hermes/plugins/model-providers/`` or a pip entry point)+uses the same three lines without touching core."""from typing import Any@@ -36,9 +35,8 @@ copilot_acp = CopilotACPProfile(env_vars=(), # Managed by ACP subprocessbase_url="acp://copilot", # ACP internal schemeauth_type="external_process",- # How to launch the CLI. Previously hardcoded in- # hermes_cli/auth.py::resolve_external_process_provider_credentials; the env- # var names are unchanged, so existing setups keep working.+ # How to launch the CLI; env var names predate this profile (formerly hardcoded in+ # hermes_cli/auth.py), so existing setups keep working.process_command="copilot",process_args=("--acp", "--stdio"),process_command_env_vars=("HERMES_COPILOT_ACP_COMMAND", "COPILOT_CLI_PATH"),diff --git a/plugins/model-providers/copilot/__init__.py b/plugins/model-providers/copilot/__init__.pyindex 903ef2b3f98..23d21c4dd4a 100644--- a/plugins/model-providers/copilot/__init__.py+++ b/plugins/model-providers/copilot/__init__.py@@ -15,12 +15,8 @@ class CopilotProfile(ProviderProfile):"""GitHub Copilot / GitHub Models — editor headers + reasoning."""def build_api_kwargs_extras(- self,- *,- model: str | None = None,- reasoning_config: dict | None = None,- supports_reasoning: bool = False,- **ctx,+ self, *, model: str | None = None, reasoning_config: dict | None = None,+ supports_reasoning: bool = False, **ctx,) -> tuple[dict[str, Any], dict[str, Any]]:if not (supports_reasoning and model):return {}, {}@@ -33,10 +29,9 @@ class CopilotProfile(ProviderProfile):if not reasoning_config:return {"reasoning": {"effort": "medium"}}, {}effort = reasoning_config.get("effort", "medium")- # Honor a level the live catalog lists; otherwise clamp to the nearest- # WEAKER supported level (never drop straight to medium, which inverted- # the ladder: ultra < high). Bespoke levels the ladder can't place fall- # to medium (or the first supported level).+ # Honor a level the live catalog lists; otherwise clamp to the nearest WEAKER+ # supported level (never drop straight to medium, which inverted the ladder:+ # ultra < high). Bespoke levels the ladder can't place fall to medium (or [0]).if effort not in supported:effort = clamp_reasoning_effort_to_supported(effort, list(supported))if effort not in supported:diff --git a/plugins/model-providers/custom/__init__.py b/plugins/model-providers/custom/__init__.pyindex 7260096833d..cc8c0bb445e 100644--- a/plugins/model-providers/custom/__init__.py+++ b/plugins/model-providers/custom/__init__.py@@ -11,16 +11,13 @@ from providers.base import ProviderProfiledef _looks_like_ollama_endpoint(base_url: str | None) -> bool:"""True only for explicit Ollama signatures (port 11434 or an ``ollama`` host label).-``think`` is Ollama-native; strict hosts (Mistral, Groq) 422 on it, and- arbitrary localhost may be llama.cpp / vLLM / LM Studio.- """+ arbitrary localhost may be llama.cpp / vLLM / LM Studio."""raw = (base_url or "").strip()if not raw:return Falseparsed = urlparse(raw if "://" in raw else f"//{raw}")- # urlparse raises ValueError on malformed ports ("host:99999"); treat as not-Ollama.- try:+ try: # urlparse raises ValueError on malformed ports ("host:99999"); treat as not-Ollama.if parsed.port == 11434:return Trueexcept ValueError:@@ -39,7 +36,6 @@ class CustomProfile(ProviderProfile):top_level: dict[str, Any] = {}if ollama_num_ctx:extra_body["options"] = {"num_ctx": ollama_num_ctx}-# disabled -> top-level reasoning_effort="none" (Ollama's /v1 ignores# extra_body.think) plus think=False only on Ollama URLs; enabled+effort -># top-level reasoning_effort clamped to the OpenAI-compat wire (GLM/ARK,diff --git a/plugins/model-providers/deepinfra/__init__.py b/plugins/model-providers/deepinfra/__init__.pyindex f57077f43bf..61c6bbdd75a 100644--- a/plugins/model-providers/deepinfra/__init__.py+++ b/plugins/model-providers/deepinfra/__init__.py@@ -10,12 +10,9 @@ class _DeepInfraProfile(ProviderProfile):resolution in ``agent/auxiliary_client.py`` stays provider-agnostic."""def default_vision_model(self): # type: ignore[override]- """First vision-capable *chat* model from the live catalog, or None.-- Key-gated so a box without DEEPINFRA_API_KEY never pays the round-trip.- Requires the ``chat`` surface tag so an image-gen model carrying a- ``vision`` tag can't be picked as a chat-completions vision backend.- """+ """First vision-capable *chat* model from the live catalog, or None. Key-gated so a box+ without DEEPINFRA_API_KEY never pays the round-trip; requires the ``chat`` surface tag so+ an image-gen model carrying a ``vision`` tag can't be picked as a chat vision backend."""from agent.secret_scope import get_secretif not (get_secret("DEEPINFRA_API_KEY") or "").strip():@@ -42,8 +39,7 @@ deepinfra = _DeepInfraProfile(env_vars=("DEEPINFRA_API_KEY", "DEEPINFRA_BASE_URL"),base_url="https://api.deepinfra.com/v1/openai",auth_type="api_key",- # No provider-wide cap: DeepInfra applies its documented per-model limit.- default_max_tokens=None,+ default_max_tokens=None, # DeepInfra applies its documented per-model limit# The only hardcoded DeepInfra model: aux resolution is synchronous, so it# can't wait on a catalog round-trip. Everything else is discovered live.default_aux_model="deepseek-ai/DeepSeek-V4-Flash",diff --git a/plugins/model-providers/deepseek/__init__.py b/plugins/model-providers/deepseek/__init__.pyindex b669f665953..e253863d831 100644--- a/plugins/model-providers/deepseek/__init__.py+++ b/plugins/model-providers/deepseek/__init__.py@@ -24,12 +24,11 @@ class DeepSeekProfile(ProviderProfile):self, *, reasoning_config: dict | None = None, model: str | None = None, **context) -> tuple[dict[str, Any], dict[str, Any]]:m = (model or "").strip().lower()- # deepseek-v4-* and every later generation; v3 explicitly excluded.- if not m.startswith("deepseek-v") or m.startswith("deepseek-v3"):+ if not m.startswith("deepseek-v") or m.startswith("deepseek-v3"): # v4+ only; v3 excludedreturn {}, {}rc = reasoning_config if isinstance(reasoning_config, dict) else None- # Always set explicitly (default enabled, matching the API default) to- # avoid the reasoning_content echo trap on subsequent turns.+ # Always set thinking explicitly (default enabled, matching the API default)+ # to avoid the reasoning_content echo trap on subsequent turns.if rc is not None and rc.get("enabled") is False:return {"thinking": {"type": "disabled"}}, {}top_level: dict[str, Any] = {}diff --git a/plugins/model-providers/fireworks/__init__.py b/plugins/model-providers/fireworks/__init__.pyindex 92a39c9cd8f..6e681b3af3e 100644--- a/plugins/model-providers/fireworks/__init__.py+++ b/plugins/model-providers/fireworks/__init__.py@@ -25,8 +25,7 @@ fireworks = ProviderProfile(default_aux_model="accounts/fireworks/models/glm-5p2",# Picker safety net when the live catalog fetch fails.fallback_models=(- "accounts/fireworks/models/kimi-k2p6",- "accounts/fireworks/models/glm-5p2",+ "accounts/fireworks/models/kimi-k2p6", "accounts/fireworks/models/glm-5p2","accounts/fireworks/models/kimi-k2p7-code",),)diff --git a/plugins/model-providers/gmi/__init__.py b/plugins/model-providers/gmi/__init__.pyindex 307b657a537..2009d785981 100644--- a/plugins/model-providers/gmi/__init__.py+++ b/plugins/model-providers/gmi/__init__.py@@ -17,12 +17,8 @@ gmi = ProviderProfile(default_headers={"User-Agent": f"HermesAgent/{_HERMES_VERSION}"},default_aux_model="google/gemini-3.1-flash-lite-preview",fallback_models=(- "zai-org/GLM-5.1-FP8",- "deepseek-ai/DeepSeek-V3.2",- "moonshotai/Kimi-K2.5",- "google/gemini-3.1-flash-lite-preview",- "anthropic/claude-sonnet-5",- "anthropic/claude-sonnet-4.6",+ "zai-org/GLM-5.1-FP8", "deepseek-ai/DeepSeek-V3.2", "moonshotai/Kimi-K2.5",+ "google/gemini-3.1-flash-lite-preview", "anthropic/claude-sonnet-5", "anthropic/claude-sonnet-4.6","openai/gpt-5.4",),)diff --git a/plugins/model-providers/kimi-coding/__init__.py b/plugins/model-providers/kimi-coding/__init__.pyindex 1e9525cdc17..256a6a8d000 100644--- a/plugins/model-providers/kimi-coding/__init__.py+++ b/plugins/model-providers/kimi-coding/__init__.py@@ -17,7 +17,7 @@ _HEADERS = {def _is_confirmed_kimi_coding_url(base_url: str) -> bool:- """Return True only for Kimi Code's canonical HTTPS API surfaces."""+ """True only for Kimi Code's canonical HTTPS API surfaces."""try:p = urlparse(base_url)port = p.port@@ -61,27 +61,17 @@ class KimiProfile(ProviderProfile):return {"thinking": {"type": "enabled"}}, {}-kimi = KimiProfile(- name="kimi-coding",- aliases=("kimi", "moonshot", "kimi-for-coding"),- env_vars=("KIMI_API_KEY", "KIMI_CODING_API_KEY"),- base_url="https://api.moonshot.ai/v1",- fixed_temperature=OMIT_TEMPERATURE,- default_max_tokens=32000,- default_headers=dict(_HEADERS),- default_aux_model="kimi-k2-turbo-preview",-)+def _kimi(name: str, aliases: tuple, env_vars: tuple, base_url: str) -> KimiProfile:+ return KimiProfile(+ name=name, aliases=aliases, env_vars=env_vars, base_url=base_url,+ fixed_temperature=OMIT_TEMPERATURE, default_max_tokens=32000,+ default_headers=dict(_HEADERS), default_aux_model="kimi-k2-turbo-preview",+ )+-kimi_cn = KimiProfile(- name="kimi-coding-cn",- aliases=("kimi-cn", "moonshot-cn"),- env_vars=("KIMI_CN_API_KEY",),- base_url="https://api.moonshot.cn/v1",- fixed_temperature=OMIT_TEMPERATURE,- default_max_tokens=32000,- default_headers=dict(_HEADERS),- default_aux_model="kimi-k2-turbo-preview",-)+kimi = _kimi("kimi-coding", ("kimi", "moonshot", "kimi-for-coding"), ("KIMI_API_KEY", "KIMI_CODING_API_KEY"),+ "https://api.moonshot.ai/v1")+kimi_cn = _kimi("kimi-coding-cn", ("kimi-cn", "moonshot-cn"), ("KIMI_CN_API_KEY",), "https://api.moonshot.cn/v1")register_provider(kimi)register_provider(kimi_cn)diff --git a/plugins/model-providers/meta-ai/__init__.py b/plugins/model-providers/meta-ai/__init__.pyindex f349f8461f3..061a5da9b47 100644--- a/plugins/model-providers/meta-ai/__init__.py+++ b/plugins/model-providers/meta-ai/__init__.py@@ -20,18 +20,11 @@ class MetaAIProfile(ProviderProfile):"""Meta Model API — top-level reasoning_effort, self-contained."""def build_api_kwargs_extras(- self,- *,- reasoning_config: dict | None = None,- supports_reasoning: bool = False, # noqa: ARG002 — we self-gate below- **context: Any,+ self, *, reasoning_config: dict | None = None, supports_reasoning: bool = False, **context: Any) -> tuple[dict[str, Any], dict[str, Any]]:- """Ignores the core ``supports_reasoning`` gate (host-allowlist driven);- Muse Spark always accepts ``reasoning_effort``.-- Muse 400s on ``none``: disabled/"none" -> ``minimal`` (closest to off);- unset/bespoke levels -> ``medium``.- """+ """Ignores the core ``supports_reasoning`` gate (host-allowlist driven); Muse Spark always+ accepts ``reasoning_effort``. Muse 400s on ``none``: disabled/"none" -> ``minimal``+ (closest to off); unset/bespoke levels -> ``medium``."""rc = reasoning_config or {}effort = str(rc.get("effort") or "").strip().lower()if rc.get("enabled") is False or effort == "none":@@ -52,14 +45,12 @@ meta_ai = MetaAIProfile(env_vars=("MODEL_API_KEY", "META_API_KEY", "META_MODEL_API_KEY", "META_BASE_URL"),base_url=os.getenv("META_BASE_URL", "").strip() or "https://api.meta.ai/v1",auth_type="api_key",- # Responses API engages Muse prompt caching (0 cached tokens on- # chat/completions vs 93-99% hits on /v1/responses); the chat-completions- # hook above still covers custom non-api.meta.ai base URLs.+ # Responses API engages Muse prompt caching (0 cached tokens on chat/completions vs+ # 93-99% hits on /v1/responses); the hook above still covers custom non-api.meta.ai base URLs.api_mode="codex_responses",supports_vision=True,default_aux_model="muse-spark-1.2-contributor",- # Muse spends completion budget on hidden reasoning first; low caps can- # finish with empty content.+ # Muse spends completion budget on hidden reasoning first; low caps can finish with empty content.default_max_tokens=16384,fallback_models=("muse-spark-1.2", "muse-spark-1.2-contributor"),)diff --git a/plugins/model-providers/minimax/__init__.py b/plugins/model-providers/minimax/__init__.pyindex 00dcbe2f668..896bbc876b3 100644--- a/plugins/model-providers/minimax/__init__.py+++ b/plugins/model-providers/minimax/__init__.py@@ -21,12 +21,8 @@ class MiniMaxProfile(ProviderProfile):"""MiniMax — M3 OpenAI-compatible reasoning controls."""def build_api_kwargs_extras(- self,- *,- reasoning_config: dict | None = None,- model: str | None = None,- base_url: str | None = None,- **context: Any,+ self, *, reasoning_config: dict | None = None, model: str | None = None,+ base_url: str | None = None, **context: Any,) -> tuple[dict[str, Any], dict[str, Any]]:"""M3 on api.minimax.io/v1 keeps thinking inline unless ``reasoning_split``is sent; effort levels only select adaptive vs disabled ``thinking``."""@@ -42,22 +38,13 @@ class MiniMaxProfile(ProviderProfile):minimax = MiniMaxProfile(- name="minimax",- aliases=("mini-max",),- api_mode="anthropic_messages",- env_vars=("MINIMAX_API_KEY",),- base_url="https://api.minimax.io/anthropic",- auth_type="api_key",- default_aux_model="MiniMax-M3",+ name="minimax", aliases=("mini-max",), api_mode="anthropic_messages", env_vars=("MINIMAX_API_KEY",),+ base_url="https://api.minimax.io/anthropic", auth_type="api_key", default_aux_model="MiniMax-M3",)minimax_cn = MiniMaxProfile(- name="minimax-cn",- aliases=("minimax-china", "minimax_cn"),- api_mode="anthropic_messages",- env_vars=("MINIMAX_CN_API_KEY",),- base_url="https://api.minimaxi.com/anthropic",- auth_type="api_key",+ name="minimax-cn", aliases=("minimax-china", "minimax_cn"), api_mode="anthropic_messages",+ env_vars=("MINIMAX_CN_API_KEY",), base_url="https://api.minimaxi.com/anthropic", auth_type="api_key",default_aux_model="MiniMax-M3",)diff --git a/plugins/model-providers/nebius-token-factory/__init__.py b/plugins/model-providers/nebius-token-factory/__init__.pyindex 198dd8d21ad..0e1b6d7743e 100644--- a/plugins/model-providers/nebius-token-factory/__init__.py+++ b/plugins/model-providers/nebius-token-factory/__init__.py@@ -10,14 +10,7 @@ from providers.base import ProviderProfile# Conservative allowlist of model families that expose reasoning effort._REASONING_MARKERS = (- "deepseek-r1",- "deepseek-v4",- "deepseek-reasoner",- "gpt-oss",- "glm-5",- "kimi-k2",- "minimax-m2",- "qwen3",+ "deepseek-r1", "deepseek-v4", "deepseek-reasoner", "gpt-oss", "glm-5", "kimi-k2", "minimax-m2", "qwen3",)@@ -25,12 +18,8 @@ class NebiusTokenFactoryProfile(ProviderProfile):"""Nebius Token Factory - top-level reasoning_effort."""def build_api_kwargs_extras(- self,- *,- reasoning_config: dict | None = None,- model: str | None = None,- supports_reasoning: bool = False,- **context: Any,+ self, *, reasoning_config: dict | None = None, model: str | None = None,+ supports_reasoning: bool = False, **context: Any,) -> tuple[dict[str, Any], dict[str, Any]]:model_name = (model or "").strip().rsplit("/", 1)[-1].lower()if not supports_reasoning and not any(marker in model_name for marker in _REASONING_MARKERS):@@ -56,15 +45,9 @@ nebius_token_factory = NebiusTokenFactoryProfile(auth_type="api_key",default_aux_model="nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B",fallback_models=(- "Qwen/Qwen3.5-397B-A17B-fast",- "deepseek-ai/DeepSeek-V4-Pro",- "zai-org/GLM-5.1",- "moonshotai/Kimi-K2.5-fast",- "MiniMaxAI/MiniMax-M2.5-fast",- "deepseek-ai/DeepSeek-V3.2-fast",- "NousResearch/Hermes-4-70B",- "openai/gpt-oss-120b-fast",- "meta-llama/Llama-3.3-70B-Instruct",+ "Qwen/Qwen3.5-397B-A17B-fast", "deepseek-ai/DeepSeek-V4-Pro", "zai-org/GLM-5.1", "moonshotai/Kimi-K2.5-fast",+ "MiniMaxAI/MiniMax-M2.5-fast", "deepseek-ai/DeepSeek-V3.2-fast", "NousResearch/Hermes-4-70B",+ "openai/gpt-oss-120b-fast", "meta-llama/Llama-3.3-70B-Instruct",),)diff --git a/plugins/model-providers/nous/__init__.py b/plugins/model-providers/nous/__init__.pyindex 24df5f8503e..5cbd3ebad93 100644--- a/plugins/model-providers/nous/__init__.py+++ b/plugins/model-providers/nous/__init__.py@@ -2,11 +2,7 @@from typing import Any-from agent.portal_tags import (- get_affinity_scope,- get_conversation_context,- nous_portal_tags,-)+from agent.portal_tags import get_affinity_scope, get_conversation_context, nous_portal_tagsfrom agent.transports.codex import _cache_scope_from_session_idfrom providers import register_providerfrom providers.base import ProviderProfile@@ -30,9 +26,7 @@ class NousProfile(ProviderProfile):# breakpoints stay warm on one upstream instance. Resolved like the# ``conversation=`` tag: declared scope, then the ambient lineage ROOT# (covers aux call sites that pass no session_id), then the explicit argument.- sticky_key = _cache_scope_from_session_id(- get_affinity_scope() or get_conversation_context() or session_id- )+ sticky_key = _cache_scope_from_session_id(get_affinity_scope() or get_conversation_context() or session_id)if sticky_key:body["session_id"] = sticky_keyprovider_preferences = context.get("provider_preferences")@@ -42,11 +36,8 @@ class NousProfile(ProviderProfile):@staticmethoddef _cannot_disable_reasoning(model: str | None) -> bool:- """True when ``reasoning: {enabled: false}`` would 400 on *model*.-- Cache-only catalog lookup; unknown/cold (warmer kicked) and- no-reasoning-parameter routes both answer True (omit rather than risk a 400).- """+ """True when ``reasoning: {enabled: false}`` would 400 on *model*. Cache-only catalog+ lookup; unknown/cold (warmer kicked) and no-reasoning routes both answer True (omit > 400)."""try:from hermes_cli.models import nous_model_reasoning_capabilities, warm_nous_reasoning_caps_async@@ -59,12 +50,8 @@ class NousProfile(ProviderProfile):return not caps.get("supports_reasoning") or bool(caps.get("mandatory"))def build_api_kwargs_extras(- self,- *,- reasoning_config: dict | None = None,- supports_reasoning: bool = False,- model: str | None = None,- **context,+ self, *, reasoning_config: dict | None = None, supports_reasoning: bool = False,+ model: str | None = None, **context,) -> tuple[dict[str, Any], dict[str, Any]]:"""Pass the full reasoning_config, disable included (the Portal honors it;omitting it means the upstream default, thinking ON for V4-class models)."""diff --git a/plugins/model-providers/novita/__init__.py b/plugins/model-providers/novita/__init__.pyindex e49e289a0de..42a1dabafd1 100644--- a/plugins/model-providers/novita/__init__.py+++ b/plugins/model-providers/novita/__init__.py@@ -15,12 +15,8 @@ novita = ProviderProfile(auth_type="api_key",default_aux_model="deepseek/deepseek-v3-0324",fallback_models=(- "moonshotai/kimi-k2.5",- "minimax/minimax-m2.7",- "zai-org/glm-5",- "deepseek/deepseek-v3-0324",- "deepseek/deepseek-r1-0528",- "qwen/qwen3-235b-a22b-fp8",+ "moonshotai/kimi-k2.5", "minimax/minimax-m2.7", "zai-org/glm-5", "deepseek/deepseek-v3-0324",+ "deepseek/deepseek-r1-0528", "qwen/qwen3-235b-a22b-fp8",),)diff --git a/plugins/model-providers/nvidia/__init__.py b/plugins/model-providers/nvidia/__init__.pyindex abc81f45c05..1d48a225c77 100644--- a/plugins/model-providers/nvidia/__init__.py+++ b/plugins/model-providers/nvidia/__init__.py@@ -11,11 +11,7 @@ class NvidiaProviderProfile(ProviderProfile):@staticmethoddef _needs_strip(msg: Any) -> bool:- return (- isinstance(msg, dict)- and msg.get("role") == "tool"- and ("name" in msg or "tool_name" in msg)- )+ return isinstance(msg, dict) and msg.get("role") == "tool" and ("name" in msg or "tool_name" in msg)def prepare_messages(self, messages: list[dict[str, Any]]) -> list[dict[str, Any]]:"""Copy-on-write: only tool messages that lose a field are copieddiff --git a/plugins/model-providers/opencode-free/__init__.py b/plugins/model-providers/opencode-free/__init__.pyindex d8251415cc2..9778b6a3a50 100644--- a/plugins/model-providers/opencode-free/__init__.py+++ b/plugins/model-providers/opencode-free/__init__.py@@ -16,9 +16,9 @@ from providers.base import ProviderProfileclass OpenCodeFreeProfile(ProviderProfile):"""OpenCode Free — keyless, with Ox Alpha reasoning controls.- Ox Alpha (x-preview-f-free) is also reachable via opencode-zen with the same- wire contract; the translation lives in the zen plugin and is resolved through- the registered zen profile's module so the two providers can never drift.+ Ox Alpha (x-preview-f-free) is also reachable via opencode-zen with the same wire+ contract; the translation lives in the zen plugin and is resolved through the+ registered zen profile's module so the two providers can never drift."""def build_api_kwargs_extras(@@ -42,9 +42,8 @@ opencode_free = OpenCodeFreeProfile(base_url="https://opencode.ai/zen/v1",display_name="OpenCode Free",description="OpenCode free models — keyless, no account needed",- # Attribution headers (same values as opencode-zen/go) plus the empty- # Authorization override that keeps the SDK's "Bearer <placeholder>" off the- # wire (the free tier 401s any unrecognized bearer).+ # Attribution headers (same values as opencode-zen/go) plus the empty Authorization+ # override that keeps the SDK's "Bearer <placeholder>" off the wire (free tier 401s it).default_headers={"Authorization": "","HTTP-Referer": "https://hermes-agent.nousresearch.com",diff --git a/plugins/model-providers/opencode-zen/__init__.py b/plugins/model-providers/opencode-zen/__init__.pyindex b8601771f65..dba9aa6c43c 100644--- a/plugins/model-providers/opencode-zen/__init__.py+++ b/plugins/model-providers/opencode-zen/__init__.py@@ -23,7 +23,7 @@ _ATTRIBUTION_HEADERS = {def _flat_model_name(model: str | None) -> str:- """Return the bare OpenCode model ID, tolerating aggregator prefixes."""+ """Bare OpenCode model ID, tolerating aggregator prefixes."""return (model or "").strip().rsplit("/", 1)[-1].lower()@@ -33,7 +33,7 @@ def _is_deepseek_thinking_model(model: str | None) -> bool:def _is_glm_5_2_model(model: str | None) -> bool:- """Detect GLM-5.2 across alias spellings (glm-5.2 / glm-5-2 / glm-5p2)."""+ """GLM-5.2 across alias spellings (glm-5.2 / glm-5-2 / glm-5p2)."""m = _flat_model_name(model)return any(token in m for token in ("glm-5.2", "glm-5-2", "glm-5p2"))@@ -62,9 +62,7 @@ class OpenCodeGoProfile(ProviderProfile):# The relay's default max_tokens (262144) exceeds what Xiaomi accepts for# mimo-v2.5-pro and 400s; keys are normalized via _flat_model_name().- _MODEL_MAX_TOKENS: dict[str, int] = {- "mimo-v2.5-pro": 131072,- }+ _MODEL_MAX_TOKENS: dict[str, int] = {"mimo-v2.5-pro": 131072}def get_max_tokens(self, model: str | None) -> int | None:cap = self._MODEL_MAX_TOKENS.get(_flat_model_name(model))@@ -85,9 +83,7 @@ class OpenCodeGoProfile(ProviderProfile):return {}, {}return _thinking_toggle_extras(reasoning_config, re_.KIMI_K2_EFFORTS)if _is_deepseek_thinking_model(model):- return _thinking_toggle_extras(- reasoning_config, re_.DEEPSEEK_V4_EFFORTS, re_.DEEPSEEK_V4_OVERRIDES- )+ return _thinking_toggle_extras(reasoning_config, re_.DEEPSEEK_V4_EFFORTS, re_.DEEPSEEK_V4_OVERRIDES)return {}, {}@@ -98,12 +94,8 @@ def _build_ox_alpha_reasoning_extras(opencode-free profile (low/high/max only; anything else 400s)."""if _flat_model_name(model) != "x-preview-f-free":return {}, {}- clamped = re_.clamp_effort(- _requested_effort(reasoning_config), re_.OX_ALPHA_EFFORTS, re_.OX_ALPHA_OVERRIDES- )- if clamped not in re_.OX_ALPHA_EFFORTS:- return {}, {}- return {}, {"reasoning_effort": clamped}+ clamped = re_.clamp_effort(_requested_effort(reasoning_config), re_.OX_ALPHA_EFFORTS, re_.OX_ALPHA_OVERRIDES)+ return ({}, {"reasoning_effort": clamped}) if clamped in re_.OX_ALPHA_EFFORTS else ({}, {})class OpenCodeZenProfile(ProviderProfile):diff --git a/plugins/model-providers/openrouter/__init__.py b/plugins/model-providers/openrouter/__init__.pyindex f25ee79b5e6..cf9fb6147c4 100644--- a/plugins/model-providers/openrouter/__init__.py+++ b/plugins/model-providers/openrouter/__init__.py@@ -152,10 +152,7 @@ openrouter = OpenRouterProfile(base_url="https://openrouter.ai/api/v1",models_url="https://openrouter.ai/api/v1/models",fallback_models=(- "anthropic/claude-sonnet-4.6",- "openai/gpt-5.4",- "deepseek/deepseek-chat",- "google/gemini-3.8-flash",+ "anthropic/claude-sonnet-4.6", "openai/gpt-5.4", "deepseek/deepseek-chat", "google/gemini-3.8-flash","qwen/qwen3-plus",),)diff --git a/plugins/model-providers/qwen-oauth/__init__.py b/plugins/model-providers/qwen-oauth/__init__.pyindex 6e1a88f95cb..98e166bf1e8 100644--- a/plugins/model-providers/qwen-oauth/__init__.py+++ b/plugins/model-providers/qwen-oauth/__init__.py@@ -27,8 +27,8 @@ class QwenProfile(ProviderProfile):"""Qwen Portal — message normalization, vl_high_resolution, metadata top-level."""def prepare_messages(self, messages: list[dict[str, Any]]) -> list[dict[str, Any]]:- """Normalize content to list-of-dicts and inject cache_control on the system- message. Copy-on-write: only touched messages/parts are copied."""+ """Normalize content to list-of-dicts and inject cache_control on the (first)+ system message. Copy-on-write: only touched messages/parts are copied."""if not messages:return []prepared = list(messages)@@ -45,7 +45,6 @@ class QwenProfile(ProviderProfile):parts = _normalize_parts(content)if parts is not None:prepared[idx] = {**msg, "content": parts}-if system_idx is not None:msg = prepared[system_idx]content = msg.get("content")@@ -59,11 +58,7 @@ class QwenProfile(ProviderProfile):return {"vl_high_resolution_images": True}def build_api_kwargs_extras(- self,- *,- reasoning_config: dict | None = None,- qwen_session_metadata: dict | None = None,- **context,+ self, *, reasoning_config: dict | None = None, qwen_session_metadata: dict | None = None, **context) -> tuple[dict[str, Any], dict[str, Any]]:"""Qwen metadata goes to top-level api_kwargs, not extra_body."""return {}, {"metadata": qwen_session_metadata} if qwen_session_metadata else {}diff --git a/plugins/model-providers/router/__init__.py b/plugins/model-providers/router/__init__.pyindex 9604d354fa2..01f296986a3 100644--- a/plugins/model-providers/router/__init__.py+++ b/plugins/model-providers/router/__init__.py@@ -47,14 +47,11 @@ def _base_url() -> str:def _resolve_api_key() -> str:"""Router key (documented var, then alias), preferring dotenv; plain os.environis the fallback when the dotenv resolver is unavailable or raises."""- resolvers: list = [lambda var: os.environ.get(var, "")]try:- from hermes_cli.config import get_env_value_prefer_dotenv-- resolvers.insert(0, get_env_value_prefer_dotenv)+ from hermes_cli.config import get_env_value_prefer_dotenv as prefer_dotenvexcept Exception:- pass- for resolve in resolvers:+ prefer_dotenv = None+ for resolve in filter(None, (prefer_dotenv, os.environ.get)):for var in ("RAMP_ROUTER_API_KEY", "ROUTER_API_KEY"):try:value = str(resolve(var) or "").strip()@@ -121,7 +118,7 @@ def _save_disk(efforts_by_id: dict[str, list[str]]) -> None:returntry:path.parent.mkdir(parents=True, exist_ok=True)- tmp = path.with_suffix(".tmp")+ tmp = path.with_suffix(".tmp") # write-then-rename keeps readers from seeing a torn filetmp.write_text(json.dumps({"ts": time.time(), "efforts": efforts_by_id}), encoding="utf-8")tmp.replace(path)except Exception as exc:diff --git a/plugins/model-providers/upstage/__init__.py b/plugins/model-providers/upstage/__init__.pyindex 186671e164f..324c79a3c5d 100644--- a/plugins/model-providers/upstage/__init__.py+++ b/plugins/model-providers/upstage/__init__.py@@ -11,9 +11,8 @@ from agent.reasoning_effort import EFFORT_LADDER, SOLAR_EFFORTS, clamp_effortfrom providers import register_providerfrom providers.base import ProviderProfile-# Deny-list on purpose: new Solar models are assumed reasoning-capable; only-# these known non-reasoning families ignore reasoning_effort. Substring match-# so dated variants (``solar-mini-250127``) are covered.+# Deny-list on purpose: new Solar models are assumed reasoning-capable; only these known+# non-reasoning families ignore reasoning_effort. Substring match covers dated variants._NON_REASONING_MODEL_MARKERS = ("solar-mini", "syn-pro")@@ -26,12 +25,10 @@ class UpstageProfile(ProviderProfile):m = (model or "").strip().lower()if any(marker in m for marker in _NON_REASONING_MODEL_MARKERS):return {}, {}- # Unset -> default reasoning ON for agents.if not reasoning_config or not isinstance(reasoning_config, dict):- return {}, {"reasoning_effort": "medium"}- # Explicitly disabled -> omit so Solar applies its own default (minimal = off).+ return {}, {"reasoning_effort": "medium"} # unset -> reasoning ON for agentsif reasoning_config.get("enabled") is False:- return {}, {}+ return {}, {} # explicitly disabled -> Solar's own default (minimal = off)effort = (reasoning_config.get("effort") or "").strip().lower()if not effort:return {}, {"reasoning_effort": "medium"}@@ -39,9 +36,8 @@ class UpstageProfile(ProviderProfile):return {}, {}mapped = clamp_effort(effort, SOLAR_EFFORTS)if mapped not in SOLAR_EFFORTS:- # Bespoke level outside the ladder runs at full strength rather- # than quietly falling to the default; ladder levels that still- # don't map are omitted.+ # Bespoke level outside the ladder runs at full strength rather than quietly+ # falling to the default; ladder levels that still don't map are omitted.mapped = "high" if effort not in EFFORT_LADDER else Nonereturn {}, {"reasoning_effort": mapped} if mapped else {}diff --git a/plugins/model-providers/vertex/__init__.py b/plugins/model-providers/vertex/__init__.pyindex ef761c2656a..4b7583a5c59 100644--- a/plugins/model-providers/vertex/__init__.py+++ b/plugins/model-providers/vertex/__init__.py@@ -1,10 +1,8 @@-"""Google Vertex AI provider profile: Gemini via Google Cloud's OpenAI-compatible-endpoint.+"""Google Vertex AI provider profile: Gemini via Google Cloud's OpenAI-compatible endpoint.-Auth is OAuth2 (service-account JSON or ADC), not a static key: ``agent/-vertex_adapter.py`` mints ``(token, base_url)`` and the token is passed as-``api_key``. ``auth_type="vertex"`` keeps it out of the api_key provider path so-a credentials-file path is never mistaken for a key.+Auth is OAuth2 (service-account JSON or ADC), not a static key: ``agent/vertex_adapter.py``+mints ``(token, base_url)`` and the token is passed as ``api_key``. ``auth_type="vertex"``+keeps it out of the api_key provider path so a credentials-file path is never mistaken for a key."""from typing import Any@@ -17,18 +15,12 @@ class VertexProfile(ProviderProfile):"""Vertex AI — reuse Gemini's thinking_config translation for extra_body."""def build_extra_body(self, *, session_id: str | None = None, **context: Any) -> dict[str, Any]:- """Emit ``extra_body.google.thinking_config`` like the ``gemini`` provider's- OpenAI-compat subpath."""- from agent.transports.chat_completions import (- _build_gemini_thinking_config,- _snake_case_gemini_thinking_config,- )+ """Emit ``extra_body.google.thinking_config`` like the ``gemini`` provider's OpenAI-compat subpath."""+ from agent.transports.chat_completions import _build_gemini_thinking_config, _snake_case_gemini_thinking_configraw = _build_gemini_thinking_config(context.get("model") or "", context.get("reasoning_config"))thinking_config = _snake_case_gemini_thinking_config(raw) if raw else None- if not thinking_config:- return {}- return {"extra_body": {"google": {"thinking_config": thinking_config}}}+ return {"extra_body": {"google": {"thinking_config": thinking_config}}} if thinking_config else {}def fetch_models(self, *, api_key: str | None = None, base_url: str | None = None, timeout: float = 8.0diff --git a/plugins/model-providers/zai/__init__.py b/plugins/model-providers/zai/__init__.pyindex 11a57c3dc05..05105e779fe 100644--- a/plugins/model-providers/zai/__init__.py+++ b/plugins/model-providers/zai/__init__.py@@ -27,14 +27,12 @@ def _model_supports_thinking(model: str | None) -> bool:def _has_token(model: str | None, tokens: tuple[str, ...]) -> bool:m = (model or "").strip().lower()- return bool(m) and any(token in m for token in tokens)+ return any(token in m for token in tokens)def _glm_5_2_reasoning_effort(reasoning_config: dict | None, *, model: str | None = None) -> str | None:- """Map Hermes effort onto GLM's vocabulary (5.2: high/max; 5.3: low..max).-- Below-floor efforts clamp to the floor; disabled/unset leaves the server default.- """+ """Hermes effort -> GLM vocabulary (5.2: high/max; 5.3: low..max). Below-floor+ efforts clamp to the floor; disabled/unset leaves the server default."""effort = re_.requested_effort(reasoning_config)if effort is None or effort == "none":return None@@ -57,12 +55,10 @@ class ZaiProfile(ProviderProfile):is_5_2 = _has_token(model, _GLM_5_2_TOKENS)if not _model_supports_thinking(model) and not is_5_2:return extra_body, top_level-# Only emit when the user expressed a preference (server default = enabled).if isinstance(reasoning_config, dict):enabled = reasoning_config.get("enabled") is not Falseextra_body["thinking"] = {"type": "enabled" if enabled else "disabled"}-if is_5_2:effort = _glm_5_2_reasoning_effort(reasoning_config, model=model)if effort is not None: