Skip to content

Unable to use tool calling with ollama api #1428

Description

@ziouf

I've configured the Ollama integration in my Home Assistant to use Lemonade Local as the inference provider.
But it seems that Lemonade's implementation of the Ollama API does not support tool calls.

Home Assistant show this error in logs :

Unexpected error during intent recognition
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/assist_pipeline/pipeline.py", line 1298, in recognize_intent
    conversation_result = await conversation.async_converse(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<9 lines>...
    )
    ^
  File "/usr/src/homeassistant/homeassistant/components/conversation/agent_manager.py", line 129, in async_converse
    result = await method(conversation_input)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/conversation/entity.py", line 55, in internal_async_process
    return await self.async_process(user_input)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/conversation/entity.py", line 68, in async_process
    return await self._async_handle_message(user_input, chat_log)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/ollama/conversation.py", line 84, in _async_handle_message
    await self._async_handle_chat_log(chat_log)
  File "/usr/src/homeassistant/homeassistant/components/ollama/entity.py", line 259, in _async_handle_chat_log
    [
    ...<4 lines>...
    ]
  File "/usr/src/homeassistant/homeassistant/components/conversation/chat_log.py", line 507, in async_add_delta_content_stream
    async for delta in stream:
    ...<91 lines>...
            )
  File "/usr/src/homeassistant/homeassistant/components/ollama/entity.py", line 155, in _transform_stream
    async for response in result:
    ...<20 lines>...
        yield chunk
  File "/usr/local/lib/python3.14/site-packages/ollama/_client.py", line 688, in inner
    yield cls(**part)
          ~~~^^^^^^^^
  File "/usr/local/lib/python3.14/site-packages/pydantic/main.py", line 250, in __init__
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 1 validation error for ChatResponse
message.tool_calls.0.function.arguments
  Input should be a valid dictionary [type=dict_type, input_value='{', input_type=str]
    For further information visit https://errors.pydantic.dev/2.12/v/dict_type

How to reproduce

  • Install Home Assistant
  • Setup oLLama integration targeting Lemonade server
  • Setup chat agent with assist enabled. This enables tool calling to retrieve sensor values.
Image
  • Ask something to the agent
Image

Additional informations

It looks like Home Assistant is not the only integration encountering this issue.

Lene0815 is having an issue with tool caling on OpenClaw

Image

I don't know if it's related

Metadata

Metadata

Assignees

No one assigned

    Labels

    area::apiHTTP REST API surface and route handlersbugSomething isn't workingpriority::🔥hot

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions