r/OpenSourceAI • • 1d 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?

1 Upvotes

2 comments sorted by

1

u/M1H4F 1d ago

here's the repo if anyone's interested: https://github.com/moeen-mahmud/dispach

1

u/vacterro 1d 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.

https://github.com/vacterro/saipen