Skip to content

Allow configuration to set threshold before request entry in spend log gets truncated - #14042

Merged
7 commits merged into
BerriAI:mainfrom
WilsonSunBritten:10988-set-truncation-threshold
Aug 29, 2025
Merged

Allow configuration to set threshold before request entry in spend log gets truncated#14042
7 commits merged into
BerriAI:mainfrom
WilsonSunBritten:10988-set-truncation-threshold

Conversation

@WilsonSunBritten

@WilsonSunBritten WilsonSunBritten commented Aug 28, 2025

Copy link
Copy Markdown
Contributor

Title

Relevant issues

Fixes #10988

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • I have added a screenshot of my new test passing locally, due to local env environments relying on PR passing new unit tests.
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

🆕 New Feature

Changes

Added a new litellm param of 'max_request_size_before_trunc` for number of characters in a request message before going through the normal truncation process

Tests passing

image

@vercel

vercel Bot commented Aug 28, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
litellm Ready Ready Preview Comment Aug 28, 2025 11:41pm

@CLAassistant

CLAassistant commented Aug 28, 2025

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ WilsonSunBritten
❌ Wilson Britten


Wilson Britten seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@ishaan-jaff ishaan-jaff left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggested using constants instead of litellm_settings

"""
from litellm.constants import LITELLM_TRUNCATED_PAYLOAD_FIELD

MAX_STRING_LENGTH = 1000

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead - can you just make MAX_STRING_LENGTH a constant in constants.py and control it through a .env

that feels cleaner

you can call it something like MAX_STRING_LENGTH_PROMPT_IN_DB

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing. I'll note the big trade-off is control over the max limit size in the db with the current approach, while with this you could end up ~20x larger than what you configure if you have many large sub-prompts in your request. Still for the purposes I'm trying to unblock that works great.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done and looking good!

@ghost
ghost merged commit fffccc0 into BerriAI:main Aug 29, 2025
5 of 6 checks passed
@ghost

ghost commented Aug 29, 2025

Copy link
Copy Markdown

can you please document this parameter in config_settings.md? @WilsonSunBritten

@WilsonSunBritten

Copy link
Copy Markdown
Contributor Author

can you please document this parameter in config_settings.md? @WilsonSunBritten

@krrishdholakia I have submitted another MR for this here: #14079

@Antoine101

Copy link
Copy Markdown

Thanks for working on that guys! Do you have an idea of when this will be released?

fzowl pushed a commit to fzowl/litellm that referenced this pull request Jun 24, 2026
…cation-threshold

Allow configuration to set threshold before request entry in spend log gets truncated
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Request truncated in spend logs

4 participants