AivexaNewsSearch
AI news for builders and product teamsChecked every hour

Making open models work for long-horizon agentic workloads

Collected Nov 18, 2026

Ollama and Together AI published a joint post on making open models hold up under long-horizon agentic workloads, written by Parth Sareen and Zain Hasan of Together AI. Ollama's side of the work covers harness integrations, including an ollama launch command that connects harnesses such as Claude Code, Codex and Pi to open models like DeepSeek-V4.1-Flash and GLM-5.3. Together AI's side covers what the inference engine does when a request arrives. Their shared finding is that much of the engineering on each side amounts to protecting the prompt cache from choices made on the other.

Coding agents produce an unusual traffic profile. On every step the harness resends the whole conversation: system prompt, tool definitions, the user request, every file read and every command run. The model typically answers with a short tool call. That pattern is a large input sequence and a small output sequence, and the input grows with each turn. Each request goes through prefill, where the engine reads the entire prompt in one parallel pass and produces a first token, then decode, where tokens are emitted one at a time and limited by memory bandwidth. For chat both phases matter roughly equally; for agents the turn is mostly prefill.

KV caching removes repeated work within a request, and prefix caching extends that across requests: if the engine still holds the intermediate key and value pairs for turn six, turn seven only processes the new tail. The authors illustrate with idealized arithmetic: ten equal-sized turns cost 55 units of prompt work without caching and 10 with it; a hundred turns cost 5,050 versus 100. The squaring of work with session length is the reason long coding sessions degrade. Caching is not free, since new tokens still attend over cached ones, and the pattern holds the prefix up to the first differing token and stops there. Appending to the end costs nothing extra; changing anything earlier forces everything after it to be reprocessed.

From that rule the practical guidance follows. Anything volatile placed near the top of the prompt, such as a timestamp, git status or a shifting working directory, turns every turn into a full re-read. The fix is to keep the system prompt identical and put such details in the task message once. Values that are stable within a session but differ across sessions, like a user name, do not hurt that session but prevent new sessions from reusing cached setup.

Reasoning effort is a concrete trap. In GLM-5.3-Flash the setting is written by the chat template into the very first system block. Raising effort mid-task therefore changes the prompt almost at its first token and reprocesses the whole session, which on a long run can mean hundreds of thousands of tokens. The advice is to choose an effort level up front; if more thinking is needed, starting a fresh session at the higher setting is often cheaper and yields clean context, and compacting first reduces the tokens involved.

Tool handling presents another trade-off. Harnesses now carry many tools, and loading every definition up front spends context and degrades tool selection, so newer harnesses let the agent search for and load a definition on demand. Where that definition is inserted matters: appending it to the tool list near the top breaks the prefix, while placing it at the end of the conversation preserves the cache. Not every model tolerates a tool definition mid-conversation, since some chat templates error out on it.

Large tool results also compound. A returned file becomes part of every later request, so reading a 3,000-line file for forty lines is paid repeatedly and consumes context window. Truncation is sensible, but silently truncating is not: the authors give an example where an agent receives the first 100 lines of a 640-line file with no indication of the cutoff, while the function that matters sits at line 420. Adding a line stating the range received and the total lets the model search and request the right region.

Subagents differ in how much cache they can share. A subagent that inherits the parent's system prompt, tools and full conversation branches off an already-cached prefix; one given a written brief shares only the setup. Inheritance is not automatically better, because cached tokens are cheap to process but not free, and they occupy GPU memory for as long as the subagent runs. A narrow reviewer needs a few files, not hundreds of turns of history, and a subagent with its own system prompt shares nothing at all.

The engine side has to cooperate. A session's cache lives on a specific node in a specific data center, so routing decides whether the next turn hits it. Engines either pin a session with a client-supplied key such as prompt_cache_key, or hash the prefix and route to whichever node holds the longest match, even one populated by a different session. That second method is the reason to keep system prompts identical across sessions: a fresh session can then start warm. Load matters too, since a warm node may be saturated, in which case an idle node with a cache miss can be the better deal.

Between turns the cache must survive. An agent may wait minutes while tests run, so an engine can offload the cache to CPU memory while idle and restore it for the next turn. Memory allocation follows PagedAttention, handing out cache blocks as requests need them rather than reserving the maximum context length, and continuous batching rebuilds the running batch each pass so concurrent subagent requests take free slots immediately. Together AI reports running prefill and decode on separate clusters, one tuned for compute and one for memory bandwidth, with the cache shipped between them over RDMA. The practical consequence for harness builders is that cache memory headroom, not compute, usually caps how many requests a GPU serves, and oversized tool results or subagents carrying irrelevant history consume memory another session could use.

Why it matters: teams building coding agents on open models will see latency and cost driven less by model speed than by prompt stability and routing, which makes the harness design a performance decision rather than a cosmetic one. The implication, as inference, is that harnesses should treat everything before the conversation as a fixed contract and be explicit about truncation, while anyone self-hosting should ensure cache-aware routing and idle offload actually exist in their serving stack. Users see the result only as a long session that stays fast; the failure mode is silent and shows up on the bill.

Read at Ollama

Based on reporting from the original publisher. Visit the source for full context and later updates.

Publisher excerpt

Prefix caching helps coding agents stay fast as conversations grow. Prompts, tool calls, and inference routing determine how much work the model can reuse.