Skip to content

Tool call not working #214

@ban1989ban

Description

@ban1989ban

System Info

import os
import fire

from examples.client_tools.ticker_data import get_ticker_data
from examples.client_tools.calculator import calculator

from llama_stack_client import LlamaStackClient, Agent, AgentEventLogger

def main():
client = LlamaStackClient(base_url="http://IP:port")

agent = Agent(
    client,
    model="llama3.3",
    instructions="You are a helpful assistant. Use the tools you have access to for providing relevant answers.",
    sampling_params={
        "strategy": {"type": "top_p", "temperature": 1.0, "top_p": 0.9},
    },
    tools=[
        calculator,
        get_ticker_data,
    ],
)
session_id = agent.create_session("test-session")
print(f"Created session_id={session_id} for Agent({agent.agent_id})")

user_prompts = [
    "What was the closing price of Google stock (ticker symbol GOOG) for 2023 ?",
    "What is 40+30?",
]
for prompt in user_prompts:
    response = agent.create_turn(
        messages=[{"role": "user", "content": prompt}],
        session_id=session_id,
        stream=False
    )

    print(response)

if name == "main":
fire.Fire(main)
~

Information

  • The official example scripts
  • My own modified scripts

🐛 Describe the bug

Tool call not working at all

Use llama3.3 70B - 4bit quantization with ollama using llama stack

Error logs

Turn(input_messages=[UserMessage(content='What was the closing price of Google stock (ticker symbol GOOG) for 2023 ?', role='user', context=None)], output_message=CompletionMessage(content="I'm not able to provide real-time or up-to-the-minute data, including current stock prices. However, I can suggest some options for you to find the closing price of Google stock (GOOG) for 2023.\n\nYou can check financial websites such as:\n\n* Yahoo Finance\n* Google Finance\n* Bloomberg\n* CNBC\n\nThese websites provide historical stock prices, and you can search for the closing price of GOOG on a specific date in 2023. You can also use their databases to find the closing price for the entire year.\n\nAdditionally, you can check with financial institutions or brokerages that provide stock market data, such as Fidelity, Charles Schwab, or Robinhood.\n\nIf you're looking for a specific date, please let me know and I'll try to help you find the information.", role='assistant', stop_reason='end_of_turn', tool_calls=[]), session_id='bfc2f797-8862-444c-9542-ff930ecc14e7', started_at=datetime.datetime(2025, 5, 14, 14, 53, 3, 190894, tzinfo=TzInfo(UTC)), steps=[InferenceStep(api_model_response=CompletionMessage(content="I'm not able to provide real-time or up-to-the-minute data, including current stock prices. However, I can suggest some options for you to find the closing price of Google stock (GOOG) for 2023.\n\nYou can check financial websites such as:\n\n* Yahoo Finance\n* Google Finance\n* Bloomberg\n* CNBC\n\nThese websites provide historical stock prices, and you can search for the closing price of GOOG on a specific date in 2023. You can also use their databases to find the closing price for the entire year.\n\nAdditionally, you can check with financial institutions or brokerages that provide stock market data, such as Fidelity, Charles Schwab, or Robinhood.\n\nIf you're looking for a specific date, please let me know and I'll try to help you find the information.", role='assistant', stop_reason='end_of_turn', tool_calls=[]), step_id='7d9f3a54-7447-4c0f-bdae-796f77238640', step_type='inference', turn_id='26b815dd-0069-4301-b3bc-94075064df05', completed_at=datetime.datetime(2025, 5, 14, 14, 53, 10, 417274, tzinfo=TzInfo(UTC)), started_at=datetime.datetime(2025, 5, 14, 14, 53, 3, 190939, tzinfo=TzInfo(UTC)))], turn_id='26b815dd-0069-4301-b3bc-94075064df05', completed_at=datetime.datetime(2025, 5, 14, 14, 53, 10, 428417, tzinfo=TzInfo(UTC)), output_attachments=[])
Turn(input_messages=[UserMessage(content='What is 40+30?', role='user', context=None)], output_message=CompletionMessage(content='40 + 30 = 70', role='assistant', stop_reason='end_of_turn', tool_calls=[]), session_id='bfc2f797-8862-444c-9542-ff930ecc14e7', started_at=datetime.datetime(2025, 5, 14, 14, 53, 10, 442955, tzinfo=TzInfo(UTC)), steps=[InferenceStep(api_model_response=CompletionMessage(content='40 + 30 = 70', role='assistant', stop_reason='end_of_turn', tool_calls=[]), step_id='80cc77f1-fb1a-424a-bbf8-8047765a28bc', step_type='inference', turn_id='3db8f3e8-079e-4bd1-8e5e-0805a2ad2ca9', completed_at=datetime.datetime(2025, 5, 14, 14, 53, 10, 910621, tzinfo=TzInfo(UTC)), started_at=datetime.datetime(2025, 5, 14, 14, 53, 10, 442999, tzinfo=TzInfo(UTC)))], turn_id='3db8f3e8-079e-4bd1-8e5e-0805a2ad2ca9', completed_at=datetime.datetime(2025, 5, 14, 14, 53, 10, 921772, tzinfo=TzInfo(UTC)), output_attachments=[])

Expected behavior

Tool calls should work

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions