r/PiCodingAgent • u/Equivalent_Idea8839 • Sep 27 '26
Question New session handoff vs compact. which do you prefer?
I've tried every major compact plugin and I settled just on a new session handoff.
Hard to find benchmarks on this sort of thing.
I started with my own custom compact and after a week of iterating, I eventually just ended up with an auto new session at max token limit.
(Another guy on here had posted a plug-in a few days ago that does just that)
13
Upvotes
22
u/repolevedd Sep 27 '26
Every use case is different. Personally, I prefer a lean approach where the context window stays small and gets summarized regularly, while solid documentation lets me spin up new sessions with fast project context recovery.
pi-refine-compactextension, so the LLM stays up to speed on what was done in broad strokes and we can move on.Maybe my approach is a bit paranoid, but it gives me peace of mind and focus.
6
u/Ingaz Sep 27 '26
I'm using pi-blackhole and never had problems with it.
What did you used?
4
u/DistanceAlert5706 Sep 27 '26
I use observational memory and forgot about compaction.
1
u/Abject-Kitchen3198 Sep 27 '26
I keep it simple. As soon as I notice consistent drop in quality that I might attribute to long context, I instruct a handoff with some directions I deem important. It's probably the best I can do to improve the result without writing handoff myself.
1
u/ea_man Sep 27 '26
I use pi-blackhole, a smart move would be to use an external model eg a free openrouter one to do the summary for the compaction so that you don't have to process / KV cache the whole ctx locally.
Or just don't do the summary, use just the deterministic roll.
1
u/ApprehensiveBag2926 Sep 27 '26
Why not both?
I have a orchestrator mode extension in Pi, where the system prompt instructs the model to update a plan and ledger md in scratch workspace, it can compact how/when it wants, because all the key findings and planned tasks are always tracked in scratch workspace
1
u/b1rdk Sep 28 '26
I prefer new handoff sessions. My way of working starts from the assumption that agents should be ephemeral, and that the task instructions should be reproducible for any agent at any point in time
So, in order to achieve this, I first need to define a Harness that builds a sufficiently descriptive and complete state of the task being carried out, indicating only what has been done and what remains to be done
I also try to make sessions last only as long as a task does, so I try to make each task as atomic as possible, or at least keep it limited to a bounded amount of effort
It’s like when you work in Agile, you take a large task, break it down into smaller subtasks, and regardless of how you wake up that day, you should be able to pick the task back up independently of the mood you’re in and know how to continue working on it
1
u/Ok_Significance_9109 Sep 28 '26
I ended up refining existing extensions and adding my own. Tool call pruning allows the agent to selectively summarize and remove bloated tool call results (they can be retrieved if needed from the archive). Then segmented compacting - it summarizes in chunks to avoid hitting OOM. Finally, if nothing helps anymore, automated handoff. The compacting agent is aware of the pruner so no tool call references are lost. And both compactor and pruner have a cloud mode (Google free api tier, with local fallback) and a local mode. Also made sure summarizing models are with thinking off.
Spent a lot of time fine tuning this… The agent also gets system messages about the state of context and cloud availability, so it makes the choices as part of its work process.
1
u/Remarkable-Car-2821 Sep 28 '26
I had the same experience, I also tried several compaction extensions, including my own, but was happy with none. Too often, a compaction event was visibly an inflection point in longer sessions from when quality deteriorated. I feel that lump summarization is just not the ideal concept. Handoff prompts worked better for me, but they come with their own issues, especially if you want to leave your agent alone for a while with a big chunk of development work.
So I created a fork of Pi (because this seemed beyond an extension) that gives the model itself more direct control over its context. It provides tools for the model to list the messages in the context, remove messages that have become irrelevant for future work packages, and summarize other messages selectively rather than the entire context. This is combined with a system prompt injection encouraging the model to keep its context cleanly focused on the task at hand *regardless* of capacity, since unrelated material causes context dilution and makes its output weaker.
It took a bit of fine tuning of the injected prompts and tool syntax before models picked it up. Recently I have combined it with a separately loaded skill on context management that gives a bit more guidance (e.g. be more conservative about pruning user messages, keep the most recent, quickly drop files you can reload again...) and tells models to self-improve this skill from lessons it learns during long sessions.
I've been working on a couple of large-codebase development projects for many several days now, mainly with Qwen 3.8 flash next (now freshly GuFo hosted) with only 128 context, and it's been working excellently. The harness would theoretically fall back to pi's default compaction if it ever reached the trigger point around 85%, but I haven't seen this happen for days. Qwen keeps its context well focused and below capacity, leading to good project results.
I do have to provide the caveat: It has been working really well only with Qwen (27b, flash next and max all manage their context competently). Other models are more reluctant to pick up the idea. I've been working with GPT-6-sol on another project, and it *does* use the tools and curate its context, but only when it feels capacity pressure, not based on quality and focus alone.
0
u/nippster_ Sep 27 '26
I use OpenAI compaction, it’s amazing
0
u/Mammoth-Most-1103 Sep 27 '26
Check out cortexkit
I have been running their complete suite for the past week and I forgot about the concept of context and compaction.
I have a nice workflow built up around and preceding the cortexkit suite that provides durable context but.. I will say this, after this week trial I have it I am keeping it on both machines
AFT => replaces pis 4 tools with its own + 3 more that all hinge in the LSP, semantic search embeddings, codebase indexing
Magic-context => their take on caching. Pretty cool. Worth a google search or gh dive
Better yet just ask your agent to break it all down