mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-31 19:16:29 +00:00
Second, deeper pass over tools/gateway/hermes_cli plus first pass over the trees wave 1 missed (acp, acp_adapter, skills, computer_use, docker, dashboard, conformance, monitoring, secret_sources, hermes_state, providers). Same rubric as wave 1 (AGENTS.md test policy); security, alternation/caching invariants, issue-number regressions, and E2E kept. Real test-quality fixes found and rooted out along the way: - tests/tools/test_command_guards.py made real auxiliary-LLM HTTPS calls (DEFAULT_CONFIG smart-approval leaked in) — pinned approval mode=manual via autouse fixture: 17.4s → 0.4s. - test_model_switch_custom_providers.py / test_user_providers_model_switch.py silently probed live provider catalogs (~2s/test) — stubbed cached_provider_model_ids/provider_model_ids/fetch_api_models. - test_telegram_noise_filter.py: 15-platform copy-paste matrix over shared gateway.run logic → 3 representative platforms (55s → 3.9s). - test_gateway_shutdown.py: stop()'s 5s interrupt-deadline loop spun on MagicMock agents — interrupt.side_effect now clears _running_agents (22s → 1.0s). - test_gateway_inactivity_timeout.py poll-harness timings shrunk 3-5x (24s → 1.1s); test_mcp_stability.py backoff/SIGTERM-grace sleeps patched (15.4s → 2.5s); test_async_delegation.py negative-drain wait 5s → 0.5s. - test_telegram_init_deadline.py: loop-block margin restored to 1.0s with rationale comment — the watchdog-dump assertion needs the loop blocked well past deadline+grace under parallel load (flaked once in the 40-worker verification run at a 0.2s margin). Verification: full hermetic suite via scripts/run_tests.sh — 2,438 files, 21,718 tests passed, 0 failed, 293.9s wall. Suite totals vs original baseline: 46,820 → 19,757 test functions (−57.8%), wall 583.5s → 293.9s (−50%), subprocess CPU 13,564s → 11,623s.
178 lines
6.8 KiB
Python
178 lines
6.8 KiB
Python
"""Profile-path parity tests: verify profile path produces identical output to legacy flags.
|
|
|
|
Each test calls build_kwargs twice — once with legacy flags, once with provider_profile —
|
|
and asserts the output is identical. This catches any behavioral drift between the two paths.
|
|
"""
|
|
|
|
import pytest
|
|
from agent.transports.chat_completions import ChatCompletionsTransport
|
|
from providers import get_provider_profile
|
|
|
|
|
|
@pytest.fixture
|
|
def transport():
|
|
return ChatCompletionsTransport()
|
|
|
|
|
|
def _msgs():
|
|
return [{"role": "user", "content": "hello"}]
|
|
|
|
|
|
def _max_tokens_fn(n):
|
|
return {"max_completion_tokens": n}
|
|
|
|
|
|
class TestNvidiaProfileParity:
|
|
def test_max_tokens_match(self, transport):
|
|
"""NVIDIA profile sets max_tokens=16384; legacy flag is removed."""
|
|
profile = transport.build_kwargs(
|
|
model="nvidia/nemotron", messages=_msgs(), tools=None,
|
|
provider_profile=get_provider_profile("nvidia"),
|
|
max_tokens_param_fn=_max_tokens_fn,
|
|
)
|
|
assert profile["max_completion_tokens"] == 16384
|
|
|
|
|
|
class TestKimiProfileParity:
|
|
def test_temperature_omitted(self, transport):
|
|
legacy = transport.build_kwargs(
|
|
model="kimi-k2", messages=_msgs(), tools=None,
|
|
provider_profile=get_provider_profile("kimi-coding"), omit_temperature=True,
|
|
)
|
|
profile = transport.build_kwargs(
|
|
model="kimi-k2", messages=_msgs(), tools=None,
|
|
provider_profile=get_provider_profile("kimi"),
|
|
)
|
|
assert "temperature" not in legacy
|
|
assert "temperature" not in profile
|
|
|
|
|
|
def test_thinking_enabled(self, transport):
|
|
# xor contract: explicit effort → reasoning_effort only, no thinking.
|
|
rc = {"enabled": True, "effort": "high"}
|
|
legacy = transport.build_kwargs(
|
|
model="kimi-k2", messages=_msgs(), tools=None,
|
|
provider_profile=get_provider_profile("kimi-coding"), reasoning_config=rc,
|
|
)
|
|
profile = transport.build_kwargs(
|
|
model="kimi-k2", messages=_msgs(), tools=None,
|
|
provider_profile=get_provider_profile("kimi"),
|
|
reasoning_config=rc,
|
|
)
|
|
assert profile["reasoning_effort"] == legacy["reasoning_effort"] == "high"
|
|
assert "thinking" not in profile.get("extra_body", {})
|
|
assert "thinking" not in legacy.get("extra_body", {})
|
|
|
|
|
|
|
|
|
|
class TestOpenRouterProfileParity:
|
|
def test_provider_preferences(self, transport):
|
|
prefs = {"allow": ["anthropic"]}
|
|
legacy = transport.build_kwargs(
|
|
model="anthropic/claude-sonnet-4.6", messages=_msgs(), tools=None,
|
|
provider_profile=get_provider_profile("openrouter"), provider_preferences=prefs,
|
|
)
|
|
profile = transport.build_kwargs(
|
|
model="anthropic/claude-sonnet-4.6", messages=_msgs(), tools=None,
|
|
provider_profile=get_provider_profile("openrouter"),
|
|
provider_preferences=prefs,
|
|
)
|
|
assert profile["extra_body"]["provider"] == legacy["extra_body"]["provider"]
|
|
|
|
def test_reasoning_full_config(self, transport):
|
|
rc = {"enabled": True, "effort": "high"}
|
|
legacy = transport.build_kwargs(
|
|
model="deepseek/deepseek-chat", messages=_msgs(), tools=None,
|
|
provider_profile=get_provider_profile("openrouter"), supports_reasoning=True, reasoning_config=rc,
|
|
)
|
|
profile = transport.build_kwargs(
|
|
model="deepseek/deepseek-chat", messages=_msgs(), tools=None,
|
|
provider_profile=get_provider_profile("openrouter"),
|
|
supports_reasoning=True, reasoning_config=rc,
|
|
)
|
|
assert profile["extra_body"]["reasoning"] == legacy["extra_body"]["reasoning"]
|
|
|
|
|
|
|
|
class TestNousProfileParity:
|
|
def test_tags(self, transport):
|
|
legacy = transport.build_kwargs(
|
|
model="hermes-3", messages=_msgs(), tools=None, provider_profile=get_provider_profile("nous"),
|
|
)
|
|
profile = transport.build_kwargs(
|
|
model="hermes-3", messages=_msgs(), tools=None,
|
|
provider_profile=get_provider_profile("nous"),
|
|
)
|
|
assert profile["extra_body"]["tags"] == legacy["extra_body"]["tags"]
|
|
|
|
|
|
|
|
class TestQwenProfileParity:
|
|
|
|
def test_vl_high_resolution(self, transport):
|
|
legacy = transport.build_kwargs(
|
|
model="qwen3.5", messages=_msgs(), tools=None, provider_profile=get_provider_profile("qwen-oauth"),
|
|
)
|
|
profile = transport.build_kwargs(
|
|
model="qwen3.5", messages=_msgs(), tools=None,
|
|
provider_profile=get_provider_profile("qwen"),
|
|
)
|
|
assert profile["extra_body"]["vl_high_resolution_images"] == legacy["extra_body"]["vl_high_resolution_images"]
|
|
|
|
def test_metadata_top_level(self, transport):
|
|
meta = {"sessionId": "s123", "promptId": "p456"}
|
|
legacy = transport.build_kwargs(
|
|
model="qwen3.5", messages=_msgs(), tools=None,
|
|
provider_profile=get_provider_profile("qwen-oauth"), qwen_session_metadata=meta,
|
|
)
|
|
profile = transport.build_kwargs(
|
|
model="qwen3.5", messages=_msgs(), tools=None,
|
|
provider_profile=get_provider_profile("qwen"),
|
|
qwen_session_metadata=meta,
|
|
)
|
|
assert profile["metadata"] == legacy["metadata"] == meta
|
|
assert "metadata" not in profile.get("extra_body", {})
|
|
|
|
|
|
|
|
class TestDeveloperRoleParity:
|
|
"""Developer role swap must work on BOTH legacy and profile paths."""
|
|
|
|
def test_legacy_path_swaps_for_gpt5(self, transport):
|
|
msgs = [{"role": "system", "content": "Be helpful"}, {"role": "user", "content": "hi"}]
|
|
kw = transport.build_kwargs(
|
|
model="gpt-5.4", messages=msgs, tools=None,
|
|
)
|
|
assert kw["messages"][0]["role"] == "developer"
|
|
|
|
def test_profile_path_swaps_for_gpt5(self, transport):
|
|
msgs = [{"role": "system", "content": "Be helpful"}, {"role": "user", "content": "hi"}]
|
|
kw = transport.build_kwargs(
|
|
model="gpt-5.4", messages=msgs, tools=None,
|
|
provider_profile=get_provider_profile("openrouter"),
|
|
)
|
|
assert kw["messages"][0]["role"] == "developer"
|
|
|
|
|
|
|
|
class TestRequestOverridesParity:
|
|
"""request_overrides with extra_body must merge identically on both paths."""
|
|
|
|
def test_extra_body_override_legacy(self, transport):
|
|
kw = transport.build_kwargs(
|
|
model="gpt-5.4", messages=_msgs(), tools=None,
|
|
provider_profile=get_provider_profile("openrouter"),
|
|
request_overrides={"extra_body": {"custom_key": "custom_val"}},
|
|
)
|
|
assert kw["extra_body"]["custom_key"] == "custom_val"
|
|
|
|
|
|
|
|
def test_top_level_override(self, transport):
|
|
kw = transport.build_kwargs(
|
|
model="gpt-5.4", messages=_msgs(), tools=None,
|
|
provider_profile=get_provider_profile("openrouter"),
|
|
request_overrides={"top_p": 0.9},
|
|
)
|
|
assert kw["top_p"] == 0.9
|