Skip to content

[Bug]: LiteLLM v1.77.2 — store_prompts_in_spend_logs=true does not store messages/response in DB (always {}) #15641

Description

@lisyoen

What happened?

We found a reproducible issue in LiteLLM v1.77.2 where the store_prompts_in_spend_logs feature completely fails.
Even when store_prompts_in_spend_logs: true is enabled, all rows in the LiteLLM_SpendLogs table have empty JSON objects {} in both messages and response columns.

Other fields such as request_id, tokens_in/out, total_cost, and status are stored correctly, and API responses are successfully returned to the client.
This means the message and response payloads are being lost somewhere in the internal spend-log write pipeline.

We tested with:

  • Docker image: ghcr.io/berriai/litellm:v1.77.2
  • PostgreSQL backend
  • No custom callbacks or guardrails (pure default setup)
  • stream: false (non-streaming requests)
  • Verified with direct SQL query:
    SELECT messages, response
    FROM "LiteLLM_SpendLogs"
    ORDER BY "startTime" DESC
    LIMIT 5;
    
    

Relevant log output

litellm  | 16:58:50 - LiteLLM Proxy:DEBUG: litellm_pre_call_utils.py:825 - receiving data: {'model': 'Qwen/Qwen3-4B-Instruct-2507', 'messages': [{'role': 'user', 'content': 'DEBUG: store_prompts_in_spend_logs 동작 추적'}], 'stream': False, 'user': 'debug-trace'}
litellm  | 16:58:56 - LiteLLM Proxy:DEBUG: utils.py:3277 - Spend Logs transactions: 0
litellm  | INFO: Writing spend log to db
litellm  | INFO: Logged request status: success

Database query result:
SELECT messages, response FROM "LiteLLM_SpendLogs" ORDER BY "startTime" DESC LIMIT 1;
 messages | response 
----------+----------
 {}       | {}

Are you a ML Ops Team?

No

What LiteLLM version are you on ?

v1.77.2 (tested both standard and -stable variants)

Twitter / LinkedIn details

No social details to share publicly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions