Repository navigation
fix(snowflake): pin Cortex Claude cache token fields on usage - #41608
Closed
BizerNotNull wants to merge 1 commit into
Closed
BizerNotNull wants to merge 1 commit into
BizerNotNull wants to merge 1 commit into
Conversation
Keep cache_creation_input_tokens and cache_read_input_tokens on the typed Cortex usage block and assert they survive transform_response serialization, including a cache-hit payload.
Contributor
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
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.
TLDR
Problem this solves:
How it solves it:
User Flow
Before: a developer sends a cached Claude request through Snowflake Cortex and cannot see cache reads on the usage object
After: the same request keeps Cortex cache counts on usage
Relevant issues
Fixes #35229
Affected release
Linear ticket
Pre-Submission checklist
uv run pytest tests/test_litellm/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Shared setup: no Snowflake credentials were present in this environment, so this PR could not curl a live Cortex account. The mapping itself was already live-checked on #39453 against paid Cortex. This change pins the named fields from #35229 so a cache-hit usage object cannot lose them again
Before (main)
After (bbc4ee6)
_AnthropicUsageBlockincludes cache_creation_input_tokens and cache_read_input_tokenstest_prompt_cache_read_usage_is_surfacedfeeds usage{input_tokens: 2, output_tokens: 256, cache_creation_input_tokens: 0, cache_read_input_tokens: 2941}and requires those fields on both the Usage object andmodel_dump()python -m pytest tests/test_litellm/llms/snowflake/test_snowflake_native_endpoints.py tests/test_litellm/llms/snowflake/chat/test_snowflake_chat_transformation.py -v-> 75 passedType
Bug Fix
Caveats (if any)
Low
Final Attestation