Chinese
Uncategorized

Ollama’s Long-Horizon Agents Put Context Reuse Before Raw Speed

Ollama’s November note on long-horizon agents focuses on prefix caching, tool calls, and routing. Local developers should measure reuse, not only tokens per second.

Jacky Wang 4 min read 12 views

When I run a coding agent locally, I can get distracted by one number: tokens per second. It is easy to understand for a short prompt, but it says much less about a long task. An agent reads a repository, runs tests, receives an error, edits a file, and returns to the same working context. If every turn recomputes the same prefix, the machine spends time repeating work. Ollama’s 16 November discussion of long-horizon agentic workloads puts prefix caching, tool calls, and inference routing in the same conversation. The official blog points at a practical issue: how much context can be reused matters almost as much as the model.

The bottleneck is not one response

A chat prompt can be judged by its final answer. A coding agent maintains a changing workspace: system instructions, a repository summary, command output, failed tests, and recent diffs. Two costs appear on every turn. How much input must be processed again? And does the model become less reliable as the context grows?

That is why I would not compare local models with one time ollama run and call it a benchmark. I would use a small, fixed repository and give the agent several connected tasks. I would record input size, tool calls, retries, and the final diff. A basic starting point could be:

ollama pull muse-glimmer
ollama run muse-glimmer
# In one session: inspect the project -> run tests -> fix one failure -> run tests again

This command does not prove long-horizon performance. It only makes the experiment repeatable. Ollama’s post says that prompts, tool calls, and inference routing affect how much work can be reused. I would also separate cold-start runs from already-loaded runs, and “fast output” from “fast task completion.” I would record whether the agent rereads the same files and whether a failed test makes it discard its earlier plan. A model that is fast per token but restarts three times may lose to a slower model that finishes once.

Prefix caching is useful, but it has a boundary

When the system prompt and repository background have not changed, prefix caching can reduce repeated computation. On a local Mac, that may be a more reachable improvement than switching to a much larger model. The interaction does not have to begin from a cold state on every turn.

Caching is not magic, though. A changed repository can make an old summary wrong. Tool output may contain data whose retention deserves careful thought. Several projects sharing one service must not accidentally reuse context from the wrong workspace. Reuse needs a key, an invalidation rule, and visibility into what happened.

I would attach a context hash to each session and invalidate it when the code revision or an important tool result changes. That makes “why is the agent referring to an old file?” easier to investigate than searching through a chat transcript. Long-running work needs an explainable state model, not simply a conversation that feels continuous.

Model choice becomes workflow routing

Ollama’s current blog index also shows that local inference is no longer only about parameter count. MLX, GGUF, tool calling, vision input, and collaboration with cloud models all affect the choice. In my Mac workflow, a smaller model can locate files, summarise output, and handle a simple edit. A heavier model should appear when a failing test requires deeper reasoning. The aim is not to make every step maximally fast; it is to stop expensive reasoning from doing mechanical work.

I would keep the routing rules plain. File reading and formatting go to a fast local model. Database migrations, permission changes, and cross-file refactors stop for a stronger planning pass. Every write still goes through tests and a diff. If the agent cannot decide when to escalate, it usually responds by retrying the same approach.

That is my reading of Ollama’s long-horizon work. The local-agent experience will not be determined by peak benchmark speed alone. A useful system should know what it already computed, recognise when state is stale, and resume from a clear recovery point after a failure. My next measurement would be cache hits and retry count. Only after that would I decide whether a larger model is worth the trade-off. For local development, this is a more honest experiment: it tells me where the machine and workflow actually waste time, rather than producing a peak number that looks good in a screenshot.

Sources: Ollama’s blog, Ollama’s MLX announcement, Ollama model library.

发表评论