Skip to content

Fix Claude Fable 5 cost totals - #1372

Merged
steipete merged 1 commit into
mainfrom
fix/fable-5-pricing
Jun 10, 2026
Merged

Fix Claude Fable 5 cost totals#1372
steipete merged 1 commit into
mainfrom
fix/fable-5-pricing

Conversation

@steipete

@steipete steipete commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Summary

  • add bundled pricing for Anthropic's claude-fable-5
  • preserve request timestamps and price historical Claude usage with the tariff active at request time
  • apply long-context thresholds per request instead of cumulative session totals
  • account for native Claude 1-hour cache-write tokens
  • invalidate stale Claude and Pi cost caches after pricing changes

Pricing

Anthropic pricing reference:
https://platform.claude.com/docs/en/about-claude/pricing

Pi session JSONL does not record Anthropic cache retention, so Pi usage keeps its persisted default cache-write tariff rather than guessing historical retention.

Proof

  • make check
  • focused pricing/scanner/cache suite: 53 tests passed
  • full suite: 3,417 tests in 392 suites passed
  • autoreview, whole branch against origin/main: clean, no accepted/actionable findings

Fixes #1368

@clawsweeper

clawsweeper Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codex review: needs changes before merge. Reviewed June 10, 2026, 2:22 AM ET / 06:22 UTC.

Summary
Adds Fable 5 Claude pricing, historical request-level Claude repricing, 1-hour cache-write accounting, cost-cache invalidation, parser hash updates, and pricing/scanner tests.

Reproducibility: yes. from source inspection: Vertex-style claude-fable-5@... names are recognized by the scanner, but the fallback pricing normalizer does not strip the @... suffix before the new dictionary lookup.

Review metrics: 2 noteworthy metrics.

  • Changed surface: 13 files; 901 additions, 117 deletions. The PR spans pricing logic, scanners, cache schema versions, generated parser hash, changelog, and tests.
  • Cache invalidations: 2 artifact-version bumps. Claude/Vertex cost cache and Pi cost cache versions change, so maintainers should notice the intentional derived-cache refresh.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🌊 off-meta tidepool
Patch quality: 🦐 gold shrimp
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P2] Normalize @default and @YYYYMMDD Claude aliases for the bundled Fable fallback and add an empty-cache regression test.

Risk before merge

  • [P1] Vertex-formatted Fable model IDs such as claude-fable-5@default or claude-fable-5@20260609 can still be unpriced when the models.dev cache is stale or missing.

Maintainer options:

  1. Decide the mitigation before merge
    Land the pricing/cache fix after adding bundled fallback support and regression coverage for Claude @... model aliases.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P2] A narrow automated repair can add Claude @... alias normalization for bundled fallback pricing plus regression coverage.

Security
Cleared: The diff changes local pricing, scanner, cache, and test code; I found no new dependency, secret, network, CI, or code-execution surface.

Review findings

  • [P2] Price Vertex-formatted Fable aliases in the fallback — Sources/CodexBarCore/Vendored/CostUsage/CostUsagePricing.swift:216
Review details

Best possible solution:

Land the pricing/cache fix after adding bundled fallback support and regression coverage for Claude @... model aliases.

Do we have a high-confidence way to reproduce the issue?

Yes, from source inspection: Vertex-style claude-fable-5@... names are recognized by the scanner, but the fallback pricing normalizer does not strip the @... suffix before the new dictionary lookup.

Is this the best way to solve the issue?

No. The overall pricing/cache direction is maintainable, but the patch should cover the existing Vertex alias surface before merge.

Full review comments:

  • [P2] Price Vertex-formatted Fable aliases in the fallback — Sources/CodexBarCore/Vendored/CostUsage/CostUsagePricing.swift:216
    The new built-in claude-fable-5 entry only matches the bare normalized ID. For Vertex-style Claude logs such as claude-fable-5@default or claude-fable-5@20260609, normalizeClaudeModel leaves the @... suffix intact after a stale/missing models.dev lookup, so the scanner can still record an unpriced or zero Fable cost. Please normalize those aliases or add explicit fallback aliases with a regression test.
    Confidence: 0.9

Overall correctness: patch is incorrect
Overall confidence: 0.88

AGENTS.md: found and applied where relevant.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 6f6cb097dc58.

Label changes

Label changes:

  • add P2: This is a normal-priority provider cost-calculation fix with limited blast radius, though one alias pricing path remains incomplete.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The PR is owner-authored, so the external-contributor real behavior proof gate does not apply; the body lists make check, focused pricing/scanner/cache tests, and the full suite.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: ⏳ waiting on author.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P2: This is a normal-priority provider cost-calculation fix with limited blast radius, though one alias pricing path remains incomplete.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The PR is owner-authored, so the external-contributor real behavior proof gate does not apply; the body lists make check, focused pricing/scanner/cache tests, and the full suite.
Evidence reviewed

Acceptance criteria:

  • [P1] swift test --filter CostUsagePricingTests.
  • [P1] swift test --filter CostUsageScannerClaudeFableTests.
  • [P1] make check.

What I checked:

Likely related people:

  • steipete: Current-main blame points the Claude pricing table and Vertex-detection paths to Peter Steinberger, and the PR head modifies the same pricing/scanner surface. (role: recent area contributor; confidence: high; commits: 920997c6a365, 91364f2009ac; files: Sources/CodexBarCore/Vendored/CostUsage/CostUsagePricing.swift, Sources/CodexBarCore/Vendored/CostUsage/CostUsageScanner+Claude.swift)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4413eb4133

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}

private static let claude: [String: ClaudePricing] = [
"claude-fable-5": ClaudePricing(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Price Vertex-formatted Fable aliases in the fallback

When Fable is logged in Vertex AI format (for example claude-fable-5@20260609 or @default), this new bundled fallback still won't be used. The models.dev lookup can normalize @ aliases, but with a stale/missing models.dev cache the code falls back to normalizeClaudeModel, which only strips -YYYYMMDD dates and leaves the @... suffix, so the dictionary lookup misses and the scanner records a zero/unpriced cost. The repo already treats @ as Claude Vertex format in CostUsageScanner+Claude, so this fallback should cover those aliases too.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jun 10, 2026
@steipete
steipete force-pushed the fix/fable-5-pricing branch from 4413eb4 to 91364f2 Compare June 10, 2026 06:16
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P2 Normal priority bug or improvement with limited blast radius. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jun 10, 2026
@steipete
steipete merged commit 20004f3 into main Jun 10, 2026
7 checks passed
@steipete
steipete deleted the fix/fable-5-pricing branch June 10, 2026 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fable 5 support

1 participant