Skip to content

Defer section digests for incomplete native context reads - #8401

Open
loopx-agent wants to merge 1 commit into
mainfrom
codex/defer-native-section-digests-20261109
Open

loopx-agent wants to merge 1 commit into
mainfrom
codex/defer-native-section-digests-20261109

Conversation

@loopx-agent

Copy link
Copy Markdown
Collaborator

Codex's native context hook computed section digests for each selected page, even though the journal can only record those digests after complete byte coverage. Skip that work when neither the current tool response nor the journal contains the terminal range. The hook still verifies every page against its immutable capture; the existing reducer still decides when coverage is complete.

In a synthetic File and SQLite CLI replay with three selected pages, hook RPCs went from 9 to 7 and hook transfer bytes fell 41.2%. Across the guard, required reads and hooks, framed bytes fell 17.5%. Tool output byte counts stayed the same. The two-page integration replay went from 4 to 3 hook RPCs, with 33.4% fewer hook transfer bytes.

Validation covers sequential delivery, EOF arriving before a gap, damaged bytes, and an out-of-order batch. It includes the local standard premerge canary and the packaged CLI against File and SQLite, where replaying the same captured pages produced identical journal state after every hook. This replay measures internal transfer, not model token or end-to-end benchmark savings.

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent, gpt-6.1-sol, OpenAI, runtime_reported, reasoning_effort=max

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

动机 / Motivation

选读还没收到末页时,native hook 已在计算暂时用不到的 section digest。对照 File 和 SQLite 上同一份源捕获的三页顺序读、乱序读和损坏页。候选少做两次顺序读取的 RPC,完整覆盖时仍确认同一组字段。这次走实际 quota CLI、选读和 hook,使用隔离的合成会话。未测真实模型用量或任务收益。

改动思路 / Approach

沿用原逐页字节验证与 TypeScript 覆盖 reducer。只在当前批次和本选读视图的 journal 都没有末页时延后摘要。确认终页或补齐旧缺口仍计算原摘要;不同视图与损坏数据不互相补齐。状态的分类和生效点都由现有 owner 决定。

具体改动 / Changes

评审 53ab9df,PR 基线 c44eb15,4 个文件,+91/−14。实测当前主干与基线,已合入的其他路径不重叠。现有选读契约 对应 verify-each-page、complete-only-ack、defer-unusable-digest 已验证;production-context-cost 另验。

关键代码讲解

对主干的风险 / Risks

基线与候选各通过 8 个实际 CLI 对照。顺序读的 hook RPC 由 9→7,File/SQLite 各少约 107 kB 内部传输。末页先到、夹杂错误页、整批反序及另一视图先完成时,逐次覆盖和确认结果一致;恢复原页后仍按原字段摘要确认,未建立全量保留基线。另有 267 项相关测试、6 项直接及 11 项自动预合并检查通过。工具的续读命令包含测试路径,未将其长度变化计入收益。

我的整体评价 / Verdict

认可当前提交。该优化避免重复计算但仍逐页核对原捕获;不能用末页替代连续覆盖,也不会把选读确认当成全量留存。数字只代表本地 hook 传输,生产规模与模型成本需要另测。

English verdict: APPROVE. Deferring redundant section digests saves two hook RPCs in the matched sequential read while preserving per-page integrity, exact coverage and recovery.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant