litellm - 💡(How to fix) Fix Anthropic /v1/messages streaming drops tool_use.input for gemini/gemma-4-31b-it while non-streaming works [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
BerriAI/litellm#25390Fetched 2026-04-09 07:52:17
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Participants
Timeline (top)
labeled ×2

Error Message

clients then error with missing required tool params POST /v1/messages/count_tokens?beta=true HTTP/1.1" 500 Internal Server Error

Root Cause

This breaks streaming agent clients like Claude Code / Cline because the client receives an empty tool call and then complains that required tool parameters are missing.

RAW_BUFFERClick to expand / collapse

Describe the bug When using LiteLLM’s Anthropic-compatible /v1/messages endpoint with a Gemma 4 route backed by gemini/gemma-4-31b-it, tool calling works in non-streaming mode but fails in streaming mode.

With the exact same request payload:

non-streaming returns a correct tool_use block with populated input streaming returns a tool_use block with input: {}

This breaks streaming agent clients like Claude Code / Cline because the client receives an empty tool call and then complains that required tool parameters are missing.

LiteLLM model route

  • model_name: gemma-4-31b litellm_params: model: gemini/gemma-4-31b-it api_key: ...

Request payload (non-streaming)

{ "model": "gemma-4-31b", "max_tokens": 256, "messages": [ { "role": "user", "content": "Use grep_tool with pattern exactly GetExerciseAnchors and path exactly lib/domain/repositories/workout_set_repository.dart. Do not answer normally." } ], "tools": [ { "name": "grep_tool", "description": "Search for a pattern in a file", "input_schema": { "type": "object", "properties": { "pattern": { "type": "string" }, "path": { "type": "string" } }, "required": ["pattern", "path"] } } ] }

Observed non-streaming response

{ "type": "tool_use", "id": "call_b37716fd8d224c66acf270ca40cb__thought__...", "name": "grep_tool", "input": { "path": "lib/domain/repositories/workout_set_repository.dart", "pattern": "GetExerciseAnchors" }, "provider_specific_fields": { "signature": "..." } }

This is correct.

Request payload (streaming) Same payload, but with:

"stream": true

Observed streaming SSE output

event: content_block_start data: {"type": "content_block_start", "index": 1, "content_block": {"type": "tool_use", "id": "call_f4e00a4fcaa045969b305568579e__thought__...", "name": "grep_tool", "input": {}}}

The tool name is correct, but input is empty.

Minimal simpler repro This also reproduces with a one-arg tool:

Tool schema:

{ "name": "echo_arg", "description": "Echo a single required string", "input_schema": { "type": "object", "properties": { "value": { "type": "string" } }, "required": ["value"] } }

Prompt:

Call the tool echo_arg with value exactly banana-42. Do not answer normally.

Non-streaming: returns input: {"value":"banana-42"} Streaming: returns input: {}

Expected behavior Streaming Anthropic /v1/messages should preserve tool-call arguments the same way non-streaming does.

Expected streamed tool_use:

{ "type": "tool_use", "name": "grep_tool", "input": { "pattern": "GetExerciseAnchors", "path": "lib/domain/repositories/workout_set_repository.dart" } }

Actual behavior Streaming Anthropic /v1/messages emits:

{ "type": "tool_use", "name": "grep_tool", "input": {} }

Why this matters This makes streaming-based agent clients unusable for Gemma on this route:

model clearly understands the tool and arguments non-streaming proves the arguments are generated correctly streaming drops the arguments clients then error with missing required tool params

Additional context I also previously hit a separate Gemini-path issue on Anthropic /v1/messages/count_tokens, where LiteLLM raised:

ModuleNotFoundError: No module named 'google.genai'

That was from the Gemini token-counting path in the LiteLLM environment. The relevant log snippet is below.

POST /v1/messages?beta=true HTTP/1.1" 200 OK POST /v1/messages/count_tokens?beta=true HTTP/1.1" 500 Internal Server Error ModuleNotFoundError: No module named 'google.genai'

That issue is separate from the current streaming tool-input loss, but both occurred on the Gemini/Gemma path.

Summary

Anthropic /v1/messages gemini/gemma-4-31b-it non-streaming tool calls work streaming tool calls lose input reproducible with both one-arg and two-arg tools

Happy to provide full raw request/response logs if needed.

extent analysis

TL;DR

The issue can be fixed by modifying the LiteLLM's Anthropic-compatible /v1/messages endpoint to properly handle tool call arguments in streaming mode.

Guidance

  • Verify that the input_schema is correctly defined for each tool, ensuring that all required properties are specified.
  • Check the LiteLLM's implementation of the /v1/messages endpoint to ensure that it properly handles the stream parameter and includes tool call arguments in the response.
  • Test the endpoint with different tools and input schemas to confirm that the issue is not specific to a particular tool or schema.
  • Consider adding logging or debugging statements to the LiteLLM's code to inspect the request and response data in streaming mode.

Example

No code snippet is provided as the issue is related to the LiteLLM's internal implementation.

Notes

The issue may be related to how the LiteLLM's /v1/messages endpoint handles the stream parameter and tool call arguments. The fact that non-streaming mode works correctly suggests that the issue is specific to the streaming implementation.

Recommendation

Apply a workaround by modifying the LiteLLM's /v1/messages endpoint to properly handle tool call arguments in streaming mode, or wait for an official fix from the LiteLLM team. The reason is that the current implementation has a bug that causes tool call arguments to be lost in streaming mode.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING