Skip to content

The agent that grows with you

fix(pricing): price Bedrock Claude Opus 5 and 5.5 from the snapshot

Brooklyn Nicholsondd6ab89cb8f9
diff --git a/agent/usage_pricing.py b/agent/usage_pricing.py
index 7d930389ab6..4c71d51979d 100644
--- a/agent/usage_pricing.py
+++ b/agent/usage_pricing.py
@@ -162,6 +162,7 @@ _ANTHROPIC_URL = "https://platform.claude.com/docs/en/about-claude/pricing"
_GOOGLE_URL = "https://ai.google.dev/pricing"
_OPUS = ("5.00", "25.00", "0.50", "6.25")
_SONNET = ("3.00", "15.00", "0.30", "3.75")
+_OPUS_5_5 = ("4.00", "20.00", "0.20", "5.00")
_SNAPSHOTS: tuple[tuple[str, Optional[str], str, dict], ...] = (
# OpenAI GPT-5.6 (Sol/Terra/Luna). Cache write = 1.25x input, cache read =
# 0.10x input. "-pro" high-effort modes bill at the same per-token rates
@@ -193,7 +194,7 @@ _SNAPSHOTS: tuple[tuple[str, Optional[str], str, dict], ...] = (
# Opus 5.5 cache hits are 0.05x input (every other Opus: 0.1x).
("anthropic", _ANTHROPIC_URL, "anthropic-pricing-2026-09", {
"claude-opus-5": _OPUS,
- "claude-opus-5-5": ("4.00", "20.00", "0.20", "5.00"),
+ "claude-opus-5-5": _OPUS_5_5,
}),
("openai", "https://openai.com/api/pricing/", "openai-pricing-2026-03-16", {
"gpt-4o": ("2.50", "10.00", "1.25"), "gpt-4o-mini": ("0.15", "0.60", "0.075"),
@@ -224,6 +225,9 @@ _SNAPSHOTS: tuple[tuple[str, Optional[str], str, dict], ...] = (
("bedrock", _BEDROCK_URL, "anthropic-list-2026-07", {
("anthropic.claude-opus-4-8", "anthropic.claude-opus-4-7", "anthropic.claude-opus-4-6"): _OPUS,
}),
+ ("bedrock", _BEDROCK_URL, "anthropic-list-2026-09", {
+ "anthropic.claude-opus-5": _OPUS, "anthropic.claude-opus-5-5": _OPUS_5_5,
+ }),
("bedrock", _BEDROCK_URL, "bedrock-pricing-2026-06", {"anthropic.claude-sonnet-5": _SONNET}),
("bedrock", _BEDROCK_URL, "bedrock-pricing-2026-04", {
("anthropic.claude-sonnet-4-6", "anthropic.claude-sonnet-4-5"): _SONNET,
@@ -330,7 +334,7 @@ _ANTHROPIC_FAST_MODE_PRICING: Dict[str, PricingEntry] = {
)
for _model in _models
}
-del _BEDROCK_URL, _ANTHROPIC_URL, _GOOGLE_URL, _OPUS, _SONNET
+del _BEDROCK_URL, _ANTHROPIC_URL, _GOOGLE_URL, _OPUS, _SONNET, _OPUS_5_5
# GPT-5.6 / GPT-6 tier "-pro" high-effort variants bill at the base tier's per-token
# rates (more tokens per task, not a higher rate); the Hermes-side "-900k" Codex
diff --git a/tests/agent/test_usage_pricing.py b/tests/agent/test_usage_pricing.py
index 9fe2fe1bd67..606f1a468c4 100644
--- a/tests/agent/test_usage_pricing.py
+++ b/tests/agent/test_usage_pricing.py
@@ -283,9 +283,31 @@ def test_bedrock_claude_cached_session_estimates_cost_not_unknown():
assert result.amount_usd is not None
-
-
-
[email protected]("bare", ["claude-opus-5", "claude-opus-5-5"])
[email protected]("scope", ["", "us.", "global."])
+def test_bedrock_claude_opus_5_prices_like_direct_anthropic(bare, scope):
+ """Regression for #100848: Bedrock bills Claude at Anthropic's per-token
+ rates, so a Bedrock Opus 5 / 5.5 session must price from the snapshot at
+ the direct-Anthropic rates instead of falling through to ``unknown``."""
+ direct = get_pricing_entry(bare, provider="anthropic")
+ scoped = get_pricing_entry(f"{scope}anthropic.{bare}", provider="bedrock")
+ assert direct is not None and scoped is not None
+ assert scoped.source == "official_docs_snapshot"
+ for field in ("input", "output", "cache_read", "cache_write"):
+ attr = f"{field}_cost_per_million"
+ assert getattr(scoped, attr) == getattr(direct, attr), attr
+
+
+def test_static_bedrock_catalog_claude_models_price_from_snapshot():
+ """Every Claude id Hermes offers in the offline Bedrock picker must price
+ from the official snapshot; a missing row records $0 / ``unknown``."""
+ from hermes_cli.models_catalog_static import _PROVIDER_MODELS
+
+ claude_ids = [m for m in _PROVIDER_MODELS["bedrock"] if "anthropic.claude" in m]
+ assert claude_ids
+ for model in claude_ids:
+ entry = get_pricing_entry(model, provider="bedrock")
+ assert entry is not None and entry.source == "official_docs_snapshot", model
def test_fireworks_router_fast_tier_prices_distinctly():