Skip to content

[Bug]: Function/Tool Calling Returns Raw JSON Instead of Executing Tools (Ollama via LiteLLM) #19742

Description

@rcmurphy

Check for existing issues

  • I have searched the existing issues and checked that my issue is not a duplicate.

What happened?

Summary

When using LiteLLM as a proxy between OpenWebUI and Ollama, function/tool calls are returned as raw JSON in the message content instead of being properly structured as tool calls. The same tools work correctly when routed through OpenRouter (e.g., with Claude models), and also work correctly when OpenWebUI connects directly to Ollama (bypassing LiteLLM).

Expected Behavior

When the model decides to use a tool, the response should contain a properly structured tool_calls array, and the client (OpenWebUI) should execute the tool call.

Actual Behavior

The model's tool call is returned as raw JSON in the message content field and displayed to the user instead of being executed:

{"name": "search_knowledge_files", "arguments": {"query": "fun facts about the Roman Empire"}}

Possible Causes

Speculating here!

  1. Response parsing issue: Ollama returns a proper tool call structure, but LiteLLM fails to parse it correctly and passes the raw JSON through as message content.

  2. Request formatting issue: LiteLLM sends the tool definitions to Ollama in a format that causes Ollama to respond with JSON in the content field rather than using its native tool call response structure.

Additional Information

Further diagnostic information (including proxy logs showing raw request/response data) is available on request.

This appears to be related to previously reported issues (#11104, #11262, #17807) that were either incompletely fixed or have regressed.

Steps to Reproduce

Configuration

Model string passed to LiteLLM: ollama/hf.co/unsloth/Qwen3-30B-A3B-Instruct-2507-GGUF:Q4_K_M

Native function calling is enabled. Multiple permutations of function calling-related settings (eg. supports_function_calling) have been tested with no change in behavior. I have also tried with and without a manual tool_choice. The models are configured to stream in LiteLLM.

Instructions

  1. Configure LiteLLM proxy with an Ollama model that supports tool calling (e.g., Qwen3 Instruct)
  2. Configure OpenWebUI to use LiteLLM as the backend
  3. Enable native function calling in OpenWebUI
  4. Send a message that should trigger a built-in tool call (e.g., "Search for fun facts about the Roman Empire")
  5. Observe that instead of executing the tool, the raw JSON is displayed in the chat

Relevant log output

N/A

What part of LiteLLM is this about?

Proxy

What LiteLLM version are you on ?

v1.81.0

Twitter / LinkedIn details

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions