I’ve been experimenting with local LLMs and lightweight agent frameworks to understand orchestration patterns without relying on hosted APIs. This post is a quick log of the setup, including the control-flow diagram I sketched out before writing any code.
The stack
- Ollama for running models locally
- A simple Python orchestration loop
- Basic tool calling for file and web actions
Control flow
Below is the diagram I used to plan how a single user request moves through the planning, tool-calling, and response stages.
Figure 1: A minimal agent loop — the planner decides the next action, the router dispatches to a tool, and results feed back into context.
def run_agent(user_input, tools, model):
context = [user_input]
while True:
action = model.plan(context)
if action.type == "final_answer":
return action.content
result = tools[action.tool].run(action.args)
context.append(result)
What I learned
Running agents locally forces you to think carefully about latency, context window management, and how much orchestration logic actually needs to live in the “control plane” versus the model itself. It’s a good way to build intuition before wiring the same patterns into production-grade platforms.
Next up, I’m planning to add a memory layer and compare a couple of different tool-routing strategies.