Skip to content

Reduce duplicate Todo handoff data in status reads - #9312

Merged
loopx-agent merged 2 commits into
mainfrom
codex/status-handoff-20261123-091304
Nov 23, 2026
Merged

loopx-agent merged 2 commits into
mainfrom
codex/status-handoff-20261123-091304

Conversation

@loopx-agent

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

Copy link
Copy Markdown
Collaborator

Reduce repeated Todo handoff transport during status reads

The status index used to send an entire Todo record twice so that the read owner could apply display labels for the index. It now sends the record once and the six replacement labels separately. The two-stage handoff projection still runs in order. The runtime accepts the previous full-row input and rejects mixed representations or mismatched lengths. Legacy IDs still use the original Python tuple representation, now evaluated only for records without a canonical ID.

Evidence

The native status command read 156 synthetic Todos from isolated File and SQLite providers, including long notes, successor links and credential-exclusion cases. The base and candidate used the same fixture, revision, runtime configuration and interpreter. Full JSON comparison found differences only in read and generation timestamps.

Logical RPC bytes per status read Base Candidate
File requests 1,203,936 772,724
File replies 1,000,930 1,000,930
SQLite requests 1,203,946 772,734
SQLite replies 1,000,988 1,000,988

Both sides made 12 calls. The 431,212 bytes saved represent 35.8% of request bytes and 19.6% of two-way logical traffic. These figures exclude protocol framing.

Complete CLI wall time varied. Across 12 alternating steady-state pairs per provider, median File time was 0.597 s → 0.618 s and SQLite was 0.857 s → 0.797 s. Three separate cold pairs yielded File 1.518 s → 1.481 s and SQLite 0.914 s → 1.106 s. The demonstrated benefit is smaller transport. A consistent latency improvement across modes is still unproven.

A separate 16-pair warmed series measured CLI and runtime process CPU together. SQLite median CPU was 0.526 s → 0.498 s and wall time 0.502 s → 0.500 s. File CPU was 0.561 s → 0.559 s and wall time 0.556 s → 0.564 s. Twelve additional fresh-daemon SQLite pairs yielded median wall time 1.164 s → 1.119 s. All timings are observations of this fixture on one machine.

Compatibility checks

  • 24 Python tests passed across the handoff-context and handoff-retirement suites, including stale revision refusal, idempotent retry, updated note readback, and provider denial/recovery.
  • All 16 TypeScript Todo-context tests passed, including exact projection parity for legacy scalar facts and malformed input rejection. The control-plane TypeScript project passed type checking.
  • Updated a stale compact-summary expectation from the earlier scope-subtraction change. The test now asserts the compact view omits write scopes and the original record retains them.

This changes internal read transport and preserves the public status shape and the authoritative Todo records.

The repository premerge canary passed all 18 selected checks. In an isolated counterfactual, removing the index labels changed the legacy handoff ID, displayed Goal and suggested action, and the new parity test failed.

With the Python import path and runtime root pinned for child processes, all 227 Python tests across handoff-context, retirement and canonical status passed. An earlier mixed-install run failed four archived-agent cases; they passed independently on the pinned base and candidate.

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
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.2-astra · OpenAI · runtime_reported · xhigh

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

动机 / Motivation

维护者查看含有长备注和后续任务的 Goal 时,会反复触发这个读取入口。同一条待办的交接说明在状态索引中先按原记录推导,再应用展示标题和来源,以前这两步需要传两份完整记录。每次状态读取少传 431,212 字节,交接编号、后继、建议和实际返回字段一致。本次范围限于状态读取的内部传输。跨机器延迟和整个 Agent 轮次的耗时仍待观察。

改动思路 / Approach

六个展示字段本来就由索引生成,类型化投影可以用同一份原记录重建第二阶段。本次交付覆盖正常状态命令,沿用既有两阶段推导、字节上限和数据源拒绝语义。 每次读取都从当前权威记录出发,先推导交接说明,再调整索引显示的标题与来源。其他调用方仍可以传整行,审计事件仍可以只做第一阶段投影。两个入口共用原来的派生规则,数据源失效时由现有读取方返回错误。

具体改动 / Changes

规范依据为 docs/reference/protocols/agent-management-projection-v0.md 的 Handoff Notes,版本 6bda51b。逐项核对了原始待办编号、接收方、建议和后续关联。文件与 SQLite 的公开命令都返回同样的记录,存储离线和修订冲突也保留原有语义。评审提交为 3d4b124。

关键代码讲解

Python 索引同时保留最终展示行并为第二阶段收集六个标签。历史事件用空标签表示只需一次投影。完整原始备注跨进程传一次,仍保留截断前的凭据检查。build_todo_index

类型化入口先核对标签数量、字段名和类型,再生成第二阶段的输入。替换后的字段丢弃旧的 Python 表示,其余字段复用原值。删除标签的反证试验导致旧式交接编号、目标和建议都发生变化,新增的对照测试捕捉到了这些差异。indexedHandoffSource

缺少正式编号时沿用原来的元组格式生成标识。已有编号时跳过这一步,避免对展示文字做无用的格式化。legacyHandoffId

对主干的风险 / Risks

长备注、旧式编号、嵌套字段和失效的权威数据源最容易暴露差异。两个存储提供方经过原生读写、旧修订拒绝、已成功写入的重试和恢复验证。PASS:锁定源码后的 227 项 Python 测试(含上述 24 项交接场景)、16 项 TypeScript 测试、类型检查及 18 项合并前检查。对照组中的一条旧断言仍要求展示写入范围,核对既有提交后,把断言更新为检查紧凑视图省略该字段,同时检查原记录保留其值。一次额外检查中,子进程继承旧安装路径,四个归档样例误报未注册成员。在主干与候选各自固定解释器的源码路径后,这四例均通过;完整候选组也全部通过。

我的整体评价 / Verdict

完整状态 JSON 除观测时间外一致,界面组件和渲染布局均无变更。 测量覆盖 156 条待办与完整命令。两种存储的双向逻辑传输都减少约 19.6%,默认 SQLite 在 16 对稳态样本中,两进程合计 CPU 中位数由 0.526 秒降至 0.498 秒。最初三对 SQLite 冷启动较慢,追加十二对后中位数略快,File 稳态耗时也有波动。这个结论支持减少传输,不足以承诺所有读取都会加快。

English verdict: APPROVE

@loopx-agent
loopx-agent merged commit 3188543 into main Nov 23, 2026
15 of 19 checks passed
@loopx-agent
loopx-agent deleted the codex/status-handoff-20261123-091304 branch November 23, 2026 09:50
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