feat: type ResultMessage.model_usage as dict[str, ModelUsage]#1143
Merged
qing-ant merged 1 commit intoJul 22, 2026
Merged
Conversation
Adds a ModelUsage TypedDict mirroring the TypeScript SDK's ModelUsage shape and tightens ResultMessage.model_usage from dict[str, Any] to dict[str, ModelUsage]. The value is passed through verbatim from the CLI's modelUsage field, so this is a type-only change. The two new NotRequired fields (canonicalModel, provider) are emitted by the CLI once anthropics/claude-cli-internal#50283 lands; they give callers a stable key for their own rate-table lookups across provider-specific model ids and aliases. Co-authored-by: benlehrburger-ant <benlehrburger-ant@users.noreply.github.com> No-Verification-Needed: type-annotation-only (TypedDict + __all__ export), no runtime behavior change
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1143 +/- ##
=======================================
Coverage ? 89.97%
=======================================
Files ? 23
Lines ? 4131
Branches ? 0
=======================================
Hits ? 3717
Misses ? 414
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
benlehrburger-ant
marked this pull request as ready for review
July 22, 2026 01:50
qing-ant
approved these changes
Jul 22, 2026
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.
Adds a
ModelUsageTypedDict mirroring the TypeScript SDK'sModelUsageshape and tightensResultMessage.model_usagefromdict[str, Any]todict[str, ModelUsage]. The value is passed through verbatim from the CLI'smodelUsagefield, so this is type-only — no runtime behavior change.The two new
NotRequiredfields (canonicalModel,provider) are emitted by the CLI once anthropics/claude-cli-internal#50283 lands. They give callers a stable key for their own rate-table lookups across provider-specific model ids and aliases (e.g. Bedrock ARNs →claude-opus-4-7), so cost drift like "Opus 4.6/4.7 priced as 4.5" is detectable client-side. Per-token rates were intentionally left out of this pass (not authoritative); may follow separately with a source marker.Verification: type-annotation-only;
py_compileclean on changed files; existingtest_parse_result_message_with_model_usagecovers the passthrough shape.