The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(providers): route Actual through chat completions (E-1047)
Justin Benningtond7b0a72c2a02
diff --git a/agent/agent_init.py b/agent/agent_init.pyindex cd36a64bd7b..33956ff539a 100644--- a/agent/agent_init.py+++ b/agent/agent_init.py@@ -373,7 +373,9 @@ _EXPLICIT_API_MODES = {def _resolve_api_mode(agent, api_mode, provider_name, base_url):"""Set ``agent.api_mode`` (and provider rewrites) — ordered ladder, first match wins."""host, url = agent._base_url_hostname, agent._base_url_lower- if api_mode in _EXPLICIT_API_MODES:+ if agent.provider == "actual":+ agent.api_mode = "chat_completions"+ elif api_mode in _EXPLICIT_API_MODES:agent.api_mode = api_modeelif agent.provider in {"openai-codex", "xai", "xai-oauth"}:agent.api_mode = "codex_responses"diff --git a/agent/agent_runtime_helpers.py b/agent/agent_runtime_helpers.pyindex 43e862e52ec..b5de7142991 100644--- a/agent/agent_runtime_helpers.py+++ b/agent/agent_runtime_helpers.py@@ -1691,6 +1691,17 @@ def create_openai_client(agent, client_kwargs: dict, *, reason: str, shared: boo# that specific path; this copy locks the contract so future transport/keepalive work can't reintroduce# the same class of bug.client_kwargs = dict(client_kwargs)+ try:+ from providers import get_provider_profile++ profile = get_provider_profile(getattr(agent, "provider", ""))+ if profile is not None:+ for key, value in profile.build_client_kwargs_extras(+ base_url=client_kwargs.get("base_url", "")+ ).items():+ client_kwargs.setdefault(key, value)+ except Exception:+ _ra().logger.debug("Provider client-kwargs hook skipped", exc_info=True)# The MoA virtual provider has no OpenAI wire endpoint; the facade *is* the client. Rebuild the# facade, never a native client (TypeError; relay re-wire).# Rebuilding a native OpenAI client while agent.provider == "moa" (client replacement, stream-retry pool@@ -1703,7 +1714,10 @@ def create_openai_client(agent, client_kwargs: dict, *, reason: str, shared: booreturn build_moa_facade(agent, getattr(agent, "model", None) or "default")ssl_ca_cert = client_kwargs.pop("ssl_ca_cert", None)ssl_verify_cfg = client_kwargs.pop("ssl_verify", None)- httpx_verify = resolve_httpx_verify(ca_bundle=ssl_ca_cert, ssl_verify=ssl_verify_cfg)+ httpx_verify = resolve_httpx_verify(+ ca_bundle=ssl_ca_cert, ssl_verify=ssl_verify_cfg,+ base_url=str(client_kwargs.get("base_url", "")),+ )_validate_proxy_env_urls()_validate_base_url(client_kwargs.get("base_url"))# Provider-supplied client (registration seam): a provider whose wire protocol is notdiff --git a/agent/auxiliary_client.py b/agent/auxiliary_client.pyindex e8739ee816e..2f643b67105 100644--- a/agent/auxiliary_client.py+++ b/agent/auxiliary_client.py@@ -4472,11 +4472,11 @@ def _log_once_debug(seen: set, key: Any, msg: str, *args: Any) -> None:def _wrap_transport(req: _ResolveRequest, client_obj: Any, final_model_str: str,base_url_str: str = "", api_key_str: str = ""):"""Wrap a plain OpenAI client in the right transport adapter; specialized wrappers pass through.- Codex (Responses API): explicit ``api_mode=codex_responses`` (or provider ``actual``), else — with no+ Codex (Responses API): explicit ``api_mode=codex_responses``, else — with noexplicit api_mode — api.openai.com + codex model. Anthropic (Messages): ``api_mode=anthropic_messages``,any ``/anthropic`` suffix, ``api.kimi.com/coding``, or ``api.anthropic.com``."""needs_codex = not (isinstance(client_obj, CodexAuxiliaryClient) or req.raw_codex) and (- req.provider == "actual" or req.api_mode == "codex_responses"+ req.api_mode == "codex_responses"or (not req.api_mode and base_url_hostname(base_url_str) == "api.openai.com"and "codex" in (final_model_str or "").lower()))diff --git a/hermes_cli/auth.py b/hermes_cli/auth.pyindex 64eb64a2a60..e0cd0b81ca5 100644--- a/hermes_cli/auth.py+++ b/hermes_cli/auth.py@@ -128,7 +128,7 @@ def is_actual_local_base_url(base_url: str) -> bool:def normalize_actual_base_url(base_url: str) -> str:"""Return Actual's OpenAI-compatible base URL (hosted api.actual.inc or the loopback local server;- both expose a /v1 surface for the Responses transport)."""+ both expose a /v1 surface for the selected OpenAI-compatible transport)."""url = str(base_url or "").strip().rstrip("/")if not url:return DEFAULT_ACTUAL_BASE_URL@@ -1794,6 +1794,14 @@ def get_xai_oauth_auth_status() -> Dict[str, Any]:def _provider_env_base_url(pconfig: ProviderConfig) -> str:+ if pconfig.id == "actual":+ from hermes_cli.providers import normalize_provider++ model = read_raw_config().get("model")+ if isinstance(model, dict) and normalize_provider(str(model.get("provider") or "")) == "actual":+ configured_url = str(model.get("base_url") or "").strip()+ if configured_url:+ return configured_urlreturn os.getenv(pconfig.base_url_env_var, "").strip() if pconfig.base_url_env_var else ""diff --git a/hermes_cli/config_defaults.py b/hermes_cli/config_defaults.pyindex 10e58918cc1..665a458135a 100644--- a/hermes_cli/config_defaults.py+++ b/hermes_cli/config_defaults.py@@ -2456,9 +2456,6 @@ OPTIONAL_ENV_VARS = {"GMI_BASE_URL": _base_url("GMI Cloud"),"ACTUAL_API_KEY": _prov("Actual Computer inference key (ac_...)","Actual Computer inference key", "https://actual.inc/user/keys"),- "ACTUAL_BASE_URL": _prov(- "Actual Computer base URL override (set to http://127.0.0.1:8080 for the local offline "- "daemon)", "Actual Computer base URL (leave empty for hosted relay)", None, password=False),"FIREWORKS_API_KEY": _prov("Fireworks AI API key", "Fireworks AI API key","https://app.fireworks.ai/settings/users/api-keys"),"MINIMAX_API_KEY": _prov("MiniMax API key (international)", "MiniMax API key",diff --git a/hermes_cli/main.py b/hermes_cli/main.pyindex 29af92d01e9..24988010e5b 100644--- a/hermes_cli/main.py+++ b/hermes_cli/main.py@@ -141,6 +141,7 @@ def _run_and_exit_oneshot(skills: object = None,usage_file: object = None,resume: object = None,+ reasoning: object = None,) -> None:try:from hermes_cli.oneshot import run_oneshot@@ -153,6 +154,7 @@ def _run_and_exit_oneshot(skills=skills,usage_file=usage_file,resume=resume,+ reasoning=reasoning,)except KeyboardInterrupt:rc = 130@@ -2915,6 +2917,7 @@ def _run_oneshot_from_args(args) -> None:skills=getattr(args, "skills", None),usage_file=getattr(args, "usage_file", None),resume=getattr(args, "resume", None),+ reasoning=getattr(args, "reasoning", None),)diff --git a/hermes_cli/model_setup_flows.py b/hermes_cli/model_setup_flows.pyindex 0f1b5acb34c..b97ad50ceb3 100644--- a/hermes_cli/model_setup_flows.py+++ b/hermes_cli/model_setup_flows.py@@ -32,7 +32,7 @@ def _env_base_url(base_url_env: str) -> str:return get_env_value(base_url_env) or os.getenv(base_url_env, "")-def _prompt_base_url_override(effective_base: str, base_url_env: str) -> str:+def _prompt_base_url_override(effective_base: str, base_url_env: str, *, persist_env: bool = True) -> str:"""Optional ``Base URL [...]`` prompt; a valid override is saved to *base_url_env*."""from hermes_cli.config import save_env_valueoverride = _ask(f"Base URL [{effective_base}]: ", cancel_msg="", on_cancel="")@@ -40,7 +40,8 @@ def _prompt_base_url_override(effective_base: str, base_url_env: str) -> str:if not override.startswith(_HTTP):print(" Invalid URL — must start with http:// or https://. Keeping current value.")else:- save_env_value(base_url_env, override)+ if persist_env:+ save_env_value(base_url_env, override)return overridereturn effective_base@@ -931,6 +932,11 @@ def _model_flow_api_key_provider(config, provider_id, current_model=""):current_base = str(_m.get("base_url") or "").strip()effective_base = current_base or pconfig.inference_base_url+ if provider_id == "actual":+ model_cfg = config.get("model") or {}+ if isinstance(model_cfg, dict) and model_cfg.get("provider") == provider_id:+ effective_base = str(model_cfg.get("base_url") or "").strip() or effective_base+if provider_id == "zai":# Four official endpoints with separate billing paths — a picker lets users match# the endpoint to their key type.@@ -939,7 +945,7 @@ def _model_flow_api_key_provider(config, provider_id, current_model=""):save_env_value(base_url_env, chosen_base)effective_base = chosen_baseelse:- effective_base = _prompt_base_url_override(effective_base, base_url_env)+ effective_base = _prompt_base_url_override(effective_base, base_url_env, persist_env=provider_id != "actual")model_list = _api_key_provider_model_list(provider_id, pconfig, existing_key, key_env, effective_base)if is_opencode:diff --git a/hermes_cli/oneshot.py b/hermes_cli/oneshot.pyindex a6ed16273ce..18f58dc8264 100644--- a/hermes_cli/oneshot.py+++ b/hermes_cli/oneshot.py@@ -168,6 +168,7 @@ def run_oneshot(skills: object = None,usage_file: Optional[str] = None,resume: Optional[str] = None,+ reasoning: object = None,) -> int:"""Execute a single prompt and print only the final content block.@@ -223,6 +224,7 @@ def run_oneshot(use_config_toolsets=use_config_toolsets,skills=skills,resume=resume,+ reasoning=reasoning,)except BaseException as exc: # noqa: BLE001# Capture anything escaping the agent (OSError from prompt_toolkit on a non-TTY pipe,@@ -413,6 +415,7 @@ def _run_agent(use_config_toolsets: bool = True,skills: object = None,resume: Optional[str] = None,+ reasoning: object = None,) -> tuple[str, dict]:"""Build an AIAgent exactly like a normal CLI chat turn, run one conversation, and return``(final_response, run_result)``. Imports are local to keep CLI startup cheap."""@@ -438,6 +441,16 @@ def _run_agent(if choice.api_mode:runtime["api_mode"] = choice.api_mode+ from hermes_constants import parse_reasoning_effort, resolve_reasoning_config++ reasoning_config = resolve_reasoning_config(cfg, choice.model)+ if reasoning is not None and str(reasoning).strip():+ parsed_reasoning = parse_reasoning_effort(reasoning)+ if parsed_reasoning is None:+ logging.warning("Unknown --reasoning '%s', keeping the configured level", reasoning)+ else:+ reasoning_config = parsed_reasoning+# sorted() gives stable ordering for config-derived sets; explicit values preserve user order.toolsets_list = _normalize_toolsets(toolsets)if toolsets_list is None and use_config_toolsets:@@ -474,6 +487,7 @@ def _run_agent(credential_pool=runtime.get("credential_pool"),fallback_model=get_fallback_chain(cfg) or None,ephemeral_system_prompt=skills_prompt,+ reasoning_config=reasoning_config,# The only interactive callback wired: no user sits at a terminal. Sudo prompts gate on# HERMES_INTERACTIVE (never set), hook approval via HERMES_ACCEPT_HOOKS=1, dangerous# commands via HERMES_YOLO_MODE=1, skill secret capture degrades gracefully.diff --git a/hermes_cli/providers.py b/hermes_cli/providers.pyindex 69be6306697..3982ea98e6b 100644--- a/hermes_cli/providers.py+++ b/hermes_cli/providers.py@@ -75,7 +75,7 @@ HERMES_OVERLAYS: Dict[str, HermesOverlay] = {base_url_env_var="GMI_BASE_URL"),"fireworks": HermesOverlay(extra_env_vars=("FIREWORKS_API_KEY",),base_url_override="https://api.fireworks.ai/inference/v1"),- "actual": HermesOverlay(transport="codex_responses", extra_env_vars=("ACTUAL_API_KEY", "ACTUAL_BASE_URL"),+ "actual": HermesOverlay(transport="chat_completions", extra_env_vars=("ACTUAL_API_KEY",),base_url_override="https://api.actual.inc/v1", base_url_env_var="ACTUAL_BASE_URL"),"upstage": HermesOverlay(extra_env_vars=("UPSTAGE_API_KEY",), base_url_override="https://api.upstage.ai/v1",base_url_env_var="UPSTAGE_BASE_URL"),diff --git a/hermes_cli/runtime_provider.py b/hermes_cli/runtime_provider.pyindex 17b1b2fe896..a48aa64be9c 100644--- a/hermes_cli/runtime_provider.py+++ b/hermes_cli/runtime_provider.py@@ -206,6 +206,11 @@ def _configured_or_fallback_api_mode(provider: str, model_cfg: Dict[str, Any], b"""Persisted ``model.api_mode`` when it belongs to this provider, else URL/transport fallback.OpenCode Zen/Go serve both anthropic_messages and chat_completions models, so (when``opencode_by_model``) their mode is always re-derived from the effective model."""+ if provider == "actual":+ configured_mode = _configured_api_mode(provider, model_cfg)+ if configured_mode and configured_mode != "chat_completions":+ logger.info("Routing built-in Actual through chat_completions instead of persisted api_mode=%s", configured_mode)+ return "chat_completions"if opencode_by_model and _models.opencode_provider_family(provider) is not None:return _models.opencode_model_api_mode(provider, effective_model)return _configured_api_mode(provider, model_cfg) or _fallback_api_mode(provider, base_url, effective_model)@@ -216,7 +221,7 @@ def _api_key_provider_api_mode(provider: str, model_cfg: Dict[str, Any], api_key"""api_mode for a registry ``api_key`` provider (explicit and env/config paths)."""if provider == "copilot":return _copilot_runtime_api_mode(model_cfg, api_key, target_model=effective_model)- if provider in ("xai", "actual"):+ if provider == "xai":# Ramp Router: Responses-native host — /v1/chat/completions is only a minimal compatibility shim,# while reasoning and caching support live on /v1/responses (docs.router.com/api/endpoint). Mirrors# the host_mandated_api_mode clause in hermes_cli/providers.py so the runtime resolver stays in@@ -252,7 +257,10 @@ def _cfg_provider(model_cfg: Dict[str, Any]) -> str:def _config_base_url_for_provider(model_cfg: Dict[str, Any], provider: str) -> str:"""``model.base_url`` (stripped, no trailing slash) only when ``model.provider`` is``provider`` — a stale base_url must not leak into another provider."""- return str(model_cfg.get("base_url") or "").strip().rstrip("/") if _cfg_provider(model_cfg) == provider else ""+ configured_provider = _cfg_provider(model_cfg)+ if provider == "actual":+ configured_provider = _models.normalize_provider(configured_provider)+ return str(model_cfg.get("base_url") or "").strip().rstrip("/") if configured_provider == provider else ""def _anthropic_base_url_override_ok(base_url: str) -> bool:@@ -337,6 +345,8 @@ def _finalize_base_url(provider: str, api_mode: str, base_url: str) -> str:base_url = _models.normalize_opencode_base_url(provider, api_mode, base_url)if provider == "lmstudio":base_url = auth_mod._normalize_lmstudio_runtime_base_url(base_url)+ if provider == "actual":+ base_url = normalize_actual_base_url(base_url)return base_url@@ -431,6 +441,8 @@ _POOL_ENTRY_SIMPLE_MODES: Dict[str, tuple] = {def _pool_entry_mode_and_url(provider, entry, model_cfg, effective_model, base_url) -> tuple:"""(api_mode, base_url) for a pool entry of ``provider``."""+ if provider == "actual" and str(getattr(entry, "source", "")).startswith("env:"):+ base_url = _config_base_url_for_provider(model_cfg, provider) or base_urlif provider in _POOL_ENTRY_SIMPLE_MODES:api_mode, default_url = _POOL_ENTRY_SIMPLE_MODES[provider]return api_mode, base_url or (default_url() if callable(default_url) else default_url)@@ -570,7 +582,10 @@ def _actual_url(provider: str, base_url: str) -> str:def _explicit_api_key_provider(provider, pconfig, requested_provider, model_cfg, api_key, base_url, target_model):if not base_url:- if provider in {"kimi-coding", "kimi-coding-cn"}:+ if provider == "actual":+ base_url = (_config_base_url_for_provider(model_cfg, provider)+ or resolve_api_key_provider_credentials(provider).get("base_url", ""))+ elif provider in {"kimi-coding", "kimi-coding-cn"}:base_url = resolve_api_key_provider_credentials(provider).get("base_url", "").rstrip("/")else:env_url = _getenv(pconfig.base_url_env_var, "").strip().rstrip("/") if pconfig.base_url_env_var else ""diff --git a/plugins/model-providers/actual/__init__.py b/plugins/model-providers/actual/__init__.pyindex 03a3a500c8f..a0eebc581aa 100644--- a/plugins/model-providers/actual/__init__.py+++ b/plugins/model-providers/actual/__init__.py@@ -1,6 +1,9 @@"""Actual Computer provider profile."""import os+import sys+from typing import Any+from urllib.parse import urlparsefrom providers import register_providerfrom providers.base import ProviderProfile@@ -10,24 +13,85 @@ DEFAULT_ACTUAL_BASE_URL = "https://api.actual.inc/v1"class ActualProfile(ProviderProfile):"""Actual Computer: hosted at api.actual.inc; local (offline-mode client)- inference opted into via ACTUAL_BASE_URL."""+ inference opted into via model.base_url in config.yaml."""++ def build_client_kwargs_extras(self, **context: Any) -> dict[str, Any]:+ base_url = str(context.get("base_url") or self.base_url or "")+ try:+ hostname = (urlparse(base_url).hostname or "").lower().rstrip(".")+ except ValueError:+ return {}+ if sys.platform != "darwin" or hostname != "api.actual.inc":+ return {}+ if any(+ os.getenv(key)+ for key in (+ "HERMES_CA_BUNDLE",+ "SSL_CERT_FILE",+ "REQUESTS_CA_BUNDLE",+ "CURL_CA_BUNDLE",+ )+ ):+ return {}+ import certifi++ return {"ssl_ca_cert": certifi.where()}++ def supported_reasoning_efforts(self, model: str | None) -> tuple[str, ...] | None:+ from agent.reasoning_effort import ACTUAL_RELAY_EFFORTS++ return ACTUAL_RELAY_EFFORTS++ def build_api_kwargs_extras(+ self, *, reasoning_config: dict | None = None, **context: Any+ ) -> tuple[dict[str, Any], dict[str, Any]]:+ if not isinstance(reasoning_config, dict):+ return {}, {}+ from agent.reasoning_effort import clamp_effort, requested_effort++ enabled = reasoning_config.get("enabled") is not False+ if str(reasoning_config.get("effort") or "").strip().lower() == "none":+ enabled = False+ extra_body = {"thinking": {"type": "enabled" if enabled else "disabled"}}+ top_level: dict[str, Any] = {}+ effort = requested_effort(reasoning_config)+ if effort is not None:+ supported = self.supported_reasoning_efforts(context.get("model"))+ clamped = clamp_effort(effort, supported)+ if clamped in (supported or ()):+ top_level["reasoning_effort"] = clamped+ return extra_body, top_leveldef fetch_models(- self, *, api_key: str | None = None, base_url: str | None = None, timeout: float = 8.0+ self,+ *,+ api_key: str | None = None,+ base_url: str | None = None,+ timeout: float = 8.0,) -> list[str] | None:- """ACTUAL_BASE_URL wins over the caller's base_url; bare hosts get ``/v1`` appended."""- from hermes_cli.auth import normalize_actual_base_url+ """Use the selected route, then config.yaml, then the legacy environment override."""+ from hermes_cli.auth import (+ normalize_actual_base_url,+ resolve_api_key_provider_credentials,+ )- base_url = normalize_actual_base_url(os.getenv("ACTUAL_BASE_URL", "").strip() or base_url or self.base_url)+ base_url = normalize_actual_base_url(+ base_url or resolve_api_key_provider_credentials("actual")["base_url"]+ )return super().fetch_models(api_key=api_key, base_url=base_url, timeout=timeout)actual = ActualProfile(- name="actual", aliases=("actual-computer", "actualcomputer", "aci"), display_name="Actual Computer",+ name="actual",+ aliases=("actual-computer", "actualcomputer", "aci"),+ display_name="Actual Computer",description="Actual Computer - hosted inference via api.actual.inc, or local "- "offline inference via ACTUAL_BASE_URL",- signup_url="https://actual.inc", env_vars=("ACTUAL_API_KEY", "ACTUAL_BASE_URL"),- base_url=DEFAULT_ACTUAL_BASE_URL, auth_type="api_key", api_mode="codex_responses",+ "offline inference via model.base_url in config.yaml",+ signup_url="https://actual.inc",+ env_vars=("ACTUAL_API_KEY",),+ base_url=DEFAULT_ACTUAL_BASE_URL,+ auth_type="api_key",+ api_mode="chat_completions",)register_provider(actual)diff --git a/providers/base.py b/providers/base.pyindex b76748f0dcb..b509d36f5a9 100644--- a/providers/base.py+++ b/providers/base.py@@ -178,6 +178,14 @@ class ProviderProfile:"""return {}, {}+ def build_client_kwargs_extras(self, **context: Any) -> dict[str, Any]:+ """Provider-specific OpenAI client keyword arguments.++ Values are defaults: explicit runtime/custom-provider settings win.+ The returned mapping must be cheap to build and must not perform I/O.+ """+ return {}+def default_vision_model(self) -> str | None:"""Return a default vision model id for this provider, or None.diff --git a/run_agent.py b/run_agent.pyindex 99bcccd0e44..c62443588dd 100644--- a/run_agent.py+++ b/run_agent.py@@ -639,7 +639,7 @@ class AIAgent(normalized_provider = (provider or "").strip().lower()# Nous serves GPT-5.x via chat completions (its /v1/responses returns 404); generic custom endpoints# may relay GPT-5 without full Responses semantics — only direct OpenAI/xAI URLs auto-upgrade.- if normalized_provider in ("nous", "custom"):+ if normalized_provider in ("nous", "custom", "actual"):return Falseif normalized_provider == "copilot":try:diff --git a/tests/agent/test_actual_auxiliary_routing.py b/tests/agent/test_actual_auxiliary_routing.pynew file mode 100644index 00000000000..3ee59067e0f--- /dev/null+++ b/tests/agent/test_actual_auxiliary_routing.py@@ -0,0 +1,203 @@+"""Actual background tasks exercise the same configured route as foreground chat."""++import asyncio+from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer+import json+import threading+import time++import pytest+import yaml+++def actual_endpoint():+ requests = []++ class Handler(BaseHTTPRequestHandler):+ def do_POST(self):+ payload = json.loads(self.rfile.read(int(self.headers["Content-Length"])))+ requests.append((self.path, payload))+ if self.path != "/v1/chat/completions":+ self.send_error(404)+ return+ content = (+ '{"title":"Actual background routing"}'+ if "response_format" in payload+ else "The task is complete."+ )+ response = {+ "id": "chatcmpl-background",+ "created": 1,+ "model": payload["model"],+ "object": "chat.completion",+ "choices": [+ {+ "index": 0,+ "message": {"role": "assistant", "content": content},+ "finish_reason": "stop",+ }+ ],+ "usage": {+ "prompt_tokens": 10,+ "completion_tokens": 5,+ "total_tokens": 15,+ },+ }+ if payload.get("stream"):+ response["object"] = "chat.completion.chunk"+ response["choices"][0]["delta"] = response["choices"][0].pop("message")+ body = f"data: {json.dumps(response)}\n\ndata: [DONE]\n\n".encode()+ content_type = "text/event-stream"+ else:+ body = json.dumps(response).encode()+ content_type = "application/json"+ self.send_response(200)+ self.send_header("Content-Type", content_type)+ self.send_header("Content-Length", str(len(body)))+ self.end_headers()+ self.wfile.write(body)++ def log_message(self, *_args):+ pass++ server = ThreadingHTTPServer(("127.0.0.1", 0), Handler)+ thread = threading.Thread(target=server.serve_forever, daemon=True)+ thread.start()+ try:+ yield f"http://127.0.0.1:{server.server_port}", requests+ finally:+ server.shutdown()+ server.server_close()+ thread.join(timeout=5)++[email protected]("aux_provider", ["auto", "actual", "aci", "custom"])[email protected]("use_api_key", [False, True])+def test_actual_background_tasks_reach_chat_completions(+ tmp_path, monkeypatch, actual_endpoint, aux_provider, use_api_key+):+ from agent.auxiliary_client import async_call_llm+ from agent.context_compressor import ContextCompressor+ from agent.title_generator import generate_title+ from hermes_cli.runtime_provider import resolve_runtime_provider++ base_url, requests = actual_endpoint+ monkeypatch.setenv("HERMES_HOME", str(tmp_path))+ if use_api_key:+ monkeypatch.setenv("ACTUAL_API_KEY", "actual-test-key")+ monkeypatch.setenv("ACTUAL_BASE_URL", "http://127.0.0.1:1")+ aux_model = "override-model" if aux_provider == "custom" else "test-model"+ config = {+ "model": {+ "provider": "aci" if aux_provider == "aci" else "actual",+ "default": "test-model",+ "base_url": base_url,+ },+ "auxiliary": {+ task: {+ "provider": aux_provider,+ "model": aux_model,+ **({"base_url": base_url + "/v1"} if aux_provider == "custom" else {}),+ }+ for task in (+ "compression",+ "title_generation",+ "session_search",+ )+ },+ }+ (tmp_path / "config.yaml").write_text(yaml.safe_dump(config), encoding="utf-8")+ runtime = resolve_runtime_provider(requested="actual")+ runtime["model"] = "test-model"+ assert runtime["api_mode"] == "chat_completions"+ assert (+ generate_title(+ "Stale conversation", main_runtime=runtime, runtime_validator=lambda: False+ )+ is None+ )+ assert requests == []+ assert (+ generate_title("Check the background routing", timeout=5, main_runtime=runtime)+ == "Actual background routing"+ )+ compressor = ContextCompressor(+ model=runtime["model"],+ provider=runtime["provider"],+ api_key=runtime["api_key"],+ base_url=runtime["base_url"],+ api_mode=runtime["api_mode"],+ config_context_length=32768,+ quiet_mode=True,+ )+ assert (+ compressor._call_summary_llm("Summarize this conversation.", time.monotonic())+ == "The task is complete."+ )+ response = asyncio.run(+ async_call_llm(+ task="session_search",+ messages=[{"role": "user", "content": "Summarize the results."}],+ main_runtime=runtime,+ timeout=5,+ )+ )+ assert response.choices[0].message.content == "The task is complete."+ assert len(requests) == 3+ assert all(+ path == "/v1/chat/completions" and payload["model"] == aux_model+ for path, payload in requests+ )++[email protected]("override", ["", "http://127.0.0.1:8081", "invalid-url"])+def test_actual_setup_keeps_provider_settings_in_yaml(tmp_path, monkeypatch, override):+ from hermes_cli import config as config_module+ from hermes_cli import model_setup_flows as setup+ from hermes_cli.auth import resolve_api_key_provider_credentials+ from hermes_cli.runtime_provider import resolve_runtime_provider+ from providers import get_provider_profile++ monkeypatch.setenv("HERMES_HOME", str(tmp_path))+ monkeypatch.setenv("ACTUAL_API_KEY", "actual-test-key")+ monkeypatch.setenv("ACTUAL_BASE_URL", "http://127.0.0.1:8089")+ configured_url = "http://127.0.0.1:8080"+ raw = {+ "model": {+ "provider": "actual",+ "default": "old-model",+ "base_url": configured_url,+ }+ }+ config_path = tmp_path / "config.yaml"+ config_path.write_text(yaml.safe_dump(raw), encoding="utf-8")+ env_path = tmp_path / ".env"+ env_path.write_text("ACTUAL_API_KEY=actual-test-key\n", encoding="utf-8")+ monkeypatch.setattr(+ setup,+ "_ensure_flow_api_key",+ lambda *_a, **_kw: ("actual-test-key", "actual-test-key", False),+ )+ monkeypatch.setattr(setup, "_ask", lambda *_a, **_kw: override)+ monkeypatch.setattr(setup, "_api_key_provider_model_list", lambda *_a: [])+ monkeypatch.setattr(setup, "_pick_model_or_prompt", lambda *_a, **_kw: "test-model")+ setup._model_flow_api_key_provider(config_module.load_config(), "actual")++ expected_url = override if override.startswith("http://") else configured_url+ saved = yaml.safe_load(config_path.read_text(encoding="utf-8"))+ assert saved["model"]["provider"] == "actual"+ assert saved["model"]["base_url"] == expected_url+ assert saved["model"]["default"] == "test-model"+ assert env_path.read_text(encoding="utf-8") == "ACTUAL_API_KEY=actual-test-key\n"+ assert get_provider_profile("actual").env_vars == ("ACTUAL_API_KEY",)+ assert "ACTUAL_BASE_URL" not in config_module.OPTIONAL_ENV_VARS+ assert "ACTUAL_API_MODE" not in config_module.OPTIONAL_ENV_VARS+ assert (+ resolve_api_key_provider_credentials("actual")["base_url"]+ == expected_url + "/v1"+ )+ for kwargs in ({}, {"explicit_api_key": "actual-test-key"}):+ runtime = resolve_runtime_provider(requested="actual", **kwargs)+ assert runtime["base_url"] == expected_url + "/v1"+ assert runtime["api_mode"] == "chat_completions"diff --git a/tests/hermes_cli/test_actual_provider.py b/tests/hermes_cli/test_actual_provider.pyindex e373b1eb18c..4c5e12ffac4 100644--- a/tests/hermes_cli/test_actual_provider.py+++ b/tests/hermes_cli/test_actual_provider.py@@ -3,8 +3,12 @@from __future__ import annotationsimport json+import logging+from pathlib import Pathfrom unittest.mock import patch+import pytest+from agent.auxiliary_client import _normalize_aux_providerfrom hermes_cli import runtime_provider as rpfrom hermes_cli.auth import (@@ -27,6 +31,7 @@ from providers import get_provider_profiledef _clear_actual_env(monkeypatch):monkeypatch.delenv("ACTUAL_API_KEY", raising=False)monkeypatch.delenv("ACTUAL_BASE_URL", raising=False)+ monkeypatch.delenv("ACTUAL_API_MODE", raising=False)def test_actual_aliases_and_profile_metadata():@@ -36,15 +41,15 @@ def test_actual_aliases_and_profile_metadata():assert profile.name == "actual"assert profile.display_name == "Actual Computer"assert profile.base_url == DEFAULT_ACTUAL_BASE_URL- assert profile.api_mode == "codex_responses"+ assert profile.api_mode == "chat_completions"assert profile.auth_type == "api_key"- assert profile.env_vars == ("ACTUAL_API_KEY", "ACTUAL_BASE_URL")+ assert profile.env_vars == ("ACTUAL_API_KEY",)assert normalize_overlay_provider("aci") == "actual"assert normalize_model_provider("actualcomputer") == "actual"assert resolve_provider("actual-computer") == "actual"assert _normalize_aux_provider("aci") == "actual"assert get_label("actual") == "Actual Computer"- assert determine_api_mode("actual", "https://api.actual.inc") == "codex_responses"+ assert determine_api_mode("actual", "https://api.actual.inc") == "chat_completions"def test_actual_base_url_normalization():@@ -108,11 +113,60 @@ def test_actual_runtime_uses_hosted_default(monkeypatch):resolved = rp.resolve_runtime_provider(requested="actual")assert resolved["provider"] == "actual"- assert resolved["api_mode"] == "codex_responses"+ assert resolved["api_mode"] == "chat_completions"assert resolved["api_key"] == "actual-test-key"assert resolved["base_url"] == DEFAULT_ACTUAL_BASE_URL+def test_actual_runtime_repairs_stale_responses_mode(monkeypatch, caplog):+ _clear_actual_env(monkeypatch)+ caplog.set_level(logging.INFO, logger="hermes_cli.auth")+ monkeypatch.setenv("ACTUAL_API_KEY", "actual-test-key")+ monkeypatch.setattr(+ rp,+ "_get_model_config",+ lambda: {+ "provider": "actual",+ "default": "actual/test-model",+ "api_mode": "codex_responses",+ },+ )++ resolved = rp.resolve_runtime_provider(requested="actual")+ explicit = rp.resolve_runtime_provider(+ requested="actual",+ explicit_api_key="actual-test-key",+ explicit_base_url="https://api.actual.inc/v1",+ )++ assert resolved["api_mode"] == "chat_completions"+ assert explicit["api_mode"] == "chat_completions"+ assert "persisted api_mode=codex_responses" in caplog.text+++def test_actual_runtime_ignores_legacy_mode_environment(monkeypatch):+ _clear_actual_env(monkeypatch)+ monkeypatch.setenv("ACTUAL_API_KEY", "actual-test-key")+ monkeypatch.setenv("ACTUAL_API_MODE", "codex_responses")+ monkeypatch.setattr(+ rp,+ "_get_model_config",+ lambda: {"provider": "actual", "default": "actual/test-model"},+ )++ resolved = rp.resolve_runtime_provider(requested="actual")++ assert resolved["api_mode"] == "chat_completions"+++def test_actual_hostname_detection_preserves_custom_responses_route():+ base_url = "https://api.actual.inc/v1"++ assert rp._detect_api_mode_for_url(base_url) == "codex_responses"+ assert rp._fallback_api_mode("custom", base_url) == "codex_responses"+ assert rp._resolve_plain_custom_api_mode({}, base_url) == "codex_responses"++def test_actual_runtime_uses_local_env_without_key(monkeypatch):_clear_actual_env(monkeypatch)monkeypatch.setenv("ACTUAL_BASE_URL", "http://127.0.0.1:8080")@@ -125,7 +179,7 @@ def test_actual_runtime_uses_local_env_without_key(monkeypatch):resolved = rp.resolve_runtime_provider(requested="actual")assert resolved["provider"] == "actual"- assert resolved["api_mode"] == "codex_responses"+ assert resolved["api_mode"] == "chat_completions"assert resolved["api_key"] == ACTUAL_LOCAL_NOAUTH_PLACEHOLDERassert resolved["base_url"] == DEFAULT_ACTUAL_LOCAL_BASE_URL@@ -145,7 +199,7 @@ def test_actual_runtime_uses_local_config_without_key(monkeypatch):resolved = rp.resolve_runtime_provider(requested="actual")assert resolved["provider"] == "actual"- assert resolved["api_mode"] == "codex_responses"+ assert resolved["api_mode"] == "chat_completions"assert resolved["api_key"] == ACTUAL_LOCAL_NOAUTH_PLACEHOLDERassert resolved["base_url"] == DEFAULT_ACTUAL_LOCAL_BASE_URL@@ -165,7 +219,7 @@ def test_actual_runtime_normalizes_explicit_hosted_base_url(monkeypatch):)assert resolved["provider"] == "actual"- assert resolved["api_mode"] == "codex_responses"+ assert resolved["api_mode"] == "chat_completions"assert resolved["api_key"] == "actual-test-key"assert resolved["base_url"] == DEFAULT_ACTUAL_BASE_URLassert resolved["source"] == "explicit"@@ -322,36 +376,448 @@ def test_actual_hosted_model_ids_do_not_probe_without_credentials(monkeypatch):fetch.assert_not_called()-def test_actual_codex_transport_clamps_reasoning_effort():- """Actual's SGLang/vLLM backends only accept none/low/medium/high/max.+def test_actual_profile_translates_explicit_reasoning_controls():+ profile = get_provider_profile("actual")- A global xhigh/ultra reasoning_effort must be clamped before the wire,- otherwise every request fails with a wrapped HTTP 400. Regression for- the field-reported reasoning_effort trap.- """- from agent.transports.codex import ResponsesApiTransport-- t = ResponsesApiTransport()- for requested, expected in (("xhigh", "high"), ("ultra", "max"), ("high", "high")):- kwargs = t.build_kwargs(- model="glm-5.2-nvfp4",- messages=[{"role": "user", "content": "hi"}],- tools=None,+ assert profile.build_api_kwargs_extras(reasoning_config=None) == ({}, {})+ assert profile.supported_reasoning_efforts("zai-org/GLM-5.3") == (+ "none",+ "low",+ "medium",+ "high",+ "max",+ )+ for config, expected_toggle, expected_effort in (+ ({"enabled": True, "effort": "high"}, "enabled", "high"),+ ({"enabled": True, "effort": "xhigh"}, "enabled", "high"),+ ({"enabled": True, "effort": "ultra"}, "enabled", "max"),+ ({"enabled": False, "effort": "high"}, "disabled", None),+ ({"enabled": True, "effort": "none"}, "disabled", "none"),+ ):+ extra_body, top_level = profile.build_api_kwargs_extras(+ reasoning_config=config,+ model="zai-org/GLM-5.3",+ )+ assert extra_body == {"thinking": {"type": expected_toggle}}+ if expected_effort is None:+ assert "reasoning_effort" not in top_level+ else:+ assert top_level["reasoning_effort"] == expected_effort++[email protected]_only+def test_actual_hosted_client_uses_scoped_macos_certifi(monkeypatch):+ import certifi++ profile = get_provider_profile("actual")++ assert profile.build_client_kwargs_extras(base_url=DEFAULT_ACTUAL_BASE_URL) == {+ "ssl_ca_cert": certifi.where()+ }+ assert (+ profile.build_client_kwargs_extras(base_url=DEFAULT_ACTUAL_LOCAL_BASE_URL) == {}+ )++[email protected]_only+def test_actual_client_tls_default_does_not_override_explicit_config(monkeypatch):+ from agent.agent_runtime_helpers import create_openai_client++ captured: list[dict] = []++ def fake_resolve_httpx_verify(**kwargs):+ captured.append(kwargs)+ return "resolved-verify"++ class FakeAgent:+ provider = "actual"++ @staticmethod+ def _build_keepalive_http_client(base_url, *, verify):+ assert base_url == DEFAULT_ACTUAL_BASE_URL+ assert verify == "resolved-verify"+ return "http-client"++ @staticmethod+ def _client_log_context():+ return "test"++ monkeypatch.setattr(+ "agent.ssl_verify.resolve_httpx_verify", fake_resolve_httpx_verify+ )+ monkeypatch.setattr("agent.auxiliary_client._validate_proxy_env_urls", lambda: None)+ monkeypatch.setattr("agent.auxiliary_client._validate_base_url", lambda _url: None)+ monkeypatch.setattr("agent.process_bootstrap.OpenAI", lambda **kwargs: kwargs)++ defaults = create_openai_client(+ FakeAgent(),+ {"api_key": "test", "base_url": DEFAULT_ACTUAL_BASE_URL},+ reason="test",+ shared=False,+ )+ explicit = create_openai_client(+ FakeAgent(),+ {+ "api_key": "test",+ "base_url": DEFAULT_ACTUAL_BASE_URL,+ "ssl_ca_cert": "/explicit/corporate-ca.pem",+ },+ reason="test",+ shared=False,+ )++ assert Path(captured[0]["ca_bundle"]).name == "cacert.pem"+ assert captured[0]["base_url"] == DEFAULT_ACTUAL_BASE_URL+ assert captured[1]["ca_bundle"] == "/explicit/corporate-ca.pem"+ assert defaults["http_client"] == "http-client"+ assert explicit["http_client"] == "http-client"+++def test_actual_oneshot_reasoning_override_reaches_agent(monkeypatch):+ from hermes_cli import oneshot++ captured = {}++ class FakeAgent:+ def __init__(self, **kwargs):+ captured.update(kwargs)+ self._session_messages = []++ def run_conversation(self, _prompt, **_kwargs):+ return {"final_response": "ok"}++ def shutdown_memory_provider(self, *_args):+ return None++ def close(self):+ return None++ monkeypatch.setattr("hermes_cli.config.load_config", lambda: {})+ monkeypatch.setattr(+ "hermes_cli.runtime_provider.resolve_runtime_provider",+ lambda **_kwargs: {+ "api_key": "actual-test-key",+ "base_url": DEFAULT_ACTUAL_BASE_URL,+ "provider": "actual",+ "requested_provider": "actual",+ "api_mode": "chat_completions",+ },+ )+ monkeypatch.setattr(+ "hermes_cli.mcp_startup.ensure_mcp_discovery_before_agent_build",+ lambda **_kwargs: None,+ )+ monkeypatch.setattr(oneshot, "_create_session_db_for_oneshot", lambda: None)+ monkeypatch.setattr(oneshot, "get_fallback_chain", lambda _cfg: [])+ monkeypatch.setattr("run_agent.AIAgent", FakeAgent)++ response, _result = oneshot._run_agent(+ "hello",+ model="zai-org/GLM-5.3",+ provider="actual",+ reasoning="ultra",+ toolsets=["terminal"],+ use_config_toolsets=False,+ )++ assert response == "ok"+ assert captured["reasoning_config"] == {"enabled": True, "effort": "ultra"}+++def test_oneshot_dispatch_forwards_reasoning_override(monkeypatch):+ from hermes_cli import main as main_mod+ from hermes_cli import oneshot++ captured = {}++ def fake_run_oneshot(prompt, **kwargs):+ captured["prompt"] = prompt+ captured.update(kwargs)+ return 0++ class OneshotExit(Exception):+ pass++ def fake_exit(_rc):+ raise OneshotExit++ monkeypatch.setattr(oneshot, "run_oneshot", fake_run_oneshot)+ monkeypatch.setattr(main_mod, "_cleanup_oneshot_runtime", lambda: None)+ monkeypatch.setattr(main_mod, "_exit_after_oneshot", fake_exit)++ with pytest.raises(OneshotExit):+ main_mod._run_and_exit_oneshot(+ "hello",+ model="zai-org/GLM-5.3",+ provider="actual",+ reasoning="high",+ )++ assert captured["reasoning"] == "high"+++def test_actual_agent_side_routing_keeps_chat_completions_for_any_model():+ from run_agent import AIAgent++ for model in ("qwen3.8-27b-Q4_K_M", "zai-org/GLM-5.3", "gpt-5.4"):+ assert not AIAgent._provider_model_requires_responses_api(+ model,+ provider=" Actual ",+ )+++def test_actual_agent_init_repairs_stale_responses_mode():+ from run_agent import AIAgent++ with (+ patch("model_tools.get_tool_definitions", return_value=[]),+ patch("model_tools.check_toolset_requirements", return_value={}),+ patch("agent.process_bootstrap.OpenAI"),+ ):+ agent = AIAgent(+ api_key="actual-test-key",+ base_url=DEFAULT_ACTUAL_BASE_URL,provider="actual",- reasoning_config={"effort": requested},+ api_mode="codex_responses",+ model="gpt-5.4",+ quiet_mode=True,+ skip_context_files=True,+ skip_memory=True,+ )++ assert agent.api_mode == "chat_completions"+++def test_actual_agent_init_ignores_legacy_mode_environment(monkeypatch):+ from run_agent import AIAgent++ _clear_actual_env(monkeypatch)+ monkeypatch.setenv("ACTUAL_API_MODE", "codex_responses")+ with (+ patch("model_tools.get_tool_definitions", return_value=[]),+ patch("model_tools.check_toolset_requirements", return_value={}),+ patch("agent.process_bootstrap.OpenAI"),+ ):+ agent = AIAgent(+ api_key="actual-test-key",base_url=DEFAULT_ACTUAL_BASE_URL,+ provider="actual",+ api_mode="chat_completions",+ model="zai-org/GLM-5.3",+ quiet_mode=True,+ skip_context_files=True,+ skip_memory=True,+ )++ assert agent.api_mode == "chat_completions"+++def test_actual_chat_completions_wire_replays_reasoning_through_tool_turn(+ monkeypatch,+):+ import http.server+ import threading++ from openai import OpenAI++ from agent.transports.chat_completions import ChatCompletionsTransport++ requests: list[tuple[str, dict]] = []++ class _Handler(http.server.BaseHTTPRequestHandler):+ def do_POST(self):+ length = int(self.headers.get("Content-Length", "0"))+ request = json.loads(self.rfile.read(length))+ requests.append((self.path, request))++ if len(requests) == 1:+ message = {+ "role": "assistant",+ "content": None,+ "reasoning": "I should call the probe tool.",+ "reasoning_content": "I should call the probe tool.",+ "tool_calls": [+ {+ "id": "call_actual_probe",+ "type": "function",+ "function": {+ "name": "actual_probe",+ "arguments": '{"value":"ok"}',+ },+ }+ ],+ }+ finish_reason = "tool_calls"+ else:+ message = {+ "role": "assistant",+ "content": "ACTUAL_CHAT_OK",+ "reasoning": "The tool result confirms the answer.",+ "reasoning_content": "The tool result confirms the answer.",+ }+ finish_reason = "stop"++ body = json.dumps({+ "id": f"chatcmpl-actual-{len(requests)}",+ "object": "chat.completion",+ "created": 1,+ "model": request["model"],+ "choices": [+ {+ "index": 0,+ "message": message,+ "finish_reason": finish_reason,+ }+ ],+ "usage": {+ "prompt_tokens": 10,+ "completion_tokens": 5,+ "total_tokens": 15,+ },+ }).encode()+ self.send_response(200)+ self.send_header("Content-Type", "application/json")+ self.send_header("Content-Length", str(len(body)))+ self.end_headers()+ self.wfile.write(body)++ def log_message(self, *_args):+ pass++ server = http.server.HTTPServer(("127.0.0.1", 0), _Handler)+ thread = threading.Thread(target=server.serve_forever, daemon=True)+ thread.start()++ try:+ _clear_actual_env(monkeypatch)+ base_url = f"http://127.0.0.1:{server.server_address[1]}/v1"+ monkeypatch.setenv("ACTUAL_BASE_URL", base_url)+ monkeypatch.setattr(+ rp,+ "_get_model_config",+ lambda: {"provider": "actual", "default": "actual/test-model"},+ )++ resolved = rp.resolve_runtime_provider(requested="actual")+ profile = get_provider_profile(resolved["provider"])+ transport = ChatCompletionsTransport()+ client = OpenAI(+ api_key=resolved["api_key"],+ base_url=resolved["base_url"],+ max_retries=0,+ )+ tools = [+ {+ "type": "function",+ "function": {+ "name": "actual_probe",+ "description": "Return the supplied value.",+ "parameters": {+ "type": "object",+ "properties": {"value": {"type": "string"}},+ "required": ["value"],+ },+ },+ }+ ]+ messages = [{"role": "user", "content": "Use actual_probe."}]+ params = {+ "provider_profile": profile,+ "reasoning_config": {"enabled": True, "effort": "high"},+ "base_url": resolved["base_url"],+ }++ first_raw = client.chat.completions.create(+ **transport.build_kwargs(+ model="test-model",+ messages=messages,+ tools=tools,+ **params,+ ))- assert kwargs["reasoning"]["effort"] == expected, requested-- # Other providers keep the wider values untouched on the generic path.- kwargs = t.build_kwargs(- model="some-model",- messages=[{"role": "user", "content": "hi"}],- tools=None,- provider="openai-codex",- reasoning_config={"effort": "xhigh"},+ first = transport.normalize_response(first_raw)+ assert first.reasoning == "I should call the probe tool."+ assert first.reasoning_content == "I should call the probe tool."+ assert first.tool_calls and first.tool_calls[0].name == "actual_probe"++ tool_call = first.tool_calls[0]+ messages.extend([+ {+ "role": "assistant",+ "content": first.content,+ "reasoning": first.reasoning,+ "reasoning_content": first.reasoning_content,+ "tool_calls": [+ {+ "id": tool_call.id,+ "type": "function",+ "function": {+ "name": tool_call.name,+ "arguments": tool_call.arguments,+ },+ }+ ],+ },+ {+ "role": "tool",+ "tool_call_id": tool_call.id,+ "content": '{"value":"ok"}',+ },+ ])+ second_raw = client.chat.completions.create(+ **transport.build_kwargs(+ model="test-model",+ messages=messages,+ tools=tools,+ **params,+ )+ )+ second = transport.normalize_response(second_raw)+ finally:+ server.shutdown()+ thread.join(timeout=2.0)++ assert resolved["api_mode"] == "chat_completions"+ assert [path for path, _ in requests] == [+ "/v1/chat/completions",+ "/v1/chat/completions",+ ]+ assert requests[0][1]["thinking"] == {"type": "enabled"}+ assert requests[0][1]["reasoning_effort"] == "high"+ assert requests[1][1]["reasoning_effort"] == "high"+ replayed = requests[1][1]["messages"][-2]+ assert replayed["reasoning"] == "I should call the probe tool."+ assert replayed["reasoning_content"] == "I should call the probe tool."+ assert second.content == "ACTUAL_CHAT_OK"+ assert second.reasoning == "The tool result confirms the answer."+ assert second.reasoning_content == "The tool result confirms the answer."+++def test_actual_chat_completion_without_reasoning_keeps_final_content():+ from types import SimpleNamespace++ from agent.transports.chat_completions import ChatCompletionsTransport++ response = SimpleNamespace(+ choices=[+ SimpleNamespace(+ finish_reason="stop",+ message=SimpleNamespace(+ content="ACTUAL_NO_REASONING_OK",+ reasoning=None,+ reasoning_content=None,+ tool_calls=None,+ ),+ )+ ],+ usage=None,)- assert kwargs["reasoning"]["effort"] == "xhigh"++ normalized = ChatCompletionsTransport().normalize_response(response)++ assert normalized.content == "ACTUAL_NO_REASONING_OK"+ assert normalized.reasoning is None+ assert normalized.reasoning_content is Nonedef test_actual_runtime_config_local_base_url_without_key(monkeypatch):@@ -370,4 +836,4 @@ def test_actual_runtime_config_local_base_url_without_key(monkeypatch):resolved = rp.resolve_runtime_provider(requested="actual")assert resolved["api_key"] == ACTUAL_LOCAL_NOAUTH_PLACEHOLDER- assert resolved["api_mode"] == "codex_responses"+ assert resolved["api_mode"] == "chat_completions"diff --git a/tests/hermes_cli/test_api_mode_aliases.py b/tests/hermes_cli/test_api_mode_aliases.pyindex 550e009a159..49e88663a1f 100644--- a/tests/hermes_cli/test_api_mode_aliases.py+++ b/tests/hermes_cli/test_api_mode_aliases.py@@ -12,7 +12,7 @@ and an unrecognized value was silently ignored at BOTH consumption sites:* ``hermes_cli.runtime_provider._parse_api_mode`` returned None, with thesame fall-through.-For a host with a detection rule (e.g. api.actual.inc -> codex_responses)+For a host with a detection rule (e.g. api.router.com -> codex_responses)the provider silently switched transports after an update and broke:observed live as every reasoning-bearing request to a relay's untested/v1/responses endpoint failing while chat_completions worked. See thediff --git a/website/docs/integrations/providers.md b/website/docs/integrations/providers.mdindex 1038f33bae4..d4202387a95 100644--- a/website/docs/integrations/providers.md+++ b/website/docs/integrations/providers.md@@ -30,7 +30,7 @@ You need at least one way to connect to an LLM. Use `hermes model` to switch pro| **Arcee AI** | `ARCEEAI_API_KEY` in `~/.hermes/.env` (provider: `arcee`; aliases: `arcee-ai`, `arceeai`) || **GMI Cloud** | `GMI_API_KEY` in `~/.hermes/.env` (provider: `gmi`; aliases: `gmi-cloud`, `gmicloud`) || **Nebius Token Factory** | `NEBIUS_API_KEY` in `~/.hermes/.env` (provider: `nebius-token-factory`; aliases: `nebius`, `nebius-tf`, `tokenfactory`) |-| **Actual Computer** | `ACTUAL_API_KEY` in `~/.hermes/.env` for the hosted relay, or `ACTUAL_BASE_URL=http://127.0.0.1:8080` for the local daemon — no key needed on loopback (provider: `actual`; aliases: `actual-computer`, `actualcomputer`, `aci`) |+| **Actual Computer** | `ACTUAL_API_KEY` in `~/.hermes/.env` for the hosted relay; set `model.base_url` in `config.yaml` for a local daemon (no key needed on loopback). Provider: `actual`; aliases: `actual-computer`, `actualcomputer`, `aci`. || **MiniMax** | `MINIMAX_API_KEY` in `~/.hermes/.env` (provider: `minimax`) || **MiniMax China** | `MINIMAX_CN_API_KEY` in `~/.hermes/.env` (provider: `minimax-cn`) || **xAI (Grok) — Responses API** | `XAI_API_KEY` in `~/.hermes/.env` (provider: `xai`) |@@ -602,7 +602,7 @@ The base URL can be overridden with `GMI_BASE_URL` (default: `https://api.gmi-se### Actual Computer-Your own hardware as a private inference cluster via [Actual Computer](https://actual.inc). Two serving modes, both OpenAI-compatible (Hermes uses the Responses API transport):+Your own hardware as a private inference cluster via [Actual Computer](https://actual.inc). Two serving modes, both OpenAI-compatible (Hermes defaults to Chat Completions so reasoning and final content are returned together):- **Hosted relay** — `https://api.actual.inc`, end-to-end encrypted, routes to *your* cluster. Authenticate with an `ac_` inference key from [actual.inc/user/keys](https://actual.inc/user/keys).- **Local daemon** — on-device at `http://127.0.0.1:8080`, fully offline. No API key needed: Hermes detects the loopback base URL and authenticates with an internal placeholder automatically.@@ -611,20 +611,22 @@ Your own hardware as a private inference cluster via [Actual Computer](https://a# Hosted relay (ACTUAL_API_KEY in ~/.hermes/.env)hermes chat --provider actual --model <model-id-from-your-cluster>-# Local daemon (ACTUAL_BASE_URL=http://127.0.0.1:8080 in ~/.hermes/.env, no key)+# Local daemon (model.base_url in ~/.hermes/config.yaml, no key)hermes chat --provider actual --model <installed-model-name>```-Or set it permanently in `config.yaml`:+Store provider settings in `~/.hermes/config.yaml`; only the hosted API key belongs in `.env`:```yamlmodel:provider: "actual"default: "<model-id>"+ base_url: "http://127.0.0.1:8080/v1" # Omit for the hosted relay.```Notes:- Model IDs come from your cluster's `GET /v1/models` — discover with `hermes model` or `curl -s https://api.actual.inc/v1/models -H "Authorization: Bearer $ACTUAL_API_KEY"`.-- Bare hosts are normalized: `ACTUAL_BASE_URL=http://127.0.0.1:8080` becomes `http://127.0.0.1:8080/v1` automatically.+- Bare hosts in `model.base_url` are normalized: `http://127.0.0.1:8080` becomes `http://127.0.0.1:8080/v1` automatically. The legacy `ACTUAL_BASE_URL` environment variable is a fallback when no Actual URL is configured in YAML.+- The built-in Actual provider uses Chat Completions for chat, compaction, title generation, and other auxiliary tasks. Stale built-in Responses modes are repaired. For an endpoint that requires Responses, configure a named custom provider with `transport: codex_responses` under `providers` in `config.yaml`; per-task `auxiliary.<task>.api_mode` overrides are also supported.- Reasoning effort is clamped to Actual's supported range (`none/low/medium/high/max`) — a global `xhigh`/`ultra` setting will not 400 requests.- Small local models: Hermes' full default toolset plus the system prompt can exceed a 32k context window, producing an empty-stream error from llama.cpp-family servers. Restrict the toolset (`-t file,web`) or load the model with a larger context. The optional `actual-setup` skill (`hermes skills install official/devops/actual-setup`) covers setup and troubleshooting in detail.- Aliases: `actual-computer`, `actualcomputer`, `aci`.diff --git a/website/docs/reference/environment-variables.md b/website/docs/reference/environment-variables.mdindex b78efdd7e96..1296aa2c030 100644--- a/website/docs/reference/environment-variables.md+++ b/website/docs/reference/environment-variables.md@@ -46,7 +46,7 @@ Hermes reads environment variables from the process environment and, for user-ma| `GMI_API_KEY` | GMI Cloud API key ([gmicloud.ai](https://www.gmicloud.ai/)) || `GMI_BASE_URL` | Override GMI Cloud base URL (default: `https://api.gmi-serving.com/v1`) || `ACTUAL_API_KEY` | Actual Computer inference key (`ac_...`, [actual.inc/user/keys](https://actual.inc/user/keys)). Not needed for the local daemon. |-| `ACTUAL_BASE_URL` | Override Actual Computer base URL (default: `https://api.actual.inc/v1`). Set to `http://127.0.0.1:8080` for the local offline daemon — loopback hosts need no API key. |+| `ACTUAL_BASE_URL` | Legacy fallback for the Actual base URL. Configure `model.provider: actual` and `model.base_url` in `config.yaml` instead; the YAML URL takes precedence. Defaults to `https://api.actual.inc/v1`. || `MINIMAX_API_KEY` | MiniMax API key — global endpoint ([minimax.io](https://www.minimax.io)). **Not used by `minimax-oauth`** (OAuth path uses browser login instead). || `MINIMAX_BASE_URL` | Override MiniMax base URL (default: `https://api.minimax.io/anthropic` — Hermes uses MiniMax's Anthropic Messages-compatible endpoint). **Not used by `minimax-oauth`**. || `MINIMAX_CN_API_KEY` | MiniMax API key — China endpoint ([minimaxi.com](https://www.minimaxi.com)). **Not used by `minimax-oauth`** (OAuth path uses browser login instead). |