Skip to content

Python: [Bug]: ollama_chat_client.py sample passes tools as direct argument to get_response() causing TypeError #6411

@alxxdev

Description

@alxxdev

Description

What happened?

The ollama_chat_client.py sample passes tools as a direct keyword argument to OllamaChatClient.get_response(), but the method doesn't accept tools directly. It should be passed inside the options dict.

What did you expect to happen?

The sample should run successfully and return the current time using tool calling.

Steps to reproduce the issue

  1. Set OLLAMA_MODEL=llama3.2
  2. Run: uv run python/samples/02-agents/providers/ollama/ollama_chat_client.py
  3. See TypeError

Code Sample

Current broken code (lines 43 and 48 in ollama_chat_client.py):

# Non-streaming (line 48):
response = await client.get_response(messages, tools=get_time)

# Streaming (line 43):
async for chunk in client.get_response(messages, tools=get_time, stream=True):

Should be:

# Non-streaming:
response = await client.get_response(messages, options={"tools": get_time})

# Streaming:
async for chunk in client.get_response(messages, options={"tools": get_time}, stream=True):

Error Messages / Stack Traces

TypeError: FunctionInvocationLayer.get_response() got an unexpected keyword argument 'tools'

Affected file

python/samples/02-agents/providers/ollama/ollama_chat_client.py

Environment

  • agent-framework version: latest
  • Ollama model: llama3.2
  • OS: Linux

Code Sample

from agent_framework import Message, tool
from agent_framework.ollama import OllamaChatClient

@tool
def get_time():
    """Get the current time."""
    from datetime import datetime
    return f"The current time is {datetime.now().strftime('%I:%M %p')}."


async def main():
    client = OllamaChatClient()
    messages = [Message(role="user", contents=["What time is it? Use a tool call"])]

    # This raises TypeError:
    response = await client.get_response(messages, tools=get_time)

    # Should be:
    # response = await client.get_response(messages, options={"tools": get_time})

Error Messages / Stack Traces

Package Versions

agent-framework version: 1.8.0 agent-framework-ollama version: 1.0.0b260521 - Python version: 3.14 - Ollama model: llama3.2 - OS: Linux

Python Version

3.14

Additional Context

No response

Metadata

Metadata

Assignees

Labels

Type

No fields configured for Bug.

Projects

Status
No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions