Skip to content

fix(cost): v0.40.1 — accept Anthropic dated snapshot model IDs in PriceTable.get#84

Merged
cipher813 merged 1 commit into
mainfrom
fix/cost-dated-snapshot-suffix-lookup-v0-40-1
May 28, 2026
Merged

fix(cost): v0.40.1 — accept Anthropic dated snapshot model IDs in PriceTable.get#84
cipher813 merged 1 commit into
mainfrom
fix/cost-dated-snapshot-suffix-lookup-v0-40-1

Conversation

@cipher813
Copy link
Copy Markdown
Owner

Summary

  • PriceTable.get() now retries with the trailing -YYYYMMDD snapshot suffix stripped when exact match misses, so claude-haiku-4-5-20251001 (what the Anthropic SDK returns in Message.model) resolves to the family-alias card claude-haiku-4-5 in model_pricing.yaml.
  • Existing alias lookups, exact dated cards (if explicitly added), and the unknown-alias hard-fail path are all unchanged.

Root cause

morning-signal's PM 2026-05-27 firing — first edition of the public-topics-mode soak armed earlier this evening, Haiku path — crashed at cost.py:184:

PriceCardLookupError: No price card for model 'claude-haiku-4-5-20251001' active on 2026-05-28

The AM Sonnet path works because the SDK returned the family alias claude-sonnet-4-6 directly; the Haiku response carries the dated snapshot form. Pricing YAML has only claude-haiku-4-5 as the family alias (intentional, so new snapshots don't churn the card registry), and exact-match lookup against metadata.model_name failed.

Why lookup-side, not data-side

  • Data-side fix (add claude-haiku-4-5-20251001 to YAML) would need to be repeated every time Anthropic cuts a new snapshot date — same bug class would recur on the next model rev.
  • Lookup-side normalization is the chokepoint: one stripped retry handles every future dated snapshot across every Anthropic family. Aligned with feedback_lift_invariants_to_chokepoint_after_second_recurrence (this is the second SDK-vs-registry-naming axis after the Anthropic server-tool prefill mismatch).
  • Fail-loud invariant preserved: unknown alias still raises PriceCardLookupError per feedback_no_silent_fails.

Tests

  • test_dated_suffix_falls_back_to_aliasclaude-haiku-4-5-20251001 resolves to the haiku card
  • test_alias_lookup_unchanged — bare alias path still works
  • test_exact_dated_match_wins_over_alias_fallback — explicit dated card takes precedence (operator escape hatch preserved)
  • test_unknown_alias_with_dated_suffix_still_hard_failsclaude-foo-9-9-20251001 raises with full original name in error
  • test_non_dated_suffix_is_not_stripped — only the strict -\d{8}$ form is normalized

Suite 888 → 893.

Test plan

  • pytest -x -q passes (893/893)
  • Tag v0.40.1 after merge
  • Repin morning-signal to v0.40.1
  • SSM pull on i-09b539c844515d549 + manually re-fire tonight's PM edition (--force) to validate the public-topics-mode soak's first edition lands

🤖 Generated with Claude Code

…ceTable.get

`Message.model` returns the dated snapshot form (e.g. `claude-haiku-4-5-20251001`)
even when the caller requested the alias. Pricing YAML is keyed on the alias
(`claude-haiku-4-5`) so a new snapshot date doesn't require a card refresh —
but exact-match lookup against `metadata.model_name` raised
`PriceCardLookupError` for every dated form.

Caught when morning-signal's PM 2026-05-27 firing (first edition of the
public-topics-mode soak; Haiku path) crashed at `cost.py:184` with
`PriceCardLookupError: No price card for model 'claude-haiku-4-5-20251001'
active on 2026-05-28`. The AM Sonnet path works because the SDK returned the
alias `claude-sonnet-4-6` directly.

Fix: `PriceTable.get()` retries with the trailing `-YYYYMMDD` snapshot
suffix stripped on miss; existing alias lookups unchanged; exact dated
cards (if explicitly added to YAML) still win over alias fallback;
unknown alias still hard-fails per `feedback_no_silent_fails`.

5 new tests covering: dated → alias fallback, exact-dated precedence,
unknown alias hard-fail, non-dated suffix preserved. Suite 888 → 893.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@cipher813 cipher813 merged commit 57be99e into main May 28, 2026
6 checks passed
@cipher813 cipher813 deleted the fix/cost-dated-snapshot-suffix-lookup-v0-40-1 branch May 28, 2026 04:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant