Skip to content

context: 研究可回收的探索 checkpoint/rewind,不把它等同于 context_pivot #154

Open

Description

@tt-a1i

一句话结论

OMP 的 checkpoint / rewind 解决的是“临时进入高噪声调查,最后只把结论带回来”;OpenPI 的 context_pivot 解决的是“长 Session 换阶段并主动压缩”。两者不是同一个生命周期。

建议研究一个 Pi-native、默认关闭、仅裁剪 Session context、不触碰文件系统 的探索边界。先验证收益和 Pi extension seam,再决定是否实现;不要直接复制 OMP 的强制工作流。

固定证据

对比固定在:

  • OpenPI main@2a69d3f32994da4123f1312b7fa84ef3d6119be1
  • OMP main@7623b960540518bb1291808bbae28332065e9dba

OMP 当前机制:

  • checkpoint 在普通 Session entry 上记录边界,并可在 resume 后重建活动 checkpoint:checkpoint contract
  • rewind 在 turn end 从 checkpoint 分支,写入 branch_summary / retained report,随后重建模型上下文;被放弃的探索仍留在 JSONL,只是不再进入 active branch:rewind flow
  • 它明确不恢复文件、artifact、process 或 git state:rewind boundaries

OpenPI 当前机制:

为什么值得讨论

典型场景:

  1. 主 Agent 已有稳定任务上下文;
  2. 需要追一条可能失败的根因、读大量日志或比较多个实现;
  3. 调查结束后,后续实现只需要结论、证据位置和被排除路径;
  4. 把全部探索轨迹继续带入模型,会抬高 token、污染注意力,也降低 prompt cache 稳定性。

这类能力随模型变强仍然有用:模型负责决定何时进入探索、写什么报告;runtime 只保证分支、保留和恢复事实。

OpenPI 应保留的优势

  • 默认 zero-resident,不为普通回合增加 schema / prompt 税;
  • Pi Session 仍是唯一 source of truth;
  • 不引入第二套文件快照、git checkpoint 或外部状态机;
  • 不把“调查—回滚—实现”固化成强制推理流程;
  • fail closed:不能证明安全分支与恢复时,不得声称 rewind 成功。

建议先回答的问题

  • Pi 当前 extension API 是否已经能安全创建 branch summary / 移动 active leaf?若不能,应先向 Pi 提最小 seam,而不是在 OpenPI 旁路改写 JSONL。
  • checkpoint 在 compaction、session switch、fork、resume 后如何重建?
  • rewind 前后的未完成 tool call、background job、Subagent/Workflow completion 如何处理?
  • 是否只允许 idle boundary 执行,避免 turn 内历史与 UI 投影不一致?
  • 失败时如何证明 active branch 没有被部分移动?
  • 是否需要先做 benchmark:同一调查任务,有/无探索回收时的质量、cache、token 和恢复正确性。

非目标

  • 不恢复或回滚 working tree;
  • 不删除 Session 历史;
  • 不实现多 checkpoint 栈;
  • 不自动判断“这条思路失败了”;
  • 不复制 OMP 的全局 runtime 或 provider stack。

完成条件

  • 写出 Pi-native feasibility note,明确需要的现有 seam 或缺失 seam
  • 定义 success / failure / cancellation / resume 的可观察证据
  • 覆盖 compaction、fork/tree navigation、session resume 与 background completion 的交互矩阵
  • 用至少一个高噪声调查任务比较质量、token、prompt cache 和最终上下文
  • 若实现,默认关闭且 ordinary parent turn 不新增常驻工具
  • 若无法保持 Pi 为 source of truth,记录拒绝方案而不是旁路实现

与现有 Issue 的关系

Activity

  1. added
    enhancement
    on Aug 25, 2026
  2. 627150795 commented on Aug 28, 2026

    @627150795
    Contributor

    Hi! I would like to work on this research/documentation issue.

    I will document the distinction between recyclable exploration checkpoints/rewind and context_pivot, including lifecycle, recovery, branch, retention, and authority boundaries. I will keep this contribution documentation-only: no runtime checkpoint manager, API, or UI changes.

  3. 627150795 commented on Aug 28, 2026

    @627150795
    Contributor

    Update: the exploration checkpoint/rewind contract is implemented in PR #250: #250

    Validation completed: git diff --cached --check, bun run lint, and bun run typecheck passed. This is documentation-only; it does not add a checkpoint manager, restore files, mutate Git refs, or change context_pivot runtime behavior. The PR uses the repository template and will close this issue when merged.

  4. tt-a1i commented on Sep 8, 2026

    @tt-a1i
    CollaboratorAuthor

    2026-09-08 目录补一条文件系统对照,不改 #154「只裁剪 context、不碰工作区」的现结论。

    官方 example git-checkpoint.ts(earendil-works/pi main blob 6f26cff)在 turn_start 做 git stash create,/fork 时可 stash apply 回到那一 turn 的代码。这和 OMP/本帖的 Session context checkpoint 不是同一生命周期。

    问题开在 #508。本轮未运行该 example。不提议把 stash 恢复默认打开。

  5. tt-a1i commented on Sep 9, 2026

    @tt-a1i
    CollaboratorAuthor

    结论

    官方 /handoff 和 @pify/yolo rewind 都不是本帖要的「只裁剪 Session context、不碰文件系统」。本帖范围不用改。

    事实(源码,未安装未运行)

    • 官方 handoff.ts blob ed3416be(earendil-works/pi 6160683):序列化当前 branch(含 compaction 摘要)→ 另一次模型生成 → 用户编辑草稿 → newSession({ parentSession }) → 新会话 setEditorText。TUI-only。不碰工作区。
    • OpenPI a9b40f0 的 context_pivot 仍是同会话 ctx.compact()。/plan fresh 已经占用同一条 newSession({ parentSession }) 缝,brief 来自 Plan Ready,不是一般 /handoff。
    • 仓库 没有 /handoff skill,也没有 registerCommand("handoff")。SETUP.md 写「use the separate /handoff skill」是文档谎言(模型可见的 context-pivot description / 错误同样指向它)。不是本帖的实现缺口。
    • @pify/yolo 0.9.1(4c019d0)的 /yolo rewind 按用户 prompt 恢复工作树(git checkout <stash> -- .)和/或调用 navigateTree。这是文件系统 + 会话 leaf,违反本帖非目标第一条。

    建议

    新会话 + parent 指针挂 #193。工作区 / turn 恢复挂 #508。不要为本帖引入 stash 或 yolo 产品。

    本地深读:docs/research/EXPERIMENT_HANDOFF_GATES_2026-09-09.md。本轮未 pi install、未运行。

  6. tt-a1i commented on Sep 9, 2026

    @tt-a1i
    CollaboratorAuthor

    2026-09-09 对照一条目录/切换缝,不改本帖「只裁剪 context、不碰工作区」的现结论。

    /sessions 与 Pi 原生 /resume 换的是哪一个 Session 文件是当前活动会话:session_before_switch → shutdown → 打开目标 JSONL → session_start(reason: resume)。这不是 rewind,也不是 compaction。

    • 搜索/预览是人对目录的投影;切换必须走 Pi switchSession,禁止旁路改 JSONL 或第二套 session store。
    • 本帖 rewind 是同一文件内移动 active leaf / 写 branch_summary。
    • context_pivot / 原生 compaction 是改模型窗口。新会话 handoff 是另一份 JSONL + parentSession(见同日 handoff 记录)。

    源码对照写在 docs/research/EXPERIMENT_SESSIONS_CONTINUITY_2026-09-09.md。本轮未安装、未运行社区包。不提议把 picker 扩成 rewind,也不把 #154 并进 /sessions 或 #474。

  7. tt-a1i commented on Sep 9, 2026

    @tt-a1i
    CollaboratorAuthor

    结论

    社区包 cyclotomy 0.2.4 把工作区检查点绑到 Pi /tree 节点上。这不是本帖要的「只裁剪 Session context、不碰文件系统」。本帖范围不用改。

    事实(源码,未安装未运行)

    • /tree 仍是 Pi 内建:navigateTree → session_before_tree(可 { cancel: true })→ 改 leaf → session_tree。Cyclotomy 不注册 /tree。
    • 它在旁路 CAS(~/.pi/agent/cyclotomy/)里按 (sessionId, stable entryId) 存最多一份工作区快照;不写 Pi JSONL,不改 .git。
    • TUI /tree 若目标与磁盘不同:stay / detach / restore。无 UI + drift:取消 leaf 移动。Print/JSON 重开会话时留盘;RPC 等 /restore。那不是 print 模式下的 /tree。
    • 默认 enabled: true。卸载不删明文副本。

    OpenPI a9b40f0 没有 session_before_tree handler。SESSIONS 记录「/tree 不改工作区」在没装这个包、或包已停时仍成立。

    建议

    不要为本帖引入工作区快照或这套 CAS。工作区轴挂 #508(fork stash ≠ /tree 绑盘 ≠ 本帖)。不装。不开新 Ideas。

    本地深读:docs/research/EXPERIMENT_CYCLOTOMY_TREE_2026-09-09.md。钉 [email protected] / git aa54bab。未 pi install、未运行。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions