LiteLLM Anthropic-to-Chat-Completions translation bugs for Claude Code
Parent: Mac local LLMs: Chat templates, reasoning and tool calling · Published reference · snapshot 2026-10-05
↓ Facts as markdownall context files
With `modify_params: true` LiteLLM repairs OpenAI-format tool conversations before forwarding: it adds dummy results for orphaned tool calls, drops tool results whose id matches no call, and fixes empty text content.
These notes link each claim to its source. A source may be a research report hosted on this site rather than the primary document. A published reference means the content is available; it does not certify independent review or accuracy.Read the editorial policy and follow the sources before relying on a claim.
Facts
- With `modify_params: true` LiteLLM repairs OpenAI-format tool conversations before forwarding: it adds dummy results for orphaned tool calls, drops tool results whose id matches no call, and fixes empty text content. [source]
- The /v1/messages pass-through path historically skipped that sanitizer, because the sanitizer only understood OpenAI-format messages. [source]
- 2026-03-05: issue 22946 reports a 400 from Anthropic for text/tool_use interleaving after client-side context compaction merged two assistant turns; closed 2026-03-11 by PR 23104; a second PR deduplicates tool_result by tool_call_id (release v1.82.0.dev5). [source]
- Merged assistant turns of the shape [text, tool_use, text, tool_use] give "tool_use ids were found without tool_result blocks immediately after". [source]
- The documented sanitization targets Anthropic as the upstream; nothing in the page says the same repairs apply when the upstream is a local OpenAI-compatible server, where the failures reported in existing dossiers are system-placement and role-name mismatches. [source]
- None found; sources agree the issue 22946 bug sat in pass-through, not in the Chat Completions bridge. [source]
- Does `modify_params` change anything for a local backend (vLLM, llama-server) behind LiteLLM? No source tests it. [source]
- Is PR 40726 (system-message merge) merged? (carried from anthropic-compatible-local-endpoints-and-role-system-messages.md; not rechecked) [source]
- LiteLLM `modify_params: true` sanitizes three message defects: orphaned tool calls, orphaned tool results and empty message content. [source]
- For an orphaned tool call LiteLLM inserts a dummy tool result message automatically. [source]
- LiteLLM documents the sanitizer's motivation as Anthropic Claude requiring a tool result for every tool call. [source]
- Issue 22946 reported that the /v1/messages pass-through handler forwarded Anthropic-native messages without sanitization, so [text, tool_use, text, tool_use] content from a compacting client drew a 400 from Anthropic. [source]
- Issue 22946 quotes the error `messages.17: tool_use ids were found without tool_result blocks immediately after: toolu_014pWwdiQm6ear25PGFtxsuB`. [source]
- Issue 22946 was closed on 2026-03-11 by PR 23104, "sanitize /v1/messages pass-through for tool_use content ordering". [source]
- The issue states the Chat Completions path already used `sanitize_messages_for_tool_calling()` in factory.py, which never ran for Anthropic-native format. [source]
- Issue 22946 concerns an Anthropic upstream, so it is a precedent for translation-layer ordering faults, not evidence about local backends. [source]
Children
- No children recorded.