Repository navigation
docs(context): keep native page readers in the foreground - #7491
Conversation
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent; gpt-6.1-sol; OpenAI; runtime_reported; reasoning_effort=max
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
结论:APPROVE;未发现阻塞问题。评审绑定 a187819。
动机 / Motivation
使用原生 Codex 分页读取上下文的 Agent,会遇到正文已显示、hook 却只收到轮询尾部的情况。同一次读取若提前返回,模型可能看到完整页面,PostToolUse 仍缺少页面;下一次决定必须保守回到全量。改用正常前台等待可避免这条已复现的交付缺口。两个真实原生用例核对模型输入和 hook 输出,只有完整 hook 页面才允许建立 candidate;前台用例确实得到完整页面。本 PR 只补充宿主读取建议和回归验证,不改变 codec、配置默认值、hook 信任、准入或结算,也不证明模型理解、实际任务收益或费用降低。
改动思路 / Approach
这里需要区分模型收到的页面与生命周期 hook 收到的输出。基线已有 digest、完整字节覆盖和精确原捕获恢复规则;新增文字解释短命令提前 yield 后为什么仍可能缺少 hook 覆盖,并建议使用正常 10000 ms 前台等待。该参数决定工具何时交还控制,不是进程超时,也不会无条件多等十秒。若实际仍 yield,必须继续消费所有片段,并接受下一次决定全量回退;不增加人工确认或另一套读取记账。
测试复用既有原生 fixture、本地固定响应 provider 和产品 codex_context_hook。提前返回场景通过文件 gate 保持进程存活,直到 provider 已收到页面后才释放,避免用碰运气的 sleep 来证明差异。前台场景是正对照;未来宿主若向 hook 提供累计完整输出,也允许通过原有完整性规则。
具体改动 / Changes
规格依据:docs/reference/required-work-context.md,spec_revision d52f2e1。CTX-HOOK-COVERAGE 对应完整 hook 字节覆盖才建立基线,CTX-ORIGINAL-RECOVERY 对应丢失上下文后恢复同一原捕获、不得重新准入或扣额;两项均 implemented。以改动前合同为依据,没有用新文字追认更宽权限。
关键内容讲解
- 共享读取说明的英文和中文段落均保留主体、触发条件、完整覆盖、全量回退及原捕获恢复义务,新增等待建议没有缩小这些条件。
- heartbeat 集成说明同步说明轮询尾部与 hook 缺口;未修改生成器、保存的自动化提示或生产代码。
- 原生测试先断言实际请求包含完整 view,再独立提取 PostToolUse 页面。candidate 与 pending 的断言依据 hook 是否完整,不能由模型看到 EOF 或进程退出替代。
完整 diff 是三文件新增 101 行,其中文档 18 行、测试 83 行,没有生产状态或协议新增。现有测试覆盖 late hook discovery、分页和 compaction,新增用例针对“早期输出+存活进程+轮询尾部”这一不同边界;相关同作者 #7481 已修复 workspace 连续性,当前基线包含该修复,本 PR 没有重复实现。
对主干的风险 / Risks
最强反例是进程退出时模型已看到整页,但 hook 只看到了空尾部。真实 Codex 0.163.0-alpha.11.1 的新增两例均 PASS,且采用隔离 home 和本地固定响应,不调用付费模型或活动 Goal。该测试验证真实宿主工具与 hook 边界,不能证明模型理解,也不覆盖所有 Codex 版本。测试对未来完整累计输出留有合法路径,没有把当前宿主缺口永久冻结为产品要求。
PASS:新增两例;changed-test Ruff;standard premerge 的 diff、编译、双语 RFC 检查、6 项 catalog、8 项风险 smoke 和三文件 public-boundary scan。另 22 个原生用例未在此定向命令中执行,明确为 deselected;没有把它们计为通过。没有查询或等待远端 CI。
我的整体评价 / Verdict
该切片完成了读取指引和可重复边界验证,long_horizon 与 user_experience 均 preserved:保持恢复与后续决定规则,不增加交互轮次;减少全量回退只是适用宿主上的预期收益,尚无长程成本或效果测量。visual_review 为 not_applicable:没有渲染页面或 UI 变化;unverified_scope 为其他宿主版本、已安装 App 实际采用、模型理解与完整任务收益。现有 fixture 已复用,继续抽象没有当前需要,bounded refactoring 判为 unnecessary。批准与实际合并权限、merge readiness 分开。
English verdict: APPROVE at a187819; no blocking finding; both new native cases and focused repository validation passed.
Short native context readers can return their full stdout before the shell process exits. When later polling exposes only the tail to
PostToolUse, the model can have received a complete page while the native context journal still has a gap. The next guard safely falls back to full, adding avoidable reads.The shared English/Chinese context guide and heartbeat integration guide now recommend the normal foreground wait for these short readers, explain how to consume yielded chunks, and preserve the existing complete-hook-coverage and exact-capture recovery rules. The wait controls when a tool yields; it is not a process deadline or an added delay.
A new opt-in native test exercises the actual shell, polling and lifecycle hook boundary with deterministic local inference. A gate keeps the yielding process alive until the provider observes its page. The test independently checks the complete model-input page and the hook-visible page, permits a baseline only when the latter is complete, and retains a foreground positive control. Future hosts that provide complete accumulated hook output remain accepted.
Validation:
This proposal changes integration guidance and synthetic native validation. The runtime codec, default setting, hook trust, admission and settlement semantics retain their existing behavior. Loopback inference uses an isolated native home and synthetic captures; no account, live Goal or benchmark job is needed. These checks qualify the transport boundary, not model comprehension, task gains or fee savings. Independent review and remote CI remain pending.