Skip to content

Avoid redundant Turn reads for dense Chat return history - #8573

Merged
huangruiteng merged 1 commit into
mainfrom
codex/avoid-redundant-history-turn-reads-20261111
Nov 11, 2026
Merged

huangruiteng merged 1 commit into
mainfrom
codex/avoid-redundant-history-turn-reads-20261111

Conversation

@loopx-agent

Copy link
Copy Markdown
Collaborator

Resuming a long Chat conversation still verifies the delivery state of the visible history. When that history contains many returns, the reader can spend time opening each original Turn for a route hint before it scans the route directory. Use a single bounded route scan when it is no larger than the estimated Turn and route lookups. Smaller and sparse reads still use the original Turn hints, and all paths verify the exact Chat host, Session, result and current delivery state.

On a matched local replay of a 3,136-row history, the median unchanged resume improved from 418 ms to 356 ms and a 12-row suffix read from 393 ms to 343 ms, with the same visible prefix proof and suffix. The regression test verifies that a different source host stays excluded and a changed delivery state is read again. The focused suites passed 169 tests, and standard premerge checks passed.

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 family, OpenAI, self_reported

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

Reviewed exact head: 8d6a388

动机 / Motivation

在 App 打开并续读长会话的用户。已显示的历史包含数百条交办回传,随后查续读是否有新消息。续读完整可见前缀时,会先打开很多原 Turn 找路由,未定位完再扫描路由目录。匹配的本地 3,136 条历史中,空续读中位数 418→356 ms,12 条续读 393→343 ms;原前缀证明和补出的正文一致。不改变初次分页、正文、授权或 Bot 的发送和执行。测量使用同一隔离历史副本;生产安装和不同历史形状的延迟尚待观测。

改动思路 / Approach

长历史的回传足够密集时,直接有界枚举现有路由;其余读取保留原 Turn 提示和后备扫描。Chat Session/Turn 持有正文,既有 roundtrips 和原结果回执持有路由与当前回传状态。已绑定原 Chat 会话的回传状态读取。枚举只改变候选文件的查找顺序,原会话、来源宿主和单条结果仍由现有读取校验。

具体改动 / Changes

  • C1 减少长历史重复读取。loopx/capabilities/manager_context/roundtrip.py:338 用有界目录枚举判断是否直接读取路由;目录过大或无法枚举时,沿用原 Turn 提示。
  • C2 保持原结果和状态的读回。tests/test_manager_context_roundtrip.py:1475 核对另一来源宿主的路由仍被排除,并确认状态修改后会重新读取;tests/test_manager_context_roundtrip.py:1511 核对窄页只读其结果。原会话契约

对主干的风险 / Risks

最重要的风险是扩大来源范围、漏掉合法旧路由或复用过期状态。候选只换文件定位方式,保留现有来源检查、即时读取和窄页后备路径。基线回归捕获了 202 次多余的 Turn 读取,候选 169 项测试和标准预检通过。需要补读时,仍重新核对前缀的每条状态;另一宿主的记录不会加入原对话。

我的整体评价 / Verdict

优化与瓶颈吻合,已在相同副本上验证新旧读回一致。当前只确认所测文件后端,独立评审和生产验收仍是交付门槛。本评审由作者完成,结论仅覆盖该提交的历史读取路径。

English verdict: APPROVE

@huangruiteng
huangruiteng merged commit bcf1b63 into main Nov 11, 2026
27 of 41 checks passed
@huangruiteng
huangruiteng deleted the codex/avoid-redundant-history-turn-reads-20261111 branch November 11, 2026 07:34
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