fix: Anthropic via LiteLLM/proxies rejects requests with tool history but no tools param #5374

Closed
opened 2026-02-16 17:51:58 -05:00 by yindo · 0 comments
Owner

Originally created by @seilk on GitHub (Jan 13, 2026).

Originally assigned to: @thdxr on GitHub.

When using Anthropic/Claude models via LiteLLM-based proxies (e.g., custom gateways), requests fail with:
UnsupportedParamsError: Anthropic doesn't support tool calling without tools= param specified
This happens when:

  1. Message history contains previous tool calls (tool-call / tool-result)
  2. Current request has no tools (e.g., compaction, title generation)

Root Cause

LiteLLM validates that if message history contains tool calls, the tools parameter must be present. Anthropic's native API now handles this gracefully, but many users route through LiteLLM proxies which enforce stricter validation.

Proposed Solution

Add a dummy tool when:

  • Model is Anthropic/Claude (checked via providerID, api.id, or api.npm)
  • Message history contains tool-call or tool-result
  • No tools are provided (tools is empty)
    The dummy tool is excluded from activeTools so LLM won't actually call it.

Reproduction

curl -X POST "https://your-litellm-gateway" \
  -H "Authorization: Bearer $KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "model_name_for_claude",
    "messages": [
      {"role": "user", "content": "What is 2+2?"},
      {"role": "assistant", "content": null, "tool_calls": [{"id": "call_123", "type": "function", "function": {"name": "calc", "arguments": "{}"}}]},
      {"role": "tool", "tool_call_id": "call_123", "content": "4"},
      {"role": "assistant", "content": "The answer is 4."},
      {"role": "user", "content": "Thanks!"}
    ]
  }'
# Returns 400: UnsupportedParamsError

Relates to

  • #2915 (same root cause, different approach)
Originally created by @seilk on GitHub (Jan 13, 2026). Originally assigned to: @thdxr on GitHub. When using Anthropic/Claude models via LiteLLM-based proxies (e.g., custom gateways), requests fail with: UnsupportedParamsError: Anthropic doesn't support tool calling without tools= param specified This happens when: 1. Message history contains previous tool calls (`tool-call` / `tool-result`) 2. Current request has no tools (e.g., compaction, title generation) ## Root Cause LiteLLM validates that if message history contains tool calls, the `tools` parameter must be present. Anthropic's native API now handles this gracefully, but many users route through LiteLLM proxies which enforce stricter validation. ## Proposed Solution Add a dummy tool when: - Model is Anthropic/Claude (checked via `providerID`, `api.id`, or `api.npm`) - Message history contains `tool-call` or `tool-result` - No tools are provided (`tools` is empty) The dummy tool is excluded from `activeTools` so LLM won't actually call it. ## Reproduction ```bash curl -X POST "https://your-litellm-gateway" \ -H "Authorization: Bearer $KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "model_name_for_claude", "messages": [ {"role": "user", "content": "What is 2+2?"}, {"role": "assistant", "content": null, "tool_calls": [{"id": "call_123", "type": "function", "function": {"name": "calc", "arguments": "{}"}}]}, {"role": "tool", "tool_call_id": "call_123", "content": "4"}, {"role": "assistant", "content": "The answer is 4."}, {"role": "user", "content": "Thanks!"} ] }' # Returns 400: UnsupportedParamsError ``` Relates to - #2915 (same root cause, different approach)
yindo closed this issue 2026-02-16 17:51:58 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#5374