hermes-agent/tests/hermes_cli/test_gpt56_registration.py
Kshitij Kapoor a3828a94d0 feat(openai): cover gpt-5.6 -pro variants (PR #61587 complement)
PR #61587 adds sol-pro/terra-pro/luna-pro to the aggregator lists.
Complete those on the native surfaces the same way this PR completes
the base tiers:

- hermes_cli/models.py: -pro variants in _PROVIDER_MODELS[openai-api].
- agent/usage_pricing.py: alias ("openai", "gpt-5.6-*-pro") onto the
  base-tier PricingEntry rows — the -pro high-effort modes bill at the
  SAME per-token rates (verified against OpenRouter live pricing
  2026-07-09: identical prompt/completion prices for base and -pro);
  they cost more per task by consuming more tokens, not a higher rate.
- Context lengths need no new entries: "gpt-5.6-sol" et al. are
  substrings of their -pro variants and both lookup tables match
  longest-key-first (verified: sol-pro -> 1.05M direct / 272K codex).
- model_switch sort: -pro variants parse as suffix "sol-pro" (rank 1),
  so /model gpt still defaults to base sol — pinned by test.
- Not added to DEFAULT_CODEX_MODELS: only confirmed routable via API/
  OpenRouter so far; codex live discovery will surface them if ChatGPT
  exposes them, same policy as other unconfirmed codex slugs.

Tests: invariant tests extended (pro aliases share base entries, base
sol outranks sol-pro); 191 targeted tests pass.
2026-07-10 00:47:51 +05:30

83 lines
3.6 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_56_series_outranks_55(self):
models = ["gpt-5.5", "gpt-5.5-pro", "gpt-5.6-sol"]
models.sort(key=lambda m: _model_sort_key(m, "gpt"))
assert models[0] == "gpt-5.6-sol"
def test_aggregator_prefix_form(self):
models = ["openai/gpt-5.5-pro", "openai/gpt-5.6-sol"]
models.sort(key=lambda m: _model_sort_key(m, "openai/gpt"))
assert models[0] == "openai/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_official_pricing_reachable_from_openai_api_slug(self):
# "openai-api" is the picker slug for direct api.openai.com and must
# normalize to the "openai" pricing key space.
route = resolve_billing_route("gpt-5.6-sol", provider="openai-api")
assert route.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