The building blocks of an AI Agent
I’m exploring the foundations for building a local AI agent. This post walks through setting up a minimal environment using Ollama to run the Qwen3 14B model locally. Then I show the types of prompts I’ll use to interact with the model via a custom CLI tool.
Installing the model
brew install ollama
ollama serve
ollama pull qwen3:14b
Accessing the model
A simple test query.
- model
- the Ollama model to use
- prompt
- The text input
- stream
- stream the model response by token (defaults to true)
- think
- Enable, or disable model thinking mode
curl http://localhost:11434/api/generate -d
{
"model": "qwen3:14b",
"prompt":"Why is the sky blue?",
"stream": false
}
Tool usage
Tool usage and tool response.
tools
- A list of tools available to the model with a description of how the model should use the tool.
messages
- A Message history gives the model context of a user request and allows the model to ask for a tool to be used our cli to return the tool response to the model for continued reasoning.
curl http://localhost:11434/api/chat -d
{
"model": "qwen3:14b",
"think": true,
"stream": false,
"messages": [
{
"role": "user",
"content": "What is the weather?"
},
{
"role": "assistant",
"content": "",
"tool_calls": [
{
"function": {
"name": "get_temperature",
"arguments": { "city": "Toronto" }
}
}
]
},
{
"role": "tool",
"content": "11 degrees celsius",
"tool_name": "get_temperature"
}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the weather in a given city",
"parameters": {
"type": "object",
"properties": {
"city": {
"type": "string",
"description": "The city to get the weather for"
}
},
"required": ["city"]
}
}
}
]
}
The messages block contains a list of interactions up to the current point from an actor (role
: [user | assistant | tool]
). The agent(("role": "assistant"
) indicates it wants to make a tool call with the inclusion of a tool_calls
field. The CLI makes the tool call and appends the response to messages with "role": "tool"