A model that talks is interesting. A model that acts is transformative. In this step, you’ll teach your agent to read files, write files, scan folders, and perform real work on your machine.
Tools are how your agent stops being “just a conversational model” and becomes a system that can take action. In modern agent research — including frameworks like ReAct (Reason + Act) and Function Calling — tools are the bridge between language and real‑world capability. They allow your agent to read files, write data, scan folders, fetch information, and automate tasks on your machine.
In this step, you’ll add three foundational tools:
These may seem simple, but they unlock a new dimension: your agent can now observe and modify the world outside the model.
tools.jsCreate a new file to hold your tools:
Add the following code:
These synchronous tools are perfect for learning. Later, you can expand them into more advanced, asynchronous, schema‑validated tools similar to those described in the Ollama Tools API .
Open server.js and import your tools:
Then add a new endpoint that executes tools on demand:
Your agent server can now execute real actions — reading files, writing data, scanning directories, and more.
List files in a folder:
Read a file:
Write a file:
When you run these commands, you’re watching the earliest form of agentic behavior: the model decides what action to take, calls the tool, and uses the result. This is the same pattern used in advanced agent frameworks across the industry.
Now that tools exist, your agent can choose when to use them. In the next step, you’ll build an autonomous loop that lets your agent observe, plan, act, and reflect — the core cycle behind modern autonomous agents.
“Unknown tool”
tools.jsPermission errors
File not found
Next Step
Build an Autonomous Loop →