refactor(reasoning): unify per-model reasoning resolution behind a single chokepoint

Collapse the six per-surface copies of override-then-global resolution
(CLI startup, gateway, TUI, cron, /model switch, fallback activation)
onto one shared resolve_reasoning_config() in hermes_constants.

Also fixes the gateway resolving reasoning against config model.default
instead of the session's effective model: after a session-only /model
switch, the switched model's override now applies (gateway message paths
pass the resolved session model through _resolve_session_reasoning_config;
/reasoning status reads the session model override).

Cleanup: drop docs/PER_MODEL_REASONING.md (duplicates the website docs
page), drop the change-detector _config_version test (no bump needed —
deep-merge handles new keys), remove a stale plan-reference comment.

Adds chokepoint contract tests (13) and gateway session-effective-model
regression tests (2).
This commit is contained in:
Teknium 2026-07-14 07:16:54 -07:00
parent d9cdb81923
commit e81d18dfb4
11 changed files with 302 additions and 253 deletions

17
cli.py
View file

@ -3917,19 +3917,10 @@ class HermesCLI(CLIAgentSetupMixin, CLICommandsMixin):
)
# Reasoning config (OpenRouter reasoning effort level)
# Per-model override takes precedence over global effort (Closes #21256).
_reasoning_overrides = CLI_CONFIG["agent"].get("reasoning_overrides", {}) or {}
from hermes_constants import resolve_per_model_reasoning_effort
_per_model_reasoning = resolve_per_model_reasoning_effort(
self.model, _reasoning_overrides
)
self.reasoning_config = (
_per_model_reasoning
if _per_model_reasoning is not None
else _parse_reasoning_config(
CLI_CONFIG["agent"].get("reasoning_effort", "")
)
)
# Per-model override > global reasoning_effort — resolved through the
# shared chokepoint in hermes_constants (Closes #21256).
from hermes_constants import resolve_reasoning_config
self.reasoning_config = resolve_reasoning_config(CLI_CONFIG, self.model)
self.service_tier = _parse_service_tier_config(
CLI_CONFIG["agent"].get("service_tier", "")
)