---
title: "Letting models edit their own context without invalidating KV cache"
date: 2026-10-02
canonical: https://solmaz.io/x/2106002385743302665/
x_url: https://x.com/onusoz/status/2106002385743302665
license: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)
---

New paradigm alert 🚨

If this ever becomes feasible/useful, it will create a lot of complexity at the application layer 😩 (just when you thought things have settled)

tl;dr You let the model edit its context, including KV cache-breaking modifications like taking out a piece from the middle like a Jenga block, or replacing it with another block

"But won't it break the cache and cost a ton??!?!?!?!" I hear you say

Well, apparently transformers have some tolerance for reusing stale KV states after such modifications

According to the paper, if you have A B C in the context
and replace it with A B' C
apparently you can just keep using the stale cache for C and just have to recompute the cache for B'

I had the idea of giving the model a "Context Editor API" around the time "function calling" was becoming a thing in 2024. But had then quickly realized the implications of my folly and stopped it 😁 (I was a mere GPT wrapper engineer back then)

If the inference engine supports it and does not bill me extra for it, this might indeed be a superior way to work with agents

*Quotes a post by another author (https://x.com/i/status/2105282444270448647); its text is omitted here because it is not covered by this site's license.*
