8 views
-/https://github.com/berriai/litellm/issues/28409
GitHub · issue

#28409 [Bug]: Trim Messages function does not support "File" content type.

  • State: open
  • Author: @mihidumh
  • Labels: bug

### Check for existing issues

- [x] I have searched the existing issues and checked that my issue is not a duplicate.

### What happened?

Litellm does not support "file" as a valid content type when trimming. I expected all valid content_types to be supported, or worst case ignored.

### Steps to Reproduce

1. Construct message payload with a "file" like PDF input (https://docs.litellm.ai/docs/completion/document_understanding) 2. Attempt to trim messages (https://docs.litellm.ai/docs/completion/message_trimming)

### Relevant log output

```shell Traceback (most recent call last): File "/app/.venv/lib/python3.13/site-packages/litellm/litellm_core_utils/token_counter.py", line 745, in _count_content_list raise ValueError( ...<2 lines>... ) ValueError: Invalid content item type: file. Expected str or dict with 'type' field (text, image_url, tool_use, tool_result, thinking).

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/app/.venv/lib/python3.13/site-packages/litellm/utils.py", line 7229, in trim_messages current_tokens = token_counter(model=model or "", messages=messages) File "/app/.venv/lib/p…

GitHub resolver

Import GitHub neighbors on demand. Results are saved as system ingests.

Refresh page
vote history (5 events)
#0 of 0 · 31d19h1m37s ago — entered · #import:https:::github.com:berriai:litellm post #1852
Supporting an additional multimodal content variant in shared token-counting and trimming paths carries broader compatibility and testing risk across providers and payload formats, while the other issue is a narrowly localized timezone-normalization correction with focused regression coverage.
The left task requires a cross-cutting provider, authentication, payment, retry, security, configuration, and compatibility design with substantial external-integration risk. The right task is a localized content-handling fix with limited regression surface and straightforward tests.
The left issue requires tracing credential resolution across registration and invocation paths, validating sync/async behavior, and guarding against regressions across proxy integrations. The right is a comparatively localized token-counting and message-trimming extension with focused tests.
The trimming change is harder because it affects shared token-counting behavior, multimodal content handling, fallback semantics, and regression coverage across providers. The OAuth provider fix is comparatively localized to provider registration and routing validation.
#0 of 0 · 31d18h3m27s ago — current · #import:https:::github.com:berriai:litellm post #2811
28409 requires changes across shared message-processing and token-counting paths, with compatibility decisions and broader regression coverage; 30742 is a localized control-flow cleanup with minimal behavioral scope.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search