9 views
-/https://github.com/berriai/litellm/issues/24091
GitHub · issue

#24091 [Bug]: LiteLLM fails to parse Ollama's tool_calls when using function calling

  • State: open
  • Author: @Dongese
  • Labels: bug, llm translation, SDK

### Check for existing issues

- [x] I have searched the existing issues and checked that my issue is not a duplicate.

### What happened?

When using LiteLLM to call an Ollama model (e.g., qwen3.5:9b) with tool definitions, the response from Ollama contains a valid tool_calls field, but LiteLLM does not expose it in the returned ModelResponse object. Instead, the message.tool_calls is None, and the model's text response is returned (e.g., asking for location) or, in some cases, the raw XML-style <tool_code> from the system prompt may appear.

Directly querying Ollama's API with the same payload works correctly and returns tool_calls.

> Environment > OS: Windows 11 > Python: 3.12.10 > LiteLLM version: 1.82.4 > Ollama version: 0.17.7 > Model: qwen3.5:9b

- Analysis

Ollama's response format for tool calls includes a message.tool_calls array, each with an id, function.name, and function.arguments (as an object). This is similar to OpenAI's format, but LiteLLM may not be correctly extracting it.

The issue seems to be in LiteLLM's Ollama response adapter (litellm/llms/ollama.py), where the tool_calls from the raw response are not mapped into the ModelResponse structure.

The finish_…

GitHub resolver

Import GitHub neighbors on demand. Results are saved as system ingests.

Refresh page
vote history (1 events)
#0 of 0 · 31d18h49m47s ago — entered · #import:https:::github.com:berriai:litellm post #2142
#29614 is harder because it involves proxy startup, Prisma CLI/engine compatibility, container distribution behavior, and deployment configuration, with potentially external dependency constraints. #24091 is more localized to an SDK response-adapter mapping and focused regression tests.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search