pi-posthorse README

项目的 README,来自 github.com/fitchmultz/pi-posthorse。合并为一个 markdown 文件:README.md。

Posthorse

Posthorse starts fresh context windows for long Pi tasks without an automatic model-generated summary of the work. Official Pi already preserves the session journal and retains a recent tail during compaction; Posthorse adds explicit notes and history retrieval, with a handoff or bounded recovery record instead of the automatic summary.

A Pi conversation rolls into a fresh context window. Task notes and the complete session transcript remain available.

Install and start

Check the Node.js and Pi requirements before installing. Posthorse supports official Pi and fitchmultz/pi.

Update an older Pi installation before you install Posthorse. Run these commands:

pi install npm:pi-posthorse
pi

Restart Pi after installation or an update. To try Posthorse for one session, run pi -e npm:pi-posthorse.

Give Pi your task. For example:

Save task state in a note. Start a fresh context window with the next steps.

How rollover works

Posthorse can send a routine task-note reminder before rollover. The reminder tells the model to save current task state if needed, then immediately continue the prescribed work. The context window is not a task deadline. The reminder does not require new_context or wake an agent after its final answer. Large turns can reach rollover before the reminder. See Reminder timing for the trigger and its relationship to Pi's reserve and retention settings.

Automatic rollover retains a safe recent-message tail using Pi's compaction.keepRecentTokens, alongside a bounded recovery record for discarded inputs and tool evidence. No model summarizes the work. The model must restore notes and check live state before it continues. On fitchmultz/pi, a Claude model also writes one line that points to the task note, so that Claude keeps the reasoning of the retained replies. Optional new_context deliberately retains no prior messages; manual /compact uses Pi's normal summarization.

Posthorse does not schedule rollover when a provider cache expires. An idle session below the rollover threshold keeps its context; use an explicit new_context when a deliberate clean reset is useful. See idle sessions and cache expiry.

See the changelog for release history. Default-branch documentation may describe changes not yet published.

Recoverable history is not guaranteed model recall. See the practical guarantees and limits for the official-Pi comparison, search scope, checkpoints, privacy, concurrency and cost, or the rollover reference for implementation details.

The field study measures what agents did around 24,940 context boundaries in daily use: note and history use, repeated work, stops, wait time, and cost. It is observational, not a controlled comparison with stock compaction.

The controlled comparison runs the same two-hour coding tasks with stock compaction and with Posthorse on two models. It reports how often the agent stopped with work left, the tests passing, the wait at boundaries, and the cost. It covers one benchmark family and two models of one provider.

Tools

These tools are available to the model:

Tool Use
new_context({ handoff? }) Optionally request a clean reset with no retained messages after every foreground tool succeeds. Aborted turns and failed tools prevent the reset.
get_context_remaining() Estimate tokens left until rollover and the configured context limit. Usage can be unknown before a model response.
notes({ op, ... }) List, read, search, write, or append task notes.
history({ op, ... }) Search earlier conversation and read entries, including images. all: true includes this project's other sessions and nested subagent runs.

Expand a tool card with Ctrl+O. In fullscreen mode, click a tool card to expand it. A new_context card shows a request. Pi's Compacted from … tokens card confirms the rollover.

Forks get private copies of the notes used on their selected branch. The parent and fork can update the same note name without overwriting each other. Project-wide lists and searches still find both, with scope selectors for read-only comparisons.

See tool examples and paging details and fork notes.

Settings and limits

Posthorse uses Pi's effective compaction settings. It has no separate settings.

Pi setting Effect
compaction.enabled Set to false to disable reminders and automatic rollover. new_context remains available.
compaction.reserveTokens Automatic Posthorse rollover needs at least 10,000 tokens after this reserve. Smaller budgets use Pi's own compaction. Lower the reserve or choose a larger model.
compaction.keepRecentTokens Approximate recent tail for automatic rollover (Pi's default: 20,000). Zero keeps no messages. Tail size shrinks when safe groups cannot fit the fresh budget.

Two Posthorse copies can register the same tools and compete for rollover. Keep one copy loaded. Check installed sources with pi list.

Multiple compaction-policy extensions can make rollover depend on load order. Enable only one.

Oversized input and some overflow or truncated responses can reach the provider before automatic recovery. Save task state in notes. Posthorse's automatic and explicit rollovers do not stop background work outside the foreground tool batch. Manual /compact follows Pi's abort behavior instead.

See size limits and extension order. Check the legacy-session details before you move old fork sessions to official Pi.

Update or remove

pi update npm:pi-posthorse
pi remove npm:pi-posthorse

Removal leaves notes and Pi session history in place. See the installation reference for Git sources.

Data and privacy

Posthorse makes no network requests. Notes are plaintext files under .pi/notes/. Linked Git worktrees share that store; forks keep private note files inside its .forks/ directory. Notes for Pi-managed Git packages live outside their checkouts because pi update deletes untracked files there: global packages (including their descendants) use Pi's agent-directory notes/, and other project-local packages use the containing project's .pi/package-notes/, with project-local stores keyed by a full SHA-256 digest of the host and package path. Access existing checkout-local notes with this version before updating the package so they can migrate. Add .pi/notes/ and .pi/package-notes/ to the containing project's .gitignore if the notes must stay private.

History can include user messages, assistant thinking, tool arguments, errors, and images. Content you retrieve enters the context of your selected model and provider.

See storage and privacy details. For cost diagnosis, see the cached-token investigation. It does not establish the cause of a production bill or a measured cost improvement.

Development

See development and host qualification for setup, tests, and releases. See code quality for the required checks.

License

MIT.

pi-posthorse (fitchmultz/pi-posthorse)

正在搜索数据库…

这是什么?Posthorse 是 Pi 编程智能体(具体是 fitchmultz/pi 这个 fork)的一个扩展,用于在不做摘要的情况下处理上下文窗口轮换:当会话接近上限时,它会以一次持久化的交接和完整可恢复的对话记录开启一个新窗口,而不是把历史压缩成摘要。
这是独立应用,还是其他东西的附加组件?它是安装到 Pi 里的 Node.js 扩展/包,不是独立应用;Pi 保留持久化的会话边界,Posthorse 则在其上提供轮换策略以及 “newcontext”、“getcontextremaining”、notes 和 history 等工具。
它需要官方版 Pi,还是必须是那个 fork?你需要 Node.js 22.19+ 和 fitchmultz/pi 这个 fork(CI 锁定在 Pi 0.85.0 的特定提交上);官方未打补丁的 Pi 不受支持,会显示明确的扩展错误而不是正常运行。
上下文装满时自动轮换总会触发吗?只有在启用 Pi 的压缩功能、且模型上下文减去预留 token 后至少还剩 10,000 个可用 token 时才会;较小的模型或过大的预留量会退回 Pi 自带的压缩,而且一次很大的单轮交互也可能在从未触发检查点提醒的情况下直接达到轮换。
我的代码或聊天内容会离开我的电脑吗?不会,Posthorse 完全不发出网络请求;笔记、交接和对话记录都以明文文件的形式留在本地,位于 .pi/notes 下以及 Pi 自己的会话 JSONL 历史中。
如果我卸载 Posthorse,我的笔记会怎样?什么都不会丢失:移除这个包后,.pi/notes 和 Pi 的会话历史原样保留。
能把 Posthorse 和旧的 pi-headroom 扩展一起运行吗?同一时间只应启用一个自动轮换/压缩扩展,因为 Pi 只保留最后一个处理器的结果,两个已加载的策略会在同一个钩子上悄悄竞争;不过 Posthorse 能识别 pi-headroom 的旧提醒并据此去重。
到底哪些内容会被带进新的上下文窗口?一次原子化的交接,包含用户的直接输入、尚未查看的工具调用结果和可见的协调消息,外加一个明确标注可能已过时的旧检查点;已被消费的助手文字和工具结果则被留下。
Codex 版本可以投入使用了吗?不行,Codex 原型只是一个孤立实验,在 Codex 原生的上下文重置下做本地笔记和恢复,README 明确说它“尚未达到日常可用”,也不包含在 Pi 包中。
大小
8.2 MB
星标
288
时长
3个月
提交 · 90 天