Skip to content

perf(context): batch nested discovery and guide focused reads - #7670

Merged
loopx-agent merged 2 commits into
mainfrom
codex/context-index-depth-20261029
Oct 29, 2026
Merged

loopx-agent merged 2 commits into
mainfrom
codex/context-index-depth-20261029

Conversation

@huangruiteng

@huangruiteng huangruiteng commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Nested capture discovery required a CLI round trip per level, and recovery instructions sent callers back to an index even when they already knew the required pointers. Add opt-in context-read --list --list-depth 1..8, preserve depth in digest-bound continuations, and reuse selection guidance across normal capture replies, native configuration and post-compaction recovery.

Known pointers go straight to one multi---select read. Unknown pointers use a focused parent index; callers are advised to respect combined output budgets, avoid overlapping parent/child reads and inspect a missing pointer before retrying a rejected batch. The shipped project and self-repair skills generalize this to known file paths and record IDs, captured-response reuse and independent read batching while keeping dependent operations, mutations, authority freshness and uncertain-effect recovery ordered. No new setting or policy enforcement is introduced.

Default single-level indexes and full/value-read semantics stay unchanged. Indexing is metadata navigation, never evidence of reading or model retention. Current requirements, capture digests, original work/effect identities and authority checks remain required. The existing conversation response is the user journey; no new frontend state owner is added.

Validation:

  • Targeted Python suite: 285 passed, 7 opt-in skipped and 2 recovery prose-budget failures initially; after documenting the measured increase and adjusting only the synthetic allowance, all four lifecycle cases passed, resolving both failures (287 distinct passing cases overall).
  • Recovery guidance now measures 2,852 characters in the synthetic lifecycle fixture. Its test allowance is 3,100 instead of 2,600 to retain the new caller choices plus existing authority/retention clauses; actual host output/context limits are unchanged.
  • Existing selection tests cover pagination, changed-depth rejection, escaped keys, original values, no registry access and retention boundaries. Earlier depth implementation validation also passed five TypeScript selection checks.
  • All 13 changed public surfaces passed the boundary scan; the combined local check still reports unrelated registry health errors. Whitespace check passed.
  • Same executable, synthetic immutable capture and three equal required values, alternating order with warmup plus five samples: separate versus batched reads used 3→1 calls, 2,296→964 response bytes, and 1.25→0.41 seconds median. This isolates caller choice, not code speed or model behavior.
  • Earlier fixed-capture depth comparison: equivalent field discovery used 3→1 calls, 7,341→6,268 bytes and 1.43→0.47 seconds median. Neither comparison establishes whole-turn token savings or task-effectiveness improvement.

The shared guidance is a bounded consolidation at the existing context-delivery owner. No new selector, cache, relevance classifier or admission path is introduced by the recovery follow-up.

@huangruiteng
huangruiteng force-pushed the codex/context-index-depth-20261029 branch from fdfc823 to 0060c62 Compare October 29, 2026 14:54

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

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.

动机 / Motivation

需要从已保存上下文中找到当前要求、停止条件和证据,并在压缩后继续原任务的 Agent 或 CLI 用户。 已知路径原先也会被恢复指引送回目录,三层未知结构需逐层往返。新 head 让已知地址直接批量读取、未知地址有界发现,并在正常回复、配置和恢复三个入口给出一致选择。 同一子树的八个字段仍从三次 CLI 读取变为一次;真实 hook 的恢复指引从 2,430 增为 2,848 字符,同时保留原要求、身份、停止和不重复 effects 的条款。 本 PR 不修改 Host 的 20,000-token/64,000-byte 配置,不把索引当作已读或模型保留,也不交付新的持久设置、权限、模型采用或整个统一上下文主线。 恢复指导增量有实际文本成本;目录调用减少不证明整体 token、模型理解、安装态或长程净收益。已有统一上下文 owner 继续相应资格。

改动思路 / Approach

多层目录仍留在既有 RFC 6901 owner;新增的选择指引在普通 capture、持久 native 配置及 compaction hook 共用一份文字,避免恢复路径重新要求先查目录。 本 PR 交付现有 reader 和当前已加载指引的完整可用增量;不改变原必读合同、retention 或执行权限,原生文件与历史 capture 仍由原 owner 恢复。 最强反例是恢复文字遗漏原必读/权限条款,或仅放宽大小测试便宣称收益。因此这里同时比较原义、真实入口、恢复文本增长与导航成本。维持当前完整契约所需文字比机械缩短更有价值,增加 synthetic allowance 的依据必须与 Host 硬限制、冻结实验门分别核对。当前 advisory 用于检查实际可用结果和总成本,没有继承历史 verdict。

具体改动 / Changes

完整审查新 head 0060c62 相对实际 base ed0972c 的 13 文件 +198/-25。旧 fdfc8232e5be755d4de88e591e78db0cb532714e 评审稿因换头停止,未发布;没有把旧结论转为新 head 的批准。当前范围重新覆盖 reader、共享指引、native 配置/恢复和三个技能文件。

关键代码讲解

  • capturedContextSelection:唯一 RFC6901 地址选择和深度遍历;只列直接子节点→显式 1..8 层;省略仍一层。own keys、转义与 array index 验证;不返回值。
  • read_context_capture:原字节/派生 view 双摘要分页;expanded index 把深度纳入 view 与 next_command。变化深度不能借旧 selection SHA 续读。
  • CONTEXT_CAPTURE_SELECTION_GUIDANCE:唯一known/unknown选择指引;新增combined budget/no-overlap/missing-parent建议,原requirements与权限条款保留。normal/setup/recovery共用而非独立文字owner。
  • _context_continuation_instructions:原Turn恢复命令指引;恢复命令直接给--select占位;已知路径不必先list。保留原Goal/requirements/stops/Task/capture/effect;missing事实先恢复。
  • codex_context_hook:原生epoch与恢复owner;原invalidation后附共享selection指导。不因指导改写capture/retention或重放已结算effects。

深度只在显式 context-read --list 下接受 1–8,默认仍为 1;original full/value 读取不变。expanded index 只给 pointer/type/bytes/count,深度参与派生 view 摘要,next_command 保留深度和两个 SHA。变深度续读不能借旧摘要,目录 EOF 不能升级为模型已读证明。

同一个固定 capture 的八个字段,当前 base/head 实际 CLI 发现为 3→1 次调用,3,002→1,489 字节 stdout;default-index 和 known-selection 内容摘要相同,full reader 保留原始字节,large integer、1.0、负零和完整停止尾部保持。缺失路径使批次失败,损坏 capture 不返回正文、不准入或记账。

新 CONTEXT_CAPTURE_SELECTION_GUIDANCE 在正常回复、持久配置和压缩后 hook 复用。已知 pointer 直接 batch;未知 pointer 查最近父节点;按合计输出预算分批、避免 parent/child 重复、缺失地址先检查原 capture 的父节点。它们是建议,reader 的原校验与必读要求不因建议而消失。项目/自修复技能把相同原则推广到已知文件和 record ID;依赖操作、写入、权限新鲜度和不确定效果恢复仍有顺序。两个技能及相对链接目标由既有 workflow bundle 交付,无新安装动作。

先读 docs/reference/required-work-context.md 和 docs/development/README.md,不可变版本 ed0972c。原文无编号,以下只是本次定位标签:READ-1 原值及索引不等于已读;READ-2 原 capture/精确 view 的摘要续读与恢复;READ-3 必要要求/停止条件先于依赖工作,操作合同先于 effects。逐句比较了 actor、触发、时序、来源、scope、权限、continuation、stop 和 settlement;真实 hook 对照保留九条原义,并保持原 recovery、使下一 epoch 重新建立基线,不重放原工作。

有依据的回归预算调整

同一隔离 hook/config 工作量中,恢复文本为 2,430→2,848 字符。新文本会超过旧 2,600 的 synthetic allowance;原失败保留,当前 3,100 留 252 字符余量。增长来自新选择建议,原要求和 retention 条款没有删减。actual config 的 20,000-token history / 64,000-byte reader 不变;没有放宽 Host 硬限制、原 7,900-byte reference ceiling 或冻结实验标准。这是完整性与重复输入成本的明确 tradeoff,不是整体 token 或长程收益证明。

对主干的风险

未发现 blocking finding。 宽子树仍可能产生较大目录,深度上限只限制层数,不能当作总大小或时间上限。默认读取和 known/unknown 指导仍依赖 Agent 正确选择事实;模型理解、安装态及长时稳定性未资格。历史其他集成版本的通过没有当作当前 head 证据。

当前 PASS:245 个 Python reader/lifecycle/saved-project 检查、3 个真实 Codex loopback 路径(CodeMode、App Server、quota/Turn、失败恢复与两次 compaction)、5 个 TS、typecheck、Ruff、标准 premerge 6 direct / 10 catalog / 8 risk / 1 public-boundary,无 hold。初轮另有 7 个 opt-in native 场景跳过,未改记为通过;固定 loopback 只替代模型,不能证明模型理解。原 default/off 及 signed/required-source 合同保持;未查询、轮询或等待 CI。

技能指引对既有加载受众直接生效,包括 ordinary off 工作;这是已披露的通用读取建议变化。它不激活 native delivery,也不能覆盖 caller 自己的完整读取义务。runtime 的普通 off 指引未改,新深度仍须显式选择;没有假称所有 help/skill 字节相同。原 capture、权限、Stop 与不确定 effect 的恢复规则继续约束这些建议。

我的整体评价

当前 head 交付了正常读取和恢复一起可用的增量,解决了只在正常回复改导航、恢复仍要求重复发现的缺口。多层目录仍留在既有 RFC 6901 owner;新增的选择指引在普通 capture、持久 native 配置及 compaction hook 共用一份文字,避免恢复路径重新要求先查目录。 本 PR 交付现有 reader 和当前已加载指引的完整可用增量;不改变原必读合同、retention 或执行权限,原生文件与历史 capture 仍由原 owner 恢复。 long_horizon 轴接受有依据的指导增长与导航成本减少的 tradeoff,保留整体净益未知。已检查CLI reader、native配置/hook、两份技能及文档:仅命令/指引正文变化,无页面、组件、布局或首屏呈现变化。 安装态人机阅读、真实模型采用与长期使用未验证。 批准当前精确 head,merge、安装与父级成果验收仍分别处理。

English verdict: APPROVE at 0060c62; focused discovery and recovery guidance are verified, with explicit prose-cost growth and model/whole-turn benefit unqualified.

@loopx-agent
loopx-agent merged commit 3b3386d into main Oct 29, 2026
24 of 41 checks passed
@loopx-agent
loopx-agent deleted the codex/context-index-depth-20261029 branch October 29, 2026 15:30
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.

2 participants