Skip to content

Retain verified context selections across native resume - #8559

Merged
huangruiteng merged 2 commits into
mainfrom
codex/native-resume-selected-context-20261111
Nov 11, 2026
Merged

huangruiteng merged 2 commits into
mainfrom
codex/native-resume-selected-context-20261111

Conversation

@loopx-agent

@loopx-agent loopx-agent commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Goal and delivered outcome

A complete progressive selection lost its observed section state on an ordinary Codex process resume when the session had only selected reads. This forced a second read of stable authoring material even when the native history still contained the exact selection.

The existing replay verifier now qualifies complete, literal one-page selections from the current captured source. The lifecycle owner carries forward only the corresponding verified section digests. It checks the current read scope and the replay source, including the original bytes and append-only history. A missing result, partial page, changed capture, or compaction returns to ordinary reading.

Intended base main.

Author declaration

  • Written by OpenAI Codex (model_agent).
  • Implemented against docs/reference/required-work-context.md at beff0f3e55.
Criterion Disposition Evidence
Reuse must follow an exact native replay with the current scope implemented codex_context_history.py and the native resume regression
Unavailable or changed read evidence must recover through the ordinary reader implemented Omitted output, partial page, changed source and compaction cases
Selection proof is separate from whole-input continuity implemented Native model input and session journal assertions

Scope and continuation

The change covers complete single-page selected outputs. It reuses the existing native transcript verifier and typed lifecycle owner. Multi-page and inherited selections use their existing recovery path. Production and benchmark adoption can be checked on their next authorized runtime update.

Validation

  • Tested revision 0f5615b24af8fbfe1f9b9e8d7924255603c9de89
  • Run state finished
  • Input classes synthetic, authorized_private_read_only
Check kind Result Public-safe evidence
regression_parity passed A real quota context-read and context-hook test fails on the baseline because the selection is discarded. The fix passes the pinned and direct reader forms plus the fallback cases.
real_entrypoint passed Two separate Codex 0.162.1 app-server processes with loopback inference delivered the same source selection and resumed the same session. The baseline clears the selection observation. The fix exposes the exact reused field in the subsequent model-visible page. The selection was 3,110 bytes.
integration passed Focused native lifecycle and observed authoring reader tests, 117 passed.
static passed Control-plane TypeScript type check, Git diff check and scoped LoopX public boundary check.
real_entrypoint passed Isolated Linux Codex 0.162.1 with the Code Mode sidecar: both app-server and CLI exec resume delivered the exact selected tool result to the model. On the unchanged base, resuming did not report the selected field as previously delivered. The fix reported it without establishing a whole-input baseline. With the same deterministic reader policy, CLI resume avoided rereading the 3,110-byte selection and took five model requests instead of six. Inference was loopback; this does not estimate token or score gains in a full trial.

Frontend / visual evidence

UI impact none.

Type of change

  • Bug fix
  • Test update

LoopX area

  • Control plane
  • Host or runtime integration

Shared-authority RFC fixture impact N/A.

Boundary checklist

  • Public-safe diff and validation summary.
  • Scoped to native context replay. Related complete-capture and fallback reader changes remain independent.
  • No paired RFC changed.
  • UI impact is marked above.
  • DCO sign-off on the commit.

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.

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

Reviewer: model_agent · gpt-6.1-sol · OpenAI · runtime_reported · max

评审提交:0f5615b24af8fbfe1f9b9e8d7924255603c9de89

动机 / Motivation

使用 Codex 接续同一会话的 Agent 已读过完整的 Vision 编写规则,下一轮还要按同样的规则结算。进程重启后,即使原生历史仍包含完整选段,主分支也会清除这次阅读记录。需要该规则时,Agent 要再读一次。新提交在原始捕获和完整历史都可核验时保留已读规则。两种工作目录的隔离复现都少一次读取,每次省去重读 3,110 字节选段。下一轮身份仍从本轮捕获读取。新提交在原始捕获和完整历史都可核验时保留已读规则。两种工作目录的隔离复现都少一次读取,每次省去重读 3,110 字节选段。下一轮身份仍从本轮捕获读取。原始捕获字节被改动,或旧历史缺少对应输出时,不能复用旧选段。两种情况都从当前捕获取回完整规则。使用公开 Codex 0.162.1 的真实 App Server、两个独立进程、隔离 SQLite 和确定性本地 Responses。实际用户会话、真实模型用量和完整任务成本仍待验证。

改动思路 / Approach

沿用原生历史读取与 TypeScript 生命周期。接续时逐个核对选段摘要,再决定哪些规则可复用。只覆盖当前捕获中一次完整选读。恢复原来源和完整输入的资格分别由已有路径验证。 钩子先按当前捕获校验完整选段,再保存对应的工具输出摘要。SessionStart 接续时复核原始 rollout、输入范围与对应输出。TypeScript 只保留能从这两处证据确认的规则。

具体改动 / Changes

关键代码讲解

按 docs/reference/required-work-context.md 对照 qualified-selection-replay、preserve-recovery、whole-input-continuity。基线规范

checkpoint_native_selection 记录同一来源的单页完整选读和工具输出。重启时 native_resume_sections 重新校验原文件、原捕获及保存的输出。生命周期只带回匹配的字段摘要。当前 Turn 的身份从新捕获读入,原选段不建立完整输入 checkpoint。 记录选读 接续检查 状态归约

对主干的风险 / Risks

用两个独立的原生进程完成相同的 SQLite 任务。原模型输入仍有完整选段时,主分支需要补读,候选能直接使用此前读过的规则。替换原捕获字节或删掉旧工具输出后,候选重新读取当前捕获并确认完整规则。partial 和 compaction 也在实际 CLI 钩子测试里拒绝复用。

语义与 CI 对齐

两组正例均少一次回环请求和一次 3,110 字节选读,首读正文大小相同。416 项源码测试、显式 off 对照、TypeScript、Ruff 和 standard canary 通过。公开 0.162.1 的两项既有完整捕获测试在两边都于冷态缺少 candidate,尚未进入 resume;另四项历史变更对照通过。Code Mode 在 CLI 的输出形态上验证。

我的整体评价 / Verdict

通过当前提交的独立评审。完整选段可在原生重启后复用,原来源失效时可重新选读。当前验证边界是公开 0.162.1 的本地隔离进程。已验证实际的 CLI 读取和重启后的输入。实际用户会话、真实模型用量和完整任务成本仍待验证。

English verdict: APPROVE. Verified literal selections survive real Codex 0.162.1 resume. Changed sources and lost outputs recover from the current capture.

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

@songoow songoow 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 Astra Pro · OpenAI · self_reported

评审提交:cf78b5b9eae1c1d5e1f17fd2e99cb85031a83792,本次 PR 基准 6d6439c0148c04c9f4c2dd71a74db151a9b33424。完整检查 7 个文件(+165/-12)、作者自评、既有原生回放契约和共享 reader/lifecycle 调用链。评审期间作者同步主干,旧 head 0f5615b2 的证据已单独保留;以下测试和对照均已在新 head 重新执行。

动机 / Motivation

使用原生分页历史恢复会话的 Agent,在暂停前已完整读取一个字面选段,也会失去这段读取记录。 原实现对没有完整输入候选的普通 resume 清空全部已读段落;候选把已经独立验证过的单页选择绑定到实际回放历史,仅在同一来源和读取范围仍成立时保留其段落摘要。 实际 CLI 与 Effect 对照中,完整内联或固定引用读的已读段落由恢复后的 0 变为 1;缺失输出、未读完、压缩和源文件损坏四种路径继续为 0。 本次不建立完整模型输入保留资格,不改变准入、扣额或原始捕获,也不把合成回放当作安装版 Codex 或真实模型采用证明。

改动思路 / Approach

复用既有物理历史快照、精确输出组和源文件核验,把回放事实交给现有 typed lifecycle 取交集,可以保留选段连续性而不另设完整输入 owner。 当前范围是同一读取作用域内、从当前捕获完整读出的单页字面选段;分段未完成或继承得到的选择仍走现有恢复路径。

实际链路是 quota context-read → 原生 PostToolUse → codex_context_hook → _verified_context_pages → TS lifecycle。Python 先核验原捕获、选择摘要和实际页字节,TS 产生已读段落后,新的 checkpoint 才记录回放所需事实。随后 SessionStart(source=resume) 优先走原完整输入核验;只有它不成立时才计算选段回放,传给同一个 lifecycle。下一次 progressive view 继续按既有当前源字段摘要决定是否复用,不会凭一个 session ID 就跳过义务。

具体改动 / Changes

关键代码讲解

  • checkpoint_native_selection 要求一组且仅一组已验证页面、offset=0、EOF、当前 source/scope/epoch,并要求这些段落已经存在于 reducer 的消费记录。含继承段落的结果不进入这条路径。读取锚点最多合并 32 次观察,失败时只失去可选恢复,不创建完整输入候选。
  • native_resume_sections 与 _matches 复用同一原生源的路径、inode/device、元数据、模型和权限检查,以及读取区间摘要、每个实际输出组与追加记录允许集。selected=True 省略的是“覆盖整份捕获”的要求,原文件摘要和全部已观察输出的精确匹配仍然执行。
  • typed lifecycle 的交集 只留下本次回放和旧 consumed_pointers 共同拥有且摘要相等的地址。结果为空或发生失效时清除私有锚点;这里始终移除完整输入 candidate,不把选段提升为 retained input。
  • hook 接线 在现有锁内处理观察和保存,实际读取与 scope 变化继续由原 owner 管理;选择核验标记 明确区分字面读取与继承,wrapper 只传递结构化事实。
  • 真实 CLI 回归 从同一原始捕获调用 reader,再由独立 CLI 子进程送入真实 hook 和 Effect reducer;覆盖内联、固定引用、父 Code Mode 输出后追加,以及四条拒绝复用路径。

契约映射依据 基准 required-work-context:qualified_replay implemented,仍核验原生实际回放来源与输出;literal_selected_scope implemented,仅保留相同来源和读取范围中的字面段落;fail_closed_recovery implemented,缺失、压缩、损坏和不完整读取不获得复用;whole_input_adoption out_of_scope,未新增完整模型输入证书或模型 ACK。

对主干的风险 / Risks

最强反例是回放只剩最后一个输出,或者页中混入继承段落,却被误认为模型仍有全部历史。这里 checkpoint 仅接纳独立验证的完整单页,恢复还要验证每个记录的输出组,并由 TS 与先前真实消费记录取交集。原完整输入恢复路径未放宽,选段路线不会建立 candidate/retained。旧 journal 没有新锚点时继续保守清除,正常读取仍可恢复;超过记录上限会缩小可复用集合,不扩大权威。

本轮独立脚本用同一新增回归 oracle,分别加载固定基准 beff0f3e55d1 和候选的全部生产代码及 CLI 子进程,共 12 臂:普通完整读和固定引用在恢复前都为 1,恢复后基准为 0、候选为 1;缺输出、partial、compacted、changed_source 均不保留。所有臂均没有完整输入 candidate/retained;未故意损坏的捕获摘要保持一致。这里的回放文件是合成且符合现有格式的原生历史,不能据此声称亲自跑过作者自评中的 Codex 双进程实验、真实模型采纳或长期 token 成本。

语义与 CI 对齐

PASS 新 head 的 resume/lifecycle Python 测试 276 项;PASS context delivery TS 35 项与 control-plane typecheck;PASS quick premerge 的 6 项直接检查、maintainability、全库语义扫描、quota-plan 和 public boundary。同步主干后的共享 reader/progressive 实现也由上述新运行覆盖,没有把旧 head 测试改标为新 head。

远端 build 红色,部分检查仍排队;目前没有足够证据给这个远端失败归因,也没有把本地通过当成远端 CI 已修复。合入仍应遵守仓库现有 CI 和分支保护。本 PR 没有修改渲染界面,视觉检查不适用。

我的整体评价 / Verdict

交付判断 goal_achieved:普通恢复可保留已经核验的单页字面读取。长程连续性为 improved,重复恢复的原因减少,同时完整输入边界保持;用户体验为 improved,有效已读信息不再被无条件丢弃。新增状态是有界、可丢弃的私有 IO 锚点,实际语义仍由原 typed reducer 决定,规模与缺口相称。

没有发现需要阻断该 SHA 的代码问题。保留的限制是实际安装版宿主与模型采用未由本轮独立重跑、远端 CI 失败原因未确认;这份批准不授权合并或替代现有门禁。

English verdict: APPROVE at cf78b5b9eae1c1d5e1f17fd2e99cb85031a83792. Retain only independently verified literal selections that are present in the qualified replay, intersected with the prior read state. Whole-input retention and installed-host/model adoption are not established by this review.

@huangruiteng
huangruiteng merged commit bccf40e into main Nov 11, 2026
29 of 46 checks passed
@huangruiteng
huangruiteng deleted the codex/native-resume-selected-context-20261111 branch November 11, 2026 10:51
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.

3 participants