Repository navigation
feat: let the model read history behind a compaction checkpoint - #60
Merged
Merged
Conversation
Preserve the proposed history lookup, file restoration, and cache reuse design before incorporating review feedback.
After a compaction the model keeps only the summary and a recent tail, so an exact snippet the summary dropped (code, error text, the user's wording) was gone for good. This adds R21.1, a bounded read-only lookup of the transcript at or before the active checkpoint. host-core serves session.historyRead from a layout snapshot outside the state lock, on a blocking thread, with stable message-id cursors so a rewritten transcript invalidates a cursor instead of reusing offsets. It returns a model-facing projection without thinking, sub-agent rows or attachment bodies, and bounds page size, output and keyword scans. The sidecar host admits the method only for sessions the embedding host launched into that sidecar. The runtime registers ContextHistory as an on-demand tool next to new_context, binds the session itself, pins cursors to their checkpoint, and adds a lookup hint to the summary only while the tool is callable. Delegates never inherit it. The plan is confirmed as R21 with validation V60; R21.2 and R21.3 are not implemented here. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 30, 2026
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.
改动
实现 R21.1:压缩后,模型可以回查压缩点之前的原文,用来找回摘要漏掉的代码、错误原文或用户原话。计划由 X-COMPACT 转为 R21,验收 V60。
session.historyRead(crates/host-core/src/transcripts/history.rs、rpc/mc_session_history_rpc.rs)。throughMessageId及之前的消息,按页读取,不读全量 transcript。spawn_blocking。with_layout_recovery重建一次。agent-sidecar.ts记录嵌入宿主经agent.prepare / prompt / steer / compact / executeApprovedPlan交给本 sidecar 的会话,agent.disposeSession和连接关闭时移除。session.historyRead只对这些会话放行,其他会话返回SESSION_NOT_BOUND。session.get行为不变。ContextHistory(mc-context-history-tool.ts)。new_context一起注册,通过 ToolSearch 按需加载,所以压缩前后工具集合不变。query/around/cursor/limit;游标固定在它来自的检查点上。SUBAGENT_INHERIT_DENY_TOOLS)。刻意未改
session.get,不改数据库结构。契约取舍
一个 sidecar 进程承载多个会话 runtime,线路上没有单个 runtime 的身份,可信关联只能做到"嵌入宿主交给本 sidecar 的会话"这一层。同一 sidecar 内 runtime 之间的隔离,仍依赖 runtime 自己绑定
sessionId。验证
reviews_rpc_never_follows_redirects在全量运行时失败,单独重跑通过,与本改动无关。cargo fmt --check通过,Clippy 未报新文件问题。rpc-lifecycle-contract、browser-preview-tool共 20 项通过。pnpm lint、git diff --check、文档检查(645 页)通过。未调用真实模型,没有动安装版。还没验证的:
🤖 Generated with Claude Code