fix(caching): stamp provider on embedding cache-hit spend logs - #35282
Merged
mateo-berri merged 1 commit intoJul 30, 2026
Merged
Conversation
…s record provider Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Contributor
Greptile SummaryThis PR corrects provider attribution for fully cached asynchronous embedding requests.
Confidence Score: 5/5The PR appears safe to merge with no actionable defects identified. The change forwards an already-resolved provider into existing logging metadata without altering cache responses or provider selection, and the regression test directly verifies the corrected value.
|
| Filename | Overview |
|---|---|
| litellm/caching/caching_handler.py | Forwards the resolved provider through the full async embedding cache-hit logging path, matching the established cache-hit behavior. |
| tests/test_litellm/caching/test_caching_handler.py | Adds a focused regression test that exercises the changed branch and verifies the provider stored in model-call details. |
Reviews (1): Last reviewed commit: "fix(caching): stamp provider on embeddin..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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:
custom_llm_providerinto the logging obj on the full embedding cache-hit pathRelevant issues
Linear ticket
Resolves LIT-5015
Pre-Submission checklist
Screenshots / Proof of Fix
Live proxy with local caching on and an
openai/text-embedding-3-smalldeployment, backed by Postgres, hitting the real OpenAI embeddings API. The same request is sent twice; the second is a full cache hit. We then read the provider straight out of theLiteLLM_SpendLogstable.Config:
Requests (same for before and after):
Before (fix line reverted; parent of
15c7d850e5), thecache_hit=Truerow logs an empty provider:The same shows up in the daily aggregate (
LiteLLM_DailyTeamSpend), where the cache-hit tokens land under a null provider:After (fix at commit
15c7d850e5), thecache_hit=Truerow records the provider:Type
🐛 Bug Fix
Changes
LLMCachingHandler._process_async_embedding_cached_responsehandles the case where every input in an embedding request is a cache hit. It resolves the provider withlitellm.get_llm_provider(...), but when it then calls_update_litellm_logging_obj_environment(...)it never forwardedcustom_llm_provider, so the arg defaulted toNone. That leftmodel_call_details["custom_llm_provider"]unset, so the SpendLogs row (custom_llm_providercolumn, and the model prefix fromreconstruct_model_name) and the daily-spend aggregates recorded provider as None/unknownEvery other cache-hit path (the single-result branch and the sync branch) already passes
custom_llm_providerthrough; this branch was the outlier. The fix forwards the already-resolved value:Added a regression test asserting the logging obj ends up with
custom_llm_provider == "openai"after a full embedding cache hit; it fails before the one-line fix and passes afterQA runbook
openai/text-embedding-3-smalldeployment and caching enabled (cache: true,cache_params.type: local)LiteLLM_SpendLogs(or http://localhost:4000/ui/?page=logs) and confirm thecache_hit=Truerow shows provider openai, not empty/NoneFinal Attestation
Link to Devin session: https://app.devin.ai/sessions/f17d0ffcdaf242b8ab2b995a061d9b73