BerriAI/litellm · error · ValueError
Unsupported call_type={call_type!r} for compression. Expecte
Error message
Unsupported call_type={call_type!r} for compression. Expected one of: {sorted(_SUPPORTED_CALL_TYPES)}. What it means
_normalize_messages_for_compression in litellm's compression module only accepts call types whose payload is a list of role/content messages: completion, acompletion, and anthropic_messages. Any other call_type (e.g. embedding, image_generation, responses, transcription) is rejected up front, because compression operates on message lists.
Source
Thrown at litellm/compression/compress.py:110
if item_type == "text":
parts.append(str(item.get("text", "")))
elif item_type == "tool_result":
stack.append(item.get("content", ""))
return " ".join(parts)
def _normalize_messages_for_compression(
messages: list[dict],
call_type: str,
) -> tuple[list[dict], list[dict]]:
"""
Normalize each original message to a text-surrogate content for scoring.
Returns:
(normalized_messages, original_messages_copy)
"""
if call_type not in _SUPPORTED_CALL_TYPES:
raise ValueError(
f"Unsupported call_type={call_type!r} for compression. Expected one of: {sorted(_SUPPORTED_CALL_TYPES)}."
)
original_messages: Final[list[dict[str, Any]]] = [dict(m) for m in messages]
normalized_messages: Final[list[dict]] = []
for msg in original_messages:
normalized_messages.append(
{
**msg,
"content": _content_to_text(msg.get("content", "")),
}
)
return normalized_messages, original_messages
def _extract_last_user_message(messages: list[dict]) -> str:
"""Return the text content of the last user message."""View on GitHub (pinned to 6c2dcb801b)
Solutions
- Scope compression to chat call types only — do not apply it to embedding/responses/image calls
- If configuring via router/proxy, filter by call type in the compression hook or set model_info so non-chat models skip compression
- Pass the exact supported values: 'completion', 'acompletion', or 'anthropic_messages'
Example fix
# before — compression applied to every call
router_settings = {"compression": {"enabled": True}} # wraps embedding calls too
# after — only compress chat completions
if call_type in ("completion", "acompletion", "anthropic_messages"):
result = await compress_and_call(call_type, kwargs)
else:
result = await original_call(**kwargs) Defensive patterns
Strategy: validation
Validate before calling
SUPPORTED = {"completion", "acompletion", "anthropic_messages"}
def compression_supported(call_type: str) -> bool:
return call_type in SUPPORTED Prevention
- Apply compression hooks only to chat call types
- Set model_info.model_type correctly on router deployments so non-chat models skip compression
- Guard the compression entry point with a supported-call-type allowlist
When it happens
Trigger: Enabling compression and invoking litellm with a call type outside _SUPPORTED_CALL_TYPES — e.g. litellm.embedding, litellm.responses, litellm.anthropic_openshift or a router deployment whose model_type maps to an unsupported call type, with compression hooks applied.
Common situations: Turning on prompt compression globally (router/proxy settings) so it wraps every call type including embeddings/responses; misconfigured model_info.model_type on a router deployment; passing a typo'd call type string.
Related errors
- Invalid mode: {custom_auth_settings['mode']}
- 'cp4d_host' is required in litellm_params for WXO agents
- 'instance_id' is required in litellm_params for WXO agents
- 'wxo_agent_id' is required in litellm_params for WXO agents
- 'api_key' is required in litellm_params for WXO agents
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/70097ea4aec9f13a.
Report an issue: GitHub.