hermes-agent/tests/hermes_cli/test_gpt56_registration.py
Teknium 6b81590c55
test: prune low-value tests suite-wide (wave 1) — 46,820 → 28,106 test functions
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).
2026-07-29 13:10:23 -07:00

104 lines
4 KiB
Python

"""Behavior contracts for the GPT-5.6 (Sol/Terra/Luna) registration.
Invariant tests only — no list snapshots (per the no-change-detector-tests
policy). These pin the two behaviors that would silently regress:
1. Version/tier sorting: the flagship Sol must outrank Terra/Luna and the
whole 5.6 series must outrank 5.5, so `/model gpt` resolves to the
flagship rather than an alphabetical-first cheap tier.
2. Pricing reachability: the ("openai", <model>) official-docs pricing keys
must be reachable from BOTH the bare "openai" provider and the
"openai-api" picker slug (resolve_billing_route normalizes the latter).
"""
from decimal import Decimal
from agent.usage_pricing import (
_OFFICIAL_DOCS_PRICING,
_lookup_official_docs_pricing,
resolve_billing_route,
)
from hermes_cli.model_switch import _model_sort_key
class TestGpt56SortInvariants:
def test_sol_outranks_terra_and_luna(self):
models = ["gpt-5.6-luna", "gpt-5.6-terra", "gpt-5.6-sol"]
models.sort(key=lambda m: _model_sort_key(m, "gpt"))
assert models[0] == "gpt-5.6-sol"
def test_base_sol_outranks_sol_pro_for_alias_default(self):
# "-pro" high-effort variants parse as suffix "sol-pro" (rank 1), so
# `/model gpt` defaults to base Sol rather than the high-effort mode.
models = ["gpt-5.6-sol-pro", "gpt-5.6-sol"]
models.sort(key=lambda m: _model_sort_key(m, "gpt"))
assert models[0] == "gpt-5.6-sol"
class TestGpt56PricingRoute:
def test_official_pricing_reachable_from_openai(self):
route = resolve_billing_route("gpt-5.6-sol", provider="openai")
entry = _lookup_official_docs_pricing(route)
assert entry is not None
assert entry.input_cost_per_million == Decimal("5.00")
def test_cache_write_is_1_25x_input_for_56_series(self):
for slug in ("gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna"):
entry = _OFFICIAL_DOCS_PRICING[("openai", slug)]
assert entry.input_cost_per_million is not None, slug
assert entry.cache_write_cost_per_million == (
entry.input_cost_per_million * Decimal("1.25")
), slug
assert entry.cache_read_cost_per_million == (
entry.input_cost_per_million * Decimal("0.10")
), slug
def test_pro_variants_alias_to_base_tier_pricing(self):
# -pro high-effort modes bill at the same per-token rates as their
# base tiers; the snapshot aliases them rather than duplicating rows.
for base in ("gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna"):
assert (
_OFFICIAL_DOCS_PRICING[("openai", f"{base}-pro")]
is _OFFICIAL_DOCS_PRICING[("openai", base)]
), base
class TestGpt56CodexCompaction:
"""Codex OAuth caps the whole gpt-5.6 family at 272K, same as 5.4/5.5, so
the compaction auto-raise (0.85) must fire for every 5.6 variant on the
openai-codex route and NOT on the direct-API/OpenRouter routes."""
def test_autoraise_applies_to_all_56_on_codex(self):
from agent.auxiliary_client import _compression_threshold_for_model
for slug in (
"gpt-5.6-sol",
"gpt-5.6-sol-pro",
"gpt-5.6-terra",
"gpt-5.6-terra-pro",
"gpt-5.6-luna",
"gpt-5.6-luna-pro",
):
assert (
_compression_threshold_for_model(slug, provider="openai-codex")
== 0.85
), slug
def test_no_autoraise_on_direct_api_route(self):
from agent.auxiliary_client import _compression_threshold_for_model
# Direct OpenAI API / OpenRouter expose the full 1.05M window, so the
# 272K-cap override must NOT apply there.
assert (
_compression_threshold_for_model("gpt-5.6-sol", provider="openai")
is None
)
assert (
_compression_threshold_for_model(
"openai/gpt-5.6-sol", provider="openrouter"
)
is None
)