A year ago, most people used Ollama for one thing: download an open model, type ollama run, and chat with it offline. Useful, private, a little limited.
That's not what Ollama is anymore. Over 2026 it picked up the pieces agents need: an Anthropic-compatible API, a one-command launcher for coding agents, subagents and web search for Claude Code, and cloud-hosted models for when your laptop runs out of muscle. Put together, you can now run a real agentic workflow, where a model reads files, calls tools, and works in a loop, on hardware you control.
This guide explains what changed, how the pieces fit, the workflows worth trying, and the security habits that matter when an AI can act on your machine.
Ollama in 30 seconds
Ollama is a free, open-source tool that downloads and runs open-weight language models on your own computer. It handles the hard parts (model formats, GPU acceleration, memory) and exposes a simple command line plus a local API at localhost:11434. Anything that can talk to that API can use the models, no internet required.
That local API is the key to everything below. Agents don't care where a model runs; they care that it speaks a protocol they understand.
What changed in 2026
Ollama's own blog tells the story in a few releases:
| When | What shipped | Why it matters |
|---|---|---|
| Jan 2026 | Anthropic Messages API compatibility | Tools built for Claude's API, including Claude Code, can point at a local Ollama server instead. |
| Jan 2026 | ollama launch | One command sets up coding agents (Claude Code, OpenCode, Codex and others) with local or cloud models. |
| Feb 2026 | Subagents and web search in Claude Code | Web search is built into the compatibility layer, with no separate MCP server or search API key needed. |
| 2026 | Web search API and cloud models | Agents can look things up, and models too big for your machine can run on Ollama's cloud with the same commands. |
The headline is the first row. Because Ollama speaks the same API language as Claude, the agent tooling built around Claude, its tool-use format and its agent loop, now works with open models too.
How an agent actually works (and why the model matters)
"Agentic" gets thrown around a lot. Here's what it means mechanically:
- You give a goal, like "find why the login tests fail and fix it."
- The model decides on an action and asks to call a tool: read a file, run a command, search the web.
- The agent runs the tool and hands the result back to the model.
- Repeat until the model decides the goal is done.
Two model abilities make or break this loop:
- Tool calling. The model must reliably produce well-formed tool requests. A model that can't do this can chat, but it can't read files, run commands, or edit code on its own. On Ollama's model library, look for models tagged with tools.
- Context length. Every file read and command output goes into the conversation. Guides for running Claude Code on Ollama recommend 64K tokens or more of context. Many local setups default to far less, and agents fail in confusing ways when they silently run out. This is the most common "it doesn't work" cause.
OLLAMA_CONTEXT_LENGTH environment variable), but bigger contexts need more memory, so balance it against your hardware.Four workflows worth trying
1. Coding agents on local models
The flagship use: run Claude Code (or OpenCode, or Codex) against a local model. ollama launch walks you through picking a tool and a model, so there's no need to hand-edit configuration. If you prefer to wire it up yourself, Claude Code can be pointed at Ollama's Anthropic-compatible endpoint through its base-URL setting.
ollama pull <a-tool-capable-model>
ollama launch
What you get: an agent that can read your repo, run tests, and propose edits, with your code never leaving the machine. What to expect: on a strong local model it handles focused tasks well, like explaining a module, writing tests, or small refactors. For big multi-file changes, frontier models are still noticeably more reliable.
2. Build your own agent with tool calling
Ollama's API supports tool calling directly, so you can build small purpose-built agents in a few dozen lines. The official Python library even accepts plain Python functions as tools:
import ollama
def disk_usage(path: str) -> str:
"""Report how full the disk holding `path` is."""
import shutil
total, used, free = shutil.disk_usage(path)
return f"{used / total:.0%} used, {free // 2**30} GiB free"
response = ollama.chat(
model="your-tool-capable-model",
messages=[{"role": "user", "content": "Is my home drive getting full?"}],
tools=[disk_usage],
)
print(response.message.tool_calls)
The model reads the function's name, arguments, and docstring, decides whether to call it, and returns a structured request. Your code runs the function and sends the result back. That loop, repeated, is an agent. Start with read-only tools like this one before you give an agent anything that changes state.
3. Private analysis for security and regulated work
This is where local agents shine. Logs, incident notes, contracts, patient or customer data: anything you can't paste into a cloud chatbot. A local agent can:
- Summarize and triage a day of authentication logs, flagging anomalies for a human to review
- Search an internal knowledge base and draft answers with citations to the source documents
- Classify and tag thousands of documents overnight at zero per-token cost
Because nothing leaves the machine, the compliance conversation gets much shorter. (If you use Ollama's cloud models, that's no longer true: cloud means your prompts go to Ollama's servers. Know which one you're using.)
4. Hybrid: local for volume, frontier for judgment
The most practical setup we've seen splits the work:
- Local model: first-pass triage, extraction, classification, summarizing, and anything private.
- Frontier model (Claude): the hard calls, like architecture decisions, tricky debugging, and final review.
You keep costs and data exposure down without accepting worse results where quality matters most. Because Ollama speaks Claude's API format, switching a tool between the two can be as small as changing which endpoint it points at.
Security: an agent on your machine is a big deal
Our audience includes a lot of security people, so let's be direct. Running a model locally is private. Running an agent locally means software that can read your files and run commands is making decisions from text it reads. Treat it accordingly:
- Keep Ollama on localhost. By default it listens only on your own machine. Don't expose port 11434 to your network or the internet without authentication in front of it. Researchers have repeatedly found exposed, open Ollama servers that anyone could use.
- Sandbox the agent. Run coding agents in a container, VM, or dev environment, not on the laptop holding your SSH keys and password vault.
- Approve, don't auto-run. Keep the agent's permission prompts on for commands and file writes, especially while you learn how a model behaves.
- Prompt injection still applies. A local model reading a malicious web page, README, or log line can be steered just like a cloud model. "Local" protects your data from the provider; it doesn't protect the agent from what it reads.
- Pull models from sources you trust. Model files are large binaries from the internet. Stick to well-known publishers and Ollama's official library.
Is it worth it?
If you care about privacy, cost at volume, or working offline, yes, absolutely. Ollama turned local agents from a weekend science project into something you can set up in minutes. If you need maximum reliability on complex, long-running tasks, keep a frontier model in the loop.
The real skill isn't picking a side. It's understanding the agent loop, tools, context, and permissions well enough to put each model where it's strongest.
Where to learn the fundamentals
The concepts behind local agents (tool use, context management, MCP, agent loops) are the same ones taught for Claude:
- Building with the Claude API covers tool use, RAG, MCP, and agent workflows. Because Ollama is compatible with Claude's API format, the patterns transfer directly.
- The free Anthropic Academy courses in our Claude fall 2026 update, including Claude Code in Action.
- For the security side of AI tooling, see Claude Code for cybersecurity workflows and the best AI tools for cybersecurity professionals.
Coursera · Anthropic
Building with the Claude API
Tool use, MCP, and agent workflows: the patterns behind every agent, local or cloud. Straight from Anthropic.
Affiliate link — we may earn a commission if you enroll.
Further reading
- Ollama blog: release announcements, including Anthropic API compatibility,
ollama launch, and web search. - Subagents and web search in Claude Code, from Ollama.
More AI workflows live in AI & Workflows.
← All AI & Workflows