← sources

Long Horizon Agents (Surviving Compaction)

source: reddit (reddit:LocalLLaMA)published 2026-10-13 13:19ingested 2026-10-14 02:43

retained text

I struggled w/ context windows and compaction limits for a while. Post compaction stupidity and loss of context would have agents hallucinating wildly after about the third compaction.

Pi's context plugin helps, but adding a small proxy in front of my agents that let's them edit their system prompt has nearly stopped hallucination while adding a source of truth that the agent sees each turn.

To clarify: they don't directly edit their system prompt. They edit a file that the proxy appends to the system prompt. They see this text every turn as if it is their system prompt and it's cache stable between edits. They can swap these files in and out, add more than one, etc.

I don't claim to have solved the memory issue - my agents still forget things and have to figure them out all over again when they forget to take notes. But they are staying sane. They've been able to maintain state and continue working on the same project indefinitely.

The first agent to use the proxy as working memory has compacted 62 times on a budget of 128k. It's seen about 8 million tokens. It started out as a coder building a harness. It is now the project manager for the harnessed agents and managing a couple of production jobs. The code it wrote is the asset I wanted; the agent behind the code is the asset I need to protect.

How are you keeping your agents sane for the next decade?

document fetched 2026-10-14 00:42 · canonical https://reddit.com/r/LocalLLaMA/comments/1x4wf9k/long_horizon_agents_surviving_compaction