Ollama with Reasoning Tools
Give an Ollama agent explicit reasoning tools and Hacker News retrieval.
Add the following code to your Python file
from agno.agent import Agent
from agno.models.ollama.chat import Ollama
from agno.tools.hackernews import HackerNewsTools
from agno.tools.reasoning import ReasoningTools
reasoning_agent = Agent(
model=Ollama(id="llama3.2:latest"),
tools=[
ReasoningTools(
enable_think=True,
enable_analyze=True,
add_instructions=True,
add_few_shot=True,
),
HackerNewsTools(),
],
instructions="Use tables where possible",
markdown=True,
)
reasoning_agent.print_response(
"Compare the subjects of the top five Hacker News stories and include their URLs.",
stream=True,
show_full_reasoning=True,
)Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateInstall dependencies
uv pip install -U agno ollamaPrepare Ollama
Install Ollama, start the local Ollama service, then download the model:
ollama pull llama3.2:latestKeep the service running while the Python script runs. On a headless installation, start it with ollama serve in another terminal.
Run Agent
python ollama_reasoning_tools.py