Part 12 of 16 · 1 min read
How to build it so it holds up
Nine rules, each with the reason it earns its cost.
- Keep an immutable event log and compute the request as a projection of it, because a projection can change shape every step without the underlying record ever losing a fact.
- Set a budget below the hard limit, with a trigger at the budget, and do nothing below it, because every edit has a cost, including a cache miss, and most steps do not need one.
- Compact before you summarise: stub processed tool outputs and write-tool arguments first, because a stub is free and reversible while a summary costs a model call and is not.
- Keep a preserved set — system prompt, the user's original request, the last K turns — because the parts of a request everyone needs are the cheapest parts to simply never touch.
- Carry decisions, constraints and identifiers as keyed, verbatim state with supersession, because a fact that is copied rather than re-generated cannot drift and cannot decay with rounds.
- Summarise last, with a cap, and know a summary that feeds a summary decays geometrically, because the recursion means each fact must survive every round, not just one.
- Never let a summariser regenerate an identifier — route it through a slot instead, because a wrong value is worse than a missing one: the agent will act on it.
- Record provenance and let only trusted roles write state, quarantining the rest, because supersession by key has no idea whether the newer value is legitimate.
- Count the whole cost — window tokens per step, plus every summariser call's input and output, plus cache misses — because a smaller window that calls a model to get there is not automatically cheaper.