1:1 mentoring with Big Tech AI engineers
Q36Premium

Your agent runs 200 turns and you can't edit history on current models. How do you keep the context under control?

Memory & State

Context WindowMemoryCost OptimizationAgents

Commonly asked at Anthropic · Cursor · OpenAI

How to answer — what you would actually say

“First, why I can’t edit: on the newest models each thinking block is bound to the exact conversation before it. Delete or rewrite an earlier turn and every later block is invalid — a 400 on newer accounts, and a cache miss from the edit onward on any account. So the history my client sends only ever grows, and the shrinking happens on the server.

I use three features for three jobs. Context editing clears finished tool results and old thinking server-side, keeping the last few. Compaction summarises the conversation into one block when it crosses a trigger — 150K input tokens by default — and I append the whole response.content so that block survives. Memory writes anything the next session needs to storage I own.

The rest is what I choose to append. A huge tool result gets digested before it goes in, or read by a subagent in its own window. I never change the system prompt mid-run; I append a system message instead. And I freeze the tools at session start so the prefix stays cached.

The window being a million tokens doesn’t change this: every turn re-reads everything, so the cost and the attention problem arrive long before the limit does.”

The deep dive — diagrams, tradeoff tables, and the follow-up trap

Loading…