Repository navigation
fix(litellm): retain normalized cache creation usage in telemetry - #4888
Merged
gabsprogrammer merged 4 commits intoSep 15, 2026
Merged
gabsprogrammer merged 4 commits into
gabsprogrammer merged 4 commits into
Conversation
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.
Why this matters
When the switchboard is in observe/disabled mode, the LiteLLM success callback owns Token Spy telemetry. LiteLLM 1.90.7 reports Anthropic cache creation under
usage.prompt_tokens_details.cache_creation_tokens; ODS currently reads onlyusage.cache_write_tokens, so a real 4,096-token cache creation is sent to/api/ingest/routedas zero. The cache-write history loses that activity.Read the normalized detail field through the existing bounded counter conversion. Keep the previous top-level key for callers without the detail, and preserve an explicit measured zero. Input/output totals, cache reads, metadata-only payloads, queue behavior and the switchboard's exactly-once suppression remain unchanged. This corrects telemetry attribution; it does not change pricing or reinterpret total input tokens.
Overlap check
Searched all open/closed PR titles, bodies and changes to
ods_token_spy_callback.py, plus LiteLLM cache creation/write telemetry. #2035 introduced routed telemetry; #2086 corrects endpoint labels; #2354 and related variants cover worker cleanup; #3755 concerns non-finite durations. #2519 changes cached-input billing in Token Spy's OpenAI provider, not this callback mapping. No existing PR preserves the normalized cache-creation field here.Contract and validation
Provider completion → LiteLLM's normalized Usage/ModelResponse →
async_log_success_event→ bounded queue → authenticated metadata-only POST → existing Token Spy ingest counter/storage contract. The pinned source Usage mapping and Anthropic transformation were checked.pytest -q ods/extensions/services/litellm/tests— 11 passed, 1 opt-in skipped in the ordinary Python 3.11 environment.ODS_TEST_LITELLM_PIN=1 LITELLM_LOCAL_MODEL_COST_MAP=True pytest -q ods/extensions/services/litellm/testswith litellm==1.90.7 — 12 passed, including a realModelResponse(usage=Usage(cache_creation_input_tokens=4096, ...))reaching the HTTP ingest payload.pytest -q ods/extensions/services/token-spy/tests/test_routed_telemetry.py— 9 passed.git diff --checkpassed.This tests the exact LiteLLM Python release and the outgoing HTTP boundary using MockTransport; it does not call a paid provider, launch the full proxy image, or claim an end-to-end cloud billing test. Shared Python code applies across hosts; executed evidence is Linux/WSL. No stored events are rewritten. Revert restores the prior mapping without migration. Base is public-beta
c03e0809, which now includes eight earlier batch fixes merged upstream. Remaining shared baseline gate limitations are documented for the batch.Follow-up validation
Merged the current beta base in commit 31d60c2. The scoped diff still contains only the LiteLLM callback and its regression test. All 12 pinned-LiteLLM tests passed on this exact candidate. GitHub checks on this head: 32 success, 4 skipped. The earlier unrelated RemoteProvider frontend failure is no longer present; no duplicate UI fix was added (canonical follow-up: #4570).
Batch integration evidence
This exact candidate is included in the 30-PR integration receipt, on code integration commit
a38a38a2303724b2b2a3bfba6324fc40a67154baover public-betad49ad4bbc760be319de7f4c9b9a93b1f18fe3922. The receipt lists all candidate SHAs, suggested merge order and additive catalog/README reconciliation.The integration passed 2,858 API tests (3 skipped), 1,069 UI tests, build/lint, schema and four backend Compose plans. The combined live suite passed 52 cases and hit one Uptime Kuma Docker-start timeout; the unchanged Kuma cases passed in a separate rerun on the same commit. The negative cold-start observation remains recorded. Root/WSL fixture failures and the existing macOS fixture PR #3160 are explicitly separated from passing smoke/simulation checks. These receipts do not qualify every hardware platform or a simultaneous service load.
The report distinguishes completed CI from the queued Memos follow-up. Gitea #4909 remains draft for independent migration review.