feat(agent-runtime): carry the session checklist across compaction - #1275
Open
hxj04121-lab wants to merge 1 commit into
Open
hxj04121-lab wants to merge 1 commit into
hxj04121-lab wants to merge 1 commit into
Conversation
Compaction summarizes the TodoWrite calls that kept the session checklist current, so after a checkpoint the model no longer knew which steps were done and could rebuild a second list (vastsa#1177, stage 5). When the runtime installs a checkpoint it now reads todos.get for its own session once and stores { revision, updatedAt, todos } in the checkpoint's opaque details, only while unfinished items remain. The context projection renders that copy after the checkpoint summary. The stored summary is unchanged, so a later compaction never carries a stale list forward and the transcript row does not show it. Because the copy is persisted with the checkpoint it survives restart and is written once per checkpoint instead of being injected on every request. The host table stays the only authority. A failed read, an older host, a native Pi session or a finished list installs the checkpoint without a copy, and the copy is dropped rather than pushing a fitting checkpoint over the safe budget. todos.get joins the sidecar proxy allowlist as a read-only method; writes still go through host-authorized TodoWrite. Approved Plan and Goal execution instructions now ask the model to keep the checklist current (stage 4 continuation reminder). Refs vastsa#1177
hxj04121-lab
force-pushed
the
feat/todo-compaction-snapshot
branch
from
October 3, 2026 16:34
0246692 to
1e7430b
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题与修复
#1177 阶段 5 的必需项,加上阶段 4 的续跑提醒。实现方向按 issue 里的讨论(评论,@HanawaBanana 也倾向这个方案):清单快照写入压缩检查点,不在每轮请求里临时注入。
压缩会把维护清单的
TodoWrite调用一起摘要掉,压缩后模型不知道哪些步骤已经做完,容易重新建一张清单。现在运行时安装检查点时:todos.get(只读本会话),仅当存在待办或进行中条目时,把{ revision, updatedAt, todos }写入检查点的details.todoSnapshot。<session_checklist revision="…">,说明“这是压缩时的清单,之后的TodoWrite以新的为准,每次调用仍需重发全部条目”。summary不变:转录里的压缩行不会出现清单,下一次压缩把previousSummary往前带时也不会带上过期清单;每次压缩重新读取一次。权威源仍然只有 host 那张表,渲染器不读这份副本。降级行为:
todos.get失败(旧 host、native Pi 会话、代理拒绝)→ 照常安装不带快照的检查点;sidecar 白名单:
HOST_PROXY_ALLOWED只新增只读的todos.get(与session.get同级),清单写入仍只能走 host 授权的TodoWrite。续跑提醒(阶段 4):Goal/Plan 批准后的执行指令加一句:多步执行用会话清单跟踪,
TodoWrite是延迟工具需先经 ToolSearch 激活,结束前每项都要完成或取消。ADR 0312 增加 2026-10-01 修订;host RPC 协议规格与 E2E 场景
E2E-CHAT-session-todo-checklist(中英文)同步。停滞提醒(阶段 5 可选项)不在本 PR 范围内。
验证
1e7430be8157;基线main:3b036cc7810e;环境:macOS arm64,Node 23.11.0。main(含 Pi 1.0 迁移):persistCheckpoint保留上游新增的details.systemMessageJson,再在其后计算预算并附加清单快照;session-context.ts保留系统消息投影,并在其后渲染清单。rebase 后 agent-runtime 1247 项中 1244 项通过,3 项在高负载(load 14)下超时,单独重跑全部通过(4 个文件 84 项);host-runtime 121 项、lint、typecheck、check:pr-base通过。pnpm build:js、agent-runtime / host-runtime typecheck、pnpm lint、pnpm docs:check、git diff --check、以基线为准的pnpm check:pr-base:通过。runtime.test.ts「session checklist ([Feature] 会话级任务清单(Todo):让多步任务的进度可见,一起来讨论方案 #1177)」5 项:检查点写入快照且摘要不变、模型上下文中快照位于摘要之后;todos.get失败时压缩仍成功;已完成清单不写快照;快照超预算时丢弃且不触发 fallback;从持久化检查点恢复后上下文仍含清单。runtime.test.ts续跑提醒 2 项(plan / goal)。checkpoint-todos.test.ts7 项:解析容错、未完成过滤、格式、条目文本不能提前闭合</session_checklist>、session-context投影。session.appendCompaction调用(之前假设它是第一个 host 调用)。sidecar-todo-proxy.test.ts2 项(真实 stdio 反向 RPC:todos.get放行,todos.set仍以 -32601 拒绝)。node --test test/*.test.mjs:3346 项中 3337 通过,2 失败、7 取消,均与本改动无关且在main上同样存在:chat-error-message.test.mjs:53(test 嵌套在另一个 test 回调内被取消)、imported-package-skills-runtime.test.mjs:221(Node 23 错误文案与断言不同)、plugin-websocket.test.mjs7 项取消(本机沙箱限制回环 socket)。node scripts/check-architecture.mjs:报告的 6 条违规均为main上已有文件(live-voice、pt-BR 等),不涉及本 PR 文件。pnpm test:e2e:todos;本机主 checkout 与 worktree 均没有 Electron 二进制,未为此额外下载。替代验证为上面的 runtime 压缩路径测试和 sidecar 真实 stdio 代理测试;剩余风险是未在 Electron 中实跑“压缩 → 下一次请求带清单”的完整链路。Refs #1177