Agent with Tools

Give a local LM Studio agent WebSearchTools and stream its response to a web-search query.

Code

from agno.agent import Agent
from agno.models.lmstudio import LMStudio
from agno.tools.websearch import WebSearchTools

agent = Agent(
    model=LMStudio(id="qwen2.5-7b-instruct-1m"),
    tools=[WebSearchTools()],
    markdown=True,
)
agent.print_response("Whats happening in France?", stream=True)

Load a model that supports tool calling in LM Studio.

Usage

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate

Start the LM Studio API server

Install LM Studio, download and load a model, then open Developer and start the API server on port 1234. Keep the server running while you run Python in a terminal.

Check the model list:

curl http://127.0.0.1:1234/v1/models

Set LMStudio(id=...) in the example to the exact model id returned by your server. If you change the server port, set the matching base_url on LMStudio.

Install dependencies

uv pip install -U ddgs openai agno

Run Agent

Save the code above as tool_use.py, then run:

python tool_use.py