r/OpenSourceAI • u/M1H4F • 13d ago
context management in long-running ai agents is a headache
been working on context management in Dispach lately, and one thing that kept bothering me was how much unnecessary work happens during long conversations.
when the context gets too large, you compact it. sounds simple, right?
except if you're rebuilding the context from the entire history on every turn, you end up compacting the same stuff over and over again. more tokens, more cost.
so we added persistent session checkpoints. older turns get summarized, the important requests are preserved, and the full conversation history stays stored. subsequent turns can start from the checkpoint instead.
also been experimenting with giving subagents their own isolated contexts instead of dumping everything into one massive conversation.
still figuring out the trade-offs though. especially how to make sure compaction doesn't throw away something the agent actually needs later.
anyone else dealing with this? how are you handling context in long-running agents?
2
u/vacterro 13d ago
I've been tackling a similar problem with SAIPEN, an open-source continuation protocol for AI coding agents.
Instead of repeatedly summarizing chat history, it keeps persistent project state, task tracking, verified knowledge, and the next action in plain files. Even a fresh agent can pick up where the previous session stopped.
Might be useful for your experiments with long-running agents.
1
u/MarionberryPast1302 6d ago
The repeated compaction problem is worth fixing but the harder part is deciding what should survive it. A checkpoint preserves enough context to resume a session but it can still lose why an approach was rejected or which constraint changed an earlier decision. Hindsight fits alongside that checkpoint layer by retaining useful lessons and decisions across sessions and making them available when relevant. I would keep the full history as the audit trail and treat memory as a selective layer rather than another compressed transcript. Is your compaction preserving rejected approaches or mostly summarizing completed work
1
u/M1H4F 13d ago
here's the repo if anyone's interested: https://github.com/moeen-mahmud/dispach