Automating Workflows with Ollama Subagents
Practical patterns for using local LLMs to automate multi-step workflows — from content drafting to code review — without sending data to third-party APIs.
Why local LLMs?
Not every workflow needs GPT-4. For many automation tasks — drafting summaries, classifying support tickets, reviewing code for common bugs — a local model running through Ollama is fast, free, and keeps your data on your own hardware.
The subagent pattern
We define specialised agents with narrow prompts and small context windows:
- Writer agent — given raw notes, produces formatted markdown
- Reviewer agent — given code, returns a list of issues
- Classifier agent — given a support ticket, assigns category and priority
Each agent is a single Ollama chat call with a system prompt tailored to its job. No orchestrator, no plan — just a function call.
Example: automated PR review
const review = await ollama.chat({
model: class="tok-string">"qwen3.class="tok-number">5:cloud",
messages: [
{ role: class="tok-string">"system", content: class="tok-string">"You are a code reviewer. List bugs, security issues, and style problems. Be concise." },
{ role: class="tok-string">"user", content: class="tok-string">`Review this diff:\n${diff}` },
],
});The output is a bullet list posted as a PR comment. It's not as thorough as a human review, but it catches typos, missing error handling, and common security mistakes before the human ever looks at it.
When to use an orchestrator vs. a single agent
- Single agent — one well-defined task with clear input and output
- Orchestrator — a complex request that benefits from planning and specialised subagents
The DevFlare platform uses both: single agents for quick operations, the full orchestrator for complex builds and debugging sessions.
Running costs
A typical subagent call costs ~$0.0003 in electricity on a local machine. The same call through a cloud API would be $0.01–0.10. For a team running 1000 automated reviews per month, that's $0.30 vs $10–100.
Related