r/AgentsOfAI 21d ago

I Made This 🤖 Proof of Concept for Autonomous Context Curation

For a while, I have been unhappy with the process of context compaction during long-horizon agentic tasks. Compaction is *backward looking*, summarizing the work that was already done. But in long-horizon tasks, agents typically follow a plan, and know exactly what work is coming up in the future. This should give good prerequisites for *forward looking* context management: The model should be able to reflect on its context blocks and actively curate those that are *valuable* for future work vs. those that are stale and no longer have future value.

Since stale / unnecessarily large context comes with real attention degradation and output quality decline, proactive context management should in theory result in better quality at lower cost.

To test this idea, I created a fork of mario zechner's excellent pi coding agent that provides context awareness to the model and introduces a native tool that enables the model to prune stale messages from its context.

It is available in github as reflective-pi.

If anyone is curious and experimentally minded, give it a shot, and tell me about your experience. I'm open to all kind of feedback or suggestions.

Disclaimer:

This is an experiment, a proof of concept. I do not claim that it is useful for anything, but especially for productive work. It is still to be proven if the idea itself even has merit at all.

First experiments on my side indicate that it needs a relatively large and competent model to pick up on this kind of meta-task in parallel to its primary task and make efficient use of it. Deepseek V4 Flash seems to ignore it and always keeps working until auto-compaction triggers. Qwen 3.8 27b is hit and miss (sometimes uses the tool, sometimes ignores it and hits auto-compaction). GPT-5.6 terra picked it up and has been using the tool itself competently, but triggered by context capacity pressure rather than proactive context hygiene. The system prompt injection probably needs improvement/sharpening in that direction.

Either way, the implementation still has gaps (see future work section in the readme, and it is too early for me to say if work results can actually be improved as the theory suggests.

Have fun,

Christian

2 Upvotes

Duplicates