fix(spend_tracking): store messages for all call types when enabled#34748
Open
baiyuxi930826 wants to merge 1 commit into
Open
fix(spend_tracking): store messages for all call types when enabled#34748baiyuxi930826 wants to merge 1 commit into
baiyuxi930826 wants to merge 1 commit into
Conversation
_get_messages_for_spend_logs_payload only filled LiteLLM_SpendLogs.messages
for _arealtime. With store_prompts_in_spend_logs: true, acompletion and
aresponses rows still persisted messages as {}.
Persist standard_logging_payload.messages for every call type when the
gate is on (still {} when disabled or messages missing).
Fixes BerriAI#34747
|
|
Contributor
Greptile SummaryThis PR broadens gated spend-log message persistence beyond realtime calls.
Confidence Score: 5/5The PR appears safe to merge, with no concrete changed-code defect identified. The implementation consistently applies the existing prompt-storage gate before serializing messages, retains safe empty fallbacks, and adds tests for the newly supported completion and Responses API paths.
|
| Filename | Overview |
|---|---|
| litellm/proxy/spend_tracking/spend_tracking_utils.py | Removes the realtime-only restriction while preserving the existing storage gate and safe serialization fallbacks. |
| tests/test_litellm/proxy/spend_tracking/test_spend_tracking_utils.py | Updates completion expectations and adds Responses API coverage for the broadened message-storage behavior. |
Reviews (1): Last reviewed commit: "fix(spend_tracking): store messages for ..." | Re-trigger Greptile
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.
Summary
Fixes #34747
With
general_settings.store_prompts_in_spend_logs: true, spend log rows foracompletion/aresponsesstill persistedLiteLLM_SpendLogs.messagesas{}.Root cause:
_get_messages_for_spend_logs_payloadonly returned messages whencall_type == "_arealtime".Change
When the store gate is on, dump
standard_logging_payload["messages"]for all call types (still{}when disabled, missing, or dump fails). Response storage was already gated correctly.Test plan
{}safe_dumpstests/test_litellm/proxy/spend_tracking/test_spend_tracking_utils.py