Back to home

Compare

Comparing: Pi Teaches Coding Agents 'Shift Handover': Compaction Is Becoming Standard & Pi 让 AI 编程助手学会「换班交接」— 上下文压缩正在变成 Agent 的标配

AEN
Picontext compactioncoding agents·

Pi Teaches Coding Agents 'Shift Handover': Compaction Is Becoming Standard

The keyword from Pi dominating engineering discussions this week is Compaction — not deleting chat history, but having the LLM summarize older exchanges, preserve the recent ones, then resume. Pi reserves roughly 20,000 tokens (about 5 to 20 turns) for "recent conversation"; the rest is summarized by the model itself.

What this is

Every LLM has a context window limit — essentially, how much text it can process at once. Coding agents produce particularly "heavy" conversations: beyond user messages, they include system prompts, tool definitions, loaded code files, and the results of every tool call — quickly exceeding the limit as turns stack up.

Once the window fills, there are usually two paths: open a new session (losing all prior decisions and progress), or compress the history. Compaction takes the second route: an extra LLM call that summarizes older dialogue into a shorter digest, keeps the most recent segment raw, and lets the new conversation continue from there.

Pi's specific approach: it auto-triggers when a session nears the window limit, or users can manually type /compact to compress on demand. After compression, the most recent raw messages are kept (measured by token budget, not message count), with older portions replaced by summaries.

Industry view

We've noticed that coding-agent products are converging — Claude Code, Codex, and Pi have all shipped similar mechanisms. The problem they solve is concrete: complex coding tasks routinely involve dozens of tool-call rounds, and without compression they simply can't run to completion.

But there's a caution worth flagging. Research has shown that longer contexts degrade model output quality — dubbed "Context Rot." This means compaction isn't just about fitting things in; it's about helping the model "think clearly." The cost is an extra LLM call, raising both spend and latency. Summarization can also drop critical details, and implementations vary across vendors with no industry standard yet.

Impact on regular people

For enterprise IT: When procuring AI coding tools, don't just look at subscription fees — factor in the extra token calls triggered by compaction. The more complex the task, the higher the hidden cost.

For working professionals: The bar for "knowing how to use AI to write code" will rise again. The scarce skill isn't prompt-writing — it's decomposing tasks and managing context boundaries.

For consumer markets: Everyday users won't feel it yet, but long-conversation AI assistants (ChatGPT, Claude, etc.) will almost certainly adopt similar mechanisms. Expect "I seem to have forgotten what you said" notices to become more common.

Source: juejin.cn
BZH
Pi上下文压缩编程Agent·

Pi 让 AI 编程助手学会「换班交接」— 上下文压缩正在变成 Agent 的标配

Pi 这周在工程社区被反复讨论的关键词叫 Compaction(上下文压缩)— 它的本质不是把对话记录删掉,而是让 LLM 把前面的历史整理成摘要、保留最近的内容,再继续干活。Pi 默认给「最近对话」留 2 万 Token 预算(约 5 到 20 轮),其余由模型自己总结。

这是什么

LLM(大语言模型)都有上下文窗口限制,可以理解成「一次能看多少字」。编程 Agent 的对话特别「胖」:除了用户消息,还包括系统提示、工具定义、加载的代码文件、每轮工具调用结果,反复累积很快就装不下。

装不下之后通常两条路:要么开新会话(但前面的决策和进度全丢),要么把历史压缩一下。Compaction 走的是第二条:额外调用一次 LLM,让它把旧对话总结成更短的摘要,只保留最近一段原始内容,新对话接着走。

Pi 的具体做法是,当会话接近窗口上限时自动触发,或用户手动输入 /compact 主动压缩;压缩后保留最近的原始消息(按 Token 预算而非条数计算),老的部分换成摘要。

行业怎么看

我们注意到,编程 Agent 的产品形态正在趋同——Claude Code、Codex、Pi 都已上线类似机制。它解决的问题很现实:复杂代码任务动辄几十轮工具调用,不压缩根本撑不到任务完成。

但也有值得警惕的一面。有研究指出,上下文越长,模型输出质量反而下降(被称为 Context Rot,「上下文腐化」)。这意味着压缩不只是为了「装得下」,也是为了让模型「想得清楚」——代价是多一次 LLM 调用,成本和延迟都会上升;摘要环节还可能丢失关键细节,目前各家实现不统一,没有行业标准。

对普通人的影响

对企业 IT:采购 AI 编程工具时,不能只看订阅费,要算上压缩触发的额外 Token 调用;任务越复杂,隐性成本越高。

对个人职场:「会用 AI 写代码」的标准会再升级。稀缺的不是会写提示词的人,而是懂得拆解任务、控制上下文边界的人。

对消费市场:普通用户暂时无感,但长对话 AI 助手(ChatGPT、Claude 等)未来大概率也会加入类似机制,届时的「我好像忘了你说过的话」提示会更常见。

Source: juejin.cn