{"record":{"id":"70097ea4aec9f13a","repo":"BerriAI/litellm","slug":"unsupported-call-type-call-type-r-for-compressio","errorCode":null,"errorMessage":"Unsupported call_type={call_type!r} for compression. Expected one of: {sorted(_SUPPORTED_CALL_TYPES)}.","messagePattern":"Unsupported call_type=(.+?) for compression\\. Expected one of: (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/compression/compress.py","lineNumber":110,"sourceCode":"            if item_type == \"text\":\n                parts.append(str(item.get(\"text\", \"\")))\n            elif item_type == \"tool_result\":\n                stack.append(item.get(\"content\", \"\"))\n    return \" \".join(parts)\n\n\ndef _normalize_messages_for_compression(\n    messages: list[dict],\n    call_type: str,\n) -> tuple[list[dict], list[dict]]:\n    \"\"\"\n    Normalize each original message to a text-surrogate content for scoring.\n\n    Returns:\n        (normalized_messages, original_messages_copy)\n    \"\"\"\n    if call_type not in _SUPPORTED_CALL_TYPES:\n        raise ValueError(\n            f\"Unsupported call_type={call_type!r} for compression. Expected one of: {sorted(_SUPPORTED_CALL_TYPES)}.\"\n        )\n\n    original_messages: Final[list[dict[str, Any]]] = [dict(m) for m in messages]\n\n    normalized_messages: Final[list[dict]] = []\n    for msg in original_messages:\n        normalized_messages.append(\n            {\n                **msg,\n                \"content\": _content_to_text(msg.get(\"content\", \"\")),\n            }\n        )\n    return normalized_messages, original_messages\n\n\ndef _extract_last_user_message(messages: list[dict]) -> str:\n    \"\"\"Return the text content of the last user message.\"\"\"","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/compression/compress.py#L92-L128","documentation":"_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.","triggerScenarios":"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.","commonSituations":"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.","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'"],"exampleFix":"# before — compression applied to every call\nrouter_settings = {\"compression\": {\"enabled\": True}}  # wraps embedding calls too\n\n# after — only compress chat completions\nif call_type in (\"completion\", \"acompletion\", \"anthropic_messages\"):\n    result = await compress_and_call(call_type, kwargs)\nelse:\n    result = await original_call(**kwargs)","handlingStrategy":"validation","validationCode":"SUPPORTED = {\"completion\", \"acompletion\", \"anthropic_messages\"}\n\ndef compression_supported(call_type: str) -> bool:\n    return call_type in SUPPORTED","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["compression","call-type","validation","configuration"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}