mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-31 19:16:29 +00:00
Systematic prune per AGENTS.md test policy, one pass over every major test tree (gateway, hermes_cli, tools, agent, run_agent, plugins, cli, cron, tui_gateway, honcho/openviking, root-level): - DELETE: source-reading tests (read_text/getsource on prod files), change-detector tests (exact catalog counts, model-name snapshots, config version literals), mock-echo tests (assert a mock returns what it was told), assertion-free/trivial tests, near-duplicate parametrizations (boundaries + one representative kept), async/sync twin duplicates, cosmetic within-file variations. - KEEP (mandatory): security/redaction/approval guards, message-role alternation invariants, prompt-caching/deterministic-call-id invariants, issue-number regression tests (deduped), E2E tests. - 6 test files deleted outright (script-style/no-assert or fully redundant); conftest.py, fakes/, fixtures/ untouched. - tests/acp/conftest.py added: autouse fixture stubs the live models.dev/GitHub/Copilot/Anthropic inventory fetches that ACP server tests performed on every session create — test_server.py 147s → 3.4s, and the tests are now genuinely hermetic. - Sleep-based slowness shrunk where safe (codex_ttfb_watchdog, compression_concurrent_fork, etc.); no wall-clock assertion tightened. Verification: full hermetic suite via scripts/run_tests.sh — 2439 files, 31,130 tests passed, 0 failed, 0 flaky retries, 315s wall (baseline: 583s wall, 13,564s subprocess CPU).
82 lines
3 KiB
Python
82 lines
3 KiB
Python
"""Tests for per-model reasoning_effort override in TUI gateway _load_reasoning_config."""
|
|
|
|
import pytest
|
|
|
|
import tui_gateway.server as tui_server
|
|
|
|
|
|
class TestTUIPerModelReasoningConfig:
|
|
"""Test tui_gateway _load_reasoning_config respects per-model overrides."""
|
|
|
|
def test_per_model_override_takes_precedence(self, monkeypatch):
|
|
"""Per-model override wins over global reasoning_effort."""
|
|
fake_cfg = {
|
|
"model": {"default": "anthropic/claude-opus-4.5"},
|
|
"agent": {
|
|
"reasoning_effort": "medium",
|
|
"reasoning_overrides": {
|
|
"anthropic/claude-opus-4.5": "xhigh",
|
|
},
|
|
},
|
|
}
|
|
monkeypatch.setattr(tui_server, "_load_cfg", lambda: fake_cfg)
|
|
|
|
result = tui_server._load_reasoning_config()
|
|
assert result is not None
|
|
assert result["enabled"] is True
|
|
assert result["effort"] == "xhigh"
|
|
|
|
def test_global_fallback_when_no_override(self, monkeypatch):
|
|
"""Global reasoning_effort applies when no per-model override matches."""
|
|
fake_cfg = {
|
|
"model": {"default": "gpt-5"},
|
|
"agent": {
|
|
"reasoning_effort": "high",
|
|
"reasoning_overrides": {
|
|
"anthropic/claude-opus-4.5": "xhigh",
|
|
},
|
|
},
|
|
}
|
|
monkeypatch.setattr(tui_server, "_load_cfg", lambda: fake_cfg)
|
|
|
|
result = tui_server._load_reasoning_config()
|
|
assert result is not None
|
|
assert result["effort"] == "high"
|
|
|
|
def test_spelling_tolerant_match(self, monkeypatch):
|
|
"""Override matches even with different spelling (provider prefix)."""
|
|
fake_cfg = {
|
|
"model": {"default": "claude-opus-4.5"},
|
|
"agent": {
|
|
"reasoning_effort": "medium",
|
|
"reasoning_overrides": {
|
|
"anthropic/claude-opus-4.5": "high", # key has prefix, model doesn't
|
|
},
|
|
},
|
|
}
|
|
monkeypatch.setattr(tui_server, "_load_cfg", lambda: fake_cfg)
|
|
|
|
result = tui_server._load_reasoning_config()
|
|
assert result is not None
|
|
assert result["effort"] == "high"
|
|
|
|
def test_parity_with_gateway_loader(self, monkeypatch):
|
|
"""TUI and gateway loaders return identical results for same config."""
|
|
import gateway.run as gateway_run
|
|
|
|
fake_cfg = {
|
|
"model": {"default": "openrouter/anthropic/claude-sonnet-4.6"},
|
|
"agent": {
|
|
"reasoning_effort": "low",
|
|
"reasoning_overrides": {
|
|
"claude-sonnet-4.6": "high",
|
|
},
|
|
},
|
|
}
|
|
monkeypatch.setattr(tui_server, "_load_cfg", lambda: fake_cfg)
|
|
monkeypatch.setattr(gateway_run, "_load_gateway_runtime_config", lambda: fake_cfg)
|
|
|
|
tui_result = tui_server._load_reasoning_config()
|
|
gw_result = gateway_run.GatewayRunner._load_reasoning_config()
|
|
assert tui_result == gw_result
|
|
|