---
title: "Making open models work for long-horizon agentic workloads"
description: "Coding agents resend the entire conversation history on every turn, creating a pattern of large input and small output. Prefix caching avoids recomputing earlier tokens, but it is fragile: any change near the top of the prompt invalidates the cache for everything after it. The harness must avoid re-rendering dynamic system prompts or inserting tool definitions at the top, and must instead add new content at the end. The inference engine must route each turn to the same GPU that holds the cached KV pairs from the previous turn. Together AI and Ollama document the specific responsibilities of each side to keep long agent sessions fast and cost-effective."
---

# Making open models work for long-horizon agentic workloads

[Together AI](https://yomu.fyi/company/together-ai) · Nov 16, 2026

**Type:** Explainer

## Summary

Coding agents resend the entire conversation history on every turn, creating a pattern of large input and small output. Prefix caching avoids recomputing earlier tokens, but it is fragile: any change near the top of the prompt invalidates the cache for everything after it. The harness must avoid re-rendering dynamic system prompts or inserting tool definitions at the top, and must instead add new content at the end. The inference engine must route each turn to the same GPU that holds the cached KV pairs from the previous turn. Together AI and Ollama document the specific responsibilities of each side to keep long agent sessions fast and cost-effective.

## Context

Coding agents resend the entire conversation history on every turn, producing a traffic pattern of large input sequence length (ISL) and small output sequence length (OSL). Without caching, the work grows quadratically with session length. Prefix caching avoids recomputing the earlier part of the prompt, but it is fragile: any change near the top of the prompt invalidates the cache for everything after it. The post is a joint guide from Together AI (inference engine) and Ollama (harness integrations) on how to keep the cache intact across long agent sessions.

## Approach / What changed

The post describes how the harness (client side) and inference engine (server side) must cooperate to preserve the prefix cache across agent turns. The harness must avoid changing the start of the prompt (e.g., by re-rendering a dynamic system prompt or inserting tool definitions at the top), and the engine must route each turn back to the GPU that already holds the cached KV pairs. Together AI and Ollama document the specific handoff responsibilities for each side.

## Takeaways

- Agent workloads have large input sequence length (ISL) and small output sequence length (OSL), making prefill the dominant phase and prefix caching essential for performance.
- Without caching, the work grows quadratically with session length (e.g., 5,050 units at 100 turns vs. 100 with caching), because each turn reprocesses the entire history.
- The harness must avoid changing the start of the prompt (e.g., dynamic system prompts) and should load tool definitions at the end, but must verify model support for mid-conversation tool insertion.

## FAQ

### What breaks the prefix cache in an agent session?

The harness must avoid changing anything near the top of the prompt between turns. A dynamic system prompt (e.g., a timestamp or git status that updates each turn) will break the prefix cache, forcing a full re-read of the entire session.

### How should a harness load tools late without breaking the cache?

The harness should add the tool definition at the end of the prompt, where new content goes, rather than inserting it into the tool list near the top. However, not all models support a tool definition appearing mid-conversation, so the harness must check model compatibility.

### What must the inference engine do to preserve the cache across turns?

The inference engine must ensure that each turn of the same session is routed to the same GPU that holds the cached KV pairs from the previous turn. If the request lands on a different GPU, the cache is lost and the prompt must be reprocessed from scratch.

**Tags:** [AI Agents](https://yomu.fyi/topic/ai-agents), [Inference](https://yomu.fyi/topic/inference), [Ollama](https://yomu.fyi/topic/ollama), [Prefix Caching](https://yomu.fyi/topic/prefix-caching), [Together AI](https://yomu.fyi/topic/together-ai)

- Source: [Together AI](https://www.together.ai/blog/making-open-models-work-for-long-horizon-agentic-workloads)
- Source URL: https://www.together.ai/blog/making-open-models-work-for-long-horizon-agentic-workloads
- Ingested by Yomu: 2026-11-17T00:00:15.268Z

[Read original post](https://www.together.ai/blog/making-open-models-work-for-long-horizon-agentic-workloads)
