Gabriel Pina
Back to workLocal-model agent loops
idea

Local-model agent loops

An AI agent is a model in a loop — often dozens of calls per task. Route the routine steps to a local model and keep the frontier API for the hard reasoning: the rate-limit ceiling stops being the bottleneck, and routine work never leaves the machine.

An agent isn't one clever request. It's a model in a loop: it plans a step, calls a tool, reads the result, and goes again, often dozens of times before a single task is done. Every one of those steps is an API call, and they're bursty and dependent — each waits on the last.

That's exactly the workload hosted APIs throttle. Providers meter you on several axes at once — requests per minute, tokens per minute, and daily caps — and crossing any one of them returns a 429. The limits are also lower than people expect early on: a fresh Anthropic tier starts around 50 requests per minute, and OpenAI's tiers only widen as your cumulative spend grows. You can be well under your request budget and still hit the token ceiling, and when you do, one throttle stalls the whole chain.

The usual patches keep a run alive without fixing the economics. Exponential backoff and retry-after handling work by making the agent wait — you're paying, in latency and sometimes in duplicated tokens, to sit in your own queue. Gateways that fail over to a second key or model help, but they're still renting someone else's capacity.

The hedge is to treat the hosted model as the expensive specialist, not the default. Most steps in an agent loop are not hard reasoning — they're parsing a response, formatting output, classifying an intent, deciding "is this done yet?". Those can run on a capable local model on hardware you already own, where there's no per-minute ceiling and the marginal call is effectively free. The frontier API is reserved for the genuinely hard reasoning and the final answer. Route by difficulty, not by habit.

What makes this practical now is that 2026's open models — Qwen 3, Llama 3.3, Mistral Small and their peers — do reliable tool-calling, which is the mechanism an agent loop runs on. The payoff is throughput that isn't capped by a vendor's quota, and routine work — often client data — that never leaves the building. The honest limit: local models are smaller, so the whole thing depends on being clear-eyed about which steps actually need the big model. Misroute the hard ones and you've traded a rate-limit problem for a quality one.

Built with

Local LLMs
Agent loops
Tool-calling

Want something like this built? Get in touch.