<!-- llms-explorer concept facts · https://llms-explorer.com/tree/litellm-anthropic-to-chat-completions-translatio/ · pack 2026-10-05 · ~932 tokens -->

# LiteLLM Anthropic-to-Chat-Completions translation bugs for Claude Code

> 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.

Parent: [Mac local LLMs: Chat templates, reasoning and tool calling](https://llms-explorer.com/tree/mac-local-llms-chat-templates-reasoning-and-tool-calling/) · 1 facets · 16 facts · page: https://llms-explorer.com/tree/litellm-anthropic-to-chat-completions-translatio/

## 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: `asserted`
- The /v1/messages pass-through path historically skipped that sanitizer, because the sanitizer only understood OpenAI-format messages. — source: `asserted`
- 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: `asserted`
- 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: `asserted`
- 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: `asserted`
- None found; sources agree the issue 22946 bug sat in pass-through, not in the Chat Completions bridge. — source: `asserted`
- Does `modify_params` change anything for a local backend (vLLM, llama-server) behind LiteLLM? No source tests it. — source: `asserted`
- Is PR 40726 (system-message merge) merged? (carried from anthropic-compatible-local-endpoints-and-role-system-messages.md; not rechecked) — source: `asserted`
- LiteLLM `modify_params: true` sanitizes three message defects: orphaned tool calls, orphaned tool results and empty message content. — [source](https://docs.litellm.ai/docs/completion/message_sanitization)
- For an orphaned tool call LiteLLM inserts a dummy tool result message automatically. — [source](https://docs.litellm.ai/docs/completion/message_sanitization)
- LiteLLM documents the sanitizer's motivation as Anthropic Claude requiring a tool result for every tool call. — [source](https://docs.litellm.ai/docs/completion/message_sanitization)
- 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](https://github.com/BerriAI/litellm/issues/22946)
- Issue 22946 quotes the error `messages.17: tool_use ids were found without tool_result blocks immediately after: toolu_014pWwdiQm6ear25PGFtxsuB`. — [source](https://github.com/BerriAI/litellm/issues/22946)
- Issue 22946 was closed on 2026-03-11 by PR 23104, "sanitize /v1/messages pass-through for tool_use content ordering". — [source](https://github.com/BerriAI/litellm/issues/22946)
- 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](https://github.com/BerriAI/litellm/issues/22946)
- Issue 22946 concerns an Anthropic upstream, so it is a precedent for translation-layer ordering faults, not evidence about local backends. — source: `asserted`
