mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-30 19:09:28 +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).
86 lines
2.6 KiB
Python
86 lines
2.6 KiB
Python
"""Targeted tests for ``utils.model_forces_max_completion_tokens``.
|
|
|
|
This helper decides whether a given model name requires the newer
|
|
``max_completion_tokens`` kwarg (rather than the legacy ``max_tokens``) on
|
|
``/v1/chat/completions``. It protects against the 400 ``unsupported_parameter``
|
|
error seen when third-party OpenAI-compatible endpoints serve gpt-4o / 4.1 /
|
|
5.x / o-series models by name and the caller only checks the URL host.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from utils import model_forces_max_completion_tokens
|
|
|
|
|
|
# ─── Positive cases: families that require max_completion_tokens ────────────
|
|
|
|
|
|
class TestPositiveCases:
|
|
def test_gpt_5_bare(self):
|
|
assert model_forces_max_completion_tokens("gpt-5") is True
|
|
|
|
|
|
|
|
|
|
def test_gpt_4o(self):
|
|
assert model_forces_max_completion_tokens("gpt-4o") is True
|
|
|
|
|
|
|
|
|
|
def test_o1(self):
|
|
assert model_forces_max_completion_tokens("o1") is True
|
|
|
|
|
|
|
|
def test_o3(self):
|
|
assert model_forces_max_completion_tokens("o3") is True
|
|
|
|
|
|
|
|
|
|
# ─── Negative cases: older or non-OpenAI families still use max_tokens ──────
|
|
|
|
|
|
class TestNegativeCases:
|
|
def test_gpt_3_5_turbo(self):
|
|
assert model_forces_max_completion_tokens("gpt-3.5-turbo") is False
|
|
|
|
def test_gpt_4(self):
|
|
# Classic gpt-4 (non-omni) still uses max_tokens on chat completions.
|
|
assert model_forces_max_completion_tokens("gpt-4") is False
|
|
|
|
|
|
def test_claude_family(self):
|
|
assert model_forces_max_completion_tokens("claude-3-opus") is False
|
|
assert model_forces_max_completion_tokens("claude-sonnet-4-6") is False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ─── Edge cases ─────────────────────────────────────────────────────────────
|
|
|
|
|
|
class TestEdgeCases:
|
|
def test_empty_string(self):
|
|
assert model_forces_max_completion_tokens("") is False
|
|
|
|
def test_none(self):
|
|
assert model_forces_max_completion_tokens(None) is False # type: ignore[arg-type]
|
|
|
|
|
|
|
|
|
|
def test_vendor_prefix_stripped(self):
|
|
# OpenRouter-style "vendor/model" names should match the tail.
|
|
assert model_forces_max_completion_tokens("openai/gpt-5.4") is True
|
|
assert model_forces_max_completion_tokens("openai/gpt-4o-mini") is True
|
|
assert model_forces_max_completion_tokens("openai/o3-mini") is True
|
|
|
|
|
|
|
|
def test_gpt_5_substring_in_middle_not_matched(self):
|
|
# Only a prefix should match — "local-gpt-5-clone" is a different model.
|
|
assert model_forces_max_completion_tokens("local-gpt-5-clone") is False
|