Context Cleanup Cadence

Every note an agent saves constrains its future work. Why product people need a regular context cleanup, and how to run one.

Share
Context Cleanup Cadence
Photo by Laura Ohlman / Unsplash

Context

You've been using agents for a while - personally, with your org, or for coding - and things are slowing down. The agents are taking longer and longer to produce the same outputs - more turns, more waiting - and the outputs are getting weirder and weirder, requiring more correction and review.

Discussion

Here are 3 different places I faced context rot with my agents this month.

  1. I have a daily brief that Claude generates for me in a scheduled task. I noticed Claude always followed the brief, saying 'brief sent', with another paragraph summarizing what it had done. I asked Claude to stop doing this - just send the brief without further comments. It then began attaching an even longer summary in the brief thread, longer than the brief itself. I gave up and asked Claude to only append 'brief sent' and nothing else. This, it was able to do. But 2 weeks later, it was doing it again.
  2. I have a project in Claude I'm using to manage communication and documents for outreach. This was great in the beginning, but over time the documents it generates contain more slop, more AI tells, and require more editing to be usable. When I looked at the configuration files, I was surprised to find endless complex rules, requirements, and exclusions.
  3. I'm working in Claude Code on a development project to build a tool for recruiters. We started with a brief and a rough schedule, but we've learned a lot in the first weeks and our plans have changed. But somehow the bot keeps bringing up old ideas we've discarded. Or it's acting as if the original timeline sketch represents hard deadlines, even though we've discussed this many times.

The Mess You Don't See

All of these scenarios are happening for the same reason - the context the bot is using is a mess. Here's an analogy:

When I first got out of college, I lived alone in an apartment in a town where I knew nobody. I bought a set of 8 place settings for both dishes and silverware. So I could eat dinner on a Monday night and leave the dishes in the sink and nobody noticed. Tuesday and Wednesday were also no problem - just dig out the spatula and wash it off to use it again. Use the other frying pan to fry the next egg - also works fine. But by Friday when I wanted to cook a real meal I had a lot of cleanup to do.

kitchen utensils on stone washing station
Photo by Scott Umstattd / Unsplash

Agents often work this way - leaving a mess behind; appending new rules to their instruction set endlessly, and then processing those rules on every call.

It's important to understand at least a little bit about how LLMs work. Every turn you do, every time you hit Enter or the arrow button, a whole bunch of data is sent to a fresh model that knows nothing about you. It is given a combination of:

  • the prompt you just sent
  • the entire history of your current thread
  • whatever 'memory' you have enabled in settings for your past history (could be memory about you, or could be inside the existing project)
  • pointers and partial summaries of the files and documents you have worked with in the thread or project
  • any configuration files you or the agent have saved in the current project (not just claude.md, but any other files that it points to)

Every time we interact with our agents, they are shaping their context. They're taking notes, either in 'memory' if you still have it enabled, or in files. The memory and the notes constrain their future behaviors. These things are loaded into every single call back to the models, and you don't really know how much weight each item is applying.

This mass is not necessarily well curated. Current models are so powerful they can still do a lot with a horrible mess, so you often don't notice the problem until later.

In my communication project, Claude made a file called do-not-say.md, and filled it with hundreds of rules it had surmised based on feedback I had given it over a couple of months. The result was that the writing got slower and slower; the sentences got longer and longer, and more and more passive voice.

What made me clean it up: I had worked hard to get an output file simple and readable. I felt good about it. I shared it with someone, and they immediately said,

"This is too much text."

I was puzzled, because it was so much LESS text than Claude had first given to me. I couldn't even see how off it was anymore. It was only with external feedback that I was able to recognize the output problem.

Ethan Mollick wrote about how he ended up in a similar mess by mistake - his agents kept ideating brand new products, and he gave them a simple instruction: Stop building new ideas and polish what you have. The result was an incredibly cautious bureaucracy.

Fable 5.2 and Jagged AGI
General, often expert, and sometimes jagged

Fortunately, the models are great at discussing and improving their context, if we take the time to do it with them, and challenge them on their own tendencies to get tangled up in rules.

Play

Sit down with your agents and do a cleanup together. Then do it again. Then implement a rhythmic check or reminder to keep it going at the right pace for your work.

Before you start: make your context inspectable. Some of the best engineers I know shut off the model-managed memory in favor of using inspectable context, either in the code repository or in other curated systems. As product people, we need to do the same thing.

Read more