· By Jody —

Protect your LLM's context window by rewinding your conversation

I have previously talked about how you can protect your LLM's context window by delegating to subagents. Here is another (and much simpler) technique I often use.

Have you ever found yourself going down a rabbit hole with a coding agent - ending up with a long conversation that should have been much shorter? In this situation (for agents such as Claude Code that support it), you can simply rewind the code to a previous checkpoint in your chat. However, before you do so I recommend you get your agent to create a prompt that captures the conclusion you arrived at. So once you have arrived at a long and winding conclusion, do something like:

Concisely document the solution we have arrived at so I can be copy and pasted it as a prompt.

Once your agent has completed the above, you can then rewind your history to a suitable checkpoint, and then paste the response (you previously copied) as a new chat message. To rewind to a checkpoint in Claude Code you use the /rewind command (or press Esc twice). Your long-winded chats can eat up your context window, making your LLM dumber - so don't be afraid to rip them out and replace them with a shorter, more efficient version.