Live data from Hacker News

How Compaction Works in Pi

earendil.com

31–40 of 100 posts

Re: How Compaction Works in Pi

#31
I don't like that it throws away the whole KV cache when compacting. It costs a cache miss of the whole conversation length, and that's a waste of time and money.

LLMs are perfectly capable of summarising the conversation without a new system prompt.

Re: How Compaction Works in Pi

#32
post #31

I don't like that it throws away the whole KV cache when compacting. It costs a cache miss of the whole conversation length, and that's a waste of time and money. LLMs are perfectly capable of summarising the conversation without a new system prompt.

How the summarizing of the conversation happens in an LLM?

Re: How Compaction Works in Pi

#33
post #10

Compaction is painful if you run just one local LLM, the best way to avoid it is to keep context as small as possible. One trick I find useful is to have one model with two KV caches running and while first cache has produced tokens, second cache immediately summarizes them during input tokens are being generated (tools time), then harness switches to the second KV cache which takes newly produced input tokens while…

I tend to ask a line of questions to the LLM as first step to a point the context is enough for me. Then i ask for the work i need but then get back to previous context using /tree.

It's like asking the questions needed to get the answer you need from the LLM, can be either an answer for a plan/todo or a task to code/change something.

Re: How Compaction Works in Pi

#34
post #23

OMP changed the default compaction to images ! Kinda nuts to read about. Saves the generation cost of the traditional compaction step and writes the context as tiny text to an image, if I was following correctly.

But what if the model you're using doesn't have image processing capabilities?

Re: How Compaction Works in Pi

#35

Instead of compaction, has anyone seen a successful implementation of pruning? That is, the agent looks at the conversation history and removes any low-value messages. For example, sometimes context will be taken up by a side tangent, tool call outputs, or low-value codebase exploration. Much of the time, I prefer to preserve the history of my conversation instead of summarizing it. I find summarized conversations le…

It is kinda a combination of the two:

https://github.com/spott/pi-task-compaction

I’m still playing with it, but it essentially has the model define a region, and mark it with begin_task, and end_task. End_task also requires a fairly hefty summery of the entire region.

It then pulls that entire region and replaces it with the summary. If the model wants it can actually look into the output that was pruned from the conversation, but in practice the summaries have been good enough it hasn’t needed to.

I’ve been using it with 5.6 sol, and even really long sessions have like 6% context used at the end.

Re: How Compaction Works in Pi

#36
post #31

I don't like that it throws away the whole KV cache when compacting. It costs a cache miss of the whole conversation length, and that's a waste of time and money. LLMs are perfectly capable of summarising the conversation without a new system prompt.

Yeah, that seems suboptimal, unless you're using a much cheaper model to do compaction.

Re: How Compaction Works in Pi

#38

Instead of compaction, has anyone seen a successful implementation of pruning? That is, the agent looks at the conversation history and removes any low-value messages. For example, sometimes context will be taken up by a side tangent, tool call outputs, or low-value codebase exploration. Much of the time, I prefer to preserve the history of my conversation instead of summarizing it. I find summarized conversations le…

I'm very interested in this too. I feel like when my Claude session compacts I immediately have to re-alert it to critical aspects of the task, but it should be possible even to have a secondary low-skill agent crawl over the whole context window semi-continuously and nominate pieces for removal or summarization. Or at a higher level, have something able to decompose, like hey I realised we're actually working on three distinct aspects of this problem, let's split the context into those three and I'll just retain a high level summary of what's in the other ones, enough to know if I should pass off control to one of the others for a particular ask.

I feel like this is kind of subagents, but it doesn't have the clear task -> work -> return result -> die model, rather it's more closely aligned to how I myself multitask, maintaining several long-lived threads of execution, and having to intentionally "forget" about the other ones when it's time to lock in and do real work on the most important one.

Re: How Compaction Works in Pi

#39

Is pi a drop in replacement for OpenCode / Claude Code? I cannot be bothered installing 50 million plugins.

It is not.

Their approach is minimalism. If you need something pi doesn’t have, the recommendation is to ask pi about it and have it build an extension for you, or look for a plugin.

That said, try it. You may find you didn’t need everything in those ecosystems.

Re: How Compaction Works in Pi

#40
post #39

Is pi a drop in replacement for OpenCode / Claude Code? I cannot be bothered installing 50 million plugins.

It is not. Their approach is minimalism. If you need something pi doesn’t have, the recommendation is to ask pi about it and have it build an extension for you, or look for a plugin. That said, try it. You may find you didn’t need everything in those ecosystems.

I also find the SDK really valuable. Being able embed a truly minimal agent wherever you can run node/typescript is very powerful. Any model, any provider, full control over what it’s doing.

Not a shill.. I just really like pi.

Post reply on HN