fix(cost): v0.40.1 — accept Anthropic dated snapshot model IDs in PriceTable.get#84
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PriceTable.get()now retries with the trailing-YYYYMMDDsnapshot suffix stripped when exact match misses, soclaude-haiku-4-5-20251001(what the Anthropic SDK returns inMessage.model) resolves to the family-alias cardclaude-haiku-4-5inmodel_pricing.yaml.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:The AM Sonnet path works because the SDK returned the family alias
claude-sonnet-4-6directly; the Haiku response carries the dated snapshot form. Pricing YAML has onlyclaude-haiku-4-5as the family alias (intentional, so new snapshots don't churn the card registry), and exact-match lookup againstmetadata.model_namefailed.Why lookup-side, not data-side
claude-haiku-4-5-20251001to YAML) would need to be repeated every time Anthropic cuts a new snapshot date — same bug class would recur on the next model rev.feedback_lift_invariants_to_chokepoint_after_second_recurrence(this is the second SDK-vs-registry-naming axis after the Anthropic server-tool prefill mismatch).PriceCardLookupErrorperfeedback_no_silent_fails.Tests
test_dated_suffix_falls_back_to_alias—claude-haiku-4-5-20251001resolves to the haiku cardtest_alias_lookup_unchanged— bare alias path still workstest_exact_dated_match_wins_over_alias_fallback— explicit dated card takes precedence (operator escape hatch preserved)test_unknown_alias_with_dated_suffix_still_hard_fails—claude-foo-9-9-20251001raises with full original name in errortest_non_dated_suffix_is_not_stripped— only the strict-\d{8}$form is normalizedSuite 888 → 893.
Test plan
pytest -x -qpasses (893/893)v0.40.1after mergemorning-signalto v0.40.1i-09b539c844515d549+ manually re-fire tonight's PM edition (--force) to validate the public-topics-mode soak's first edition lands🤖 Generated with Claude Code