Repository navigation
perf(context): avoid replaying unchanged acceptance evidence - #7447
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: actor_kind=model_agent; model=gpt-6.1-sol; provider=OpenAI; declaration_source=runtime_reported; reasoning_effort=max.
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机
开启原生差分上下文的 Agent,在后续回合读取累计 Goal 验收证据时会遇到这个问题。
当验收结论更新但证据正文未变时,旧版仍发送相同的长说明与证据引用;本次改动复用这些原文,同时逐轮发送当前结论和控制字段。
已验证的结果是减少重复传输,并精确重建当前完整上下文,包括新增反证、删除、重排和最新状态。
本次不声明模型记忆、计费 token、整轮延迟或长程任务效果已经改善,也不改变准入、配额和执行权限。
真实模型成本、上下文保留与后续任务收益仍需在原有宿主资格和可比测量中独立验证。
改动思路
静态证据的精确复用应留在现有 TypeScript codec;实时结论仍由原验收 owner 提供,不能另造验收缓存或决策规则。
本 PR 仅扩展现有 opt-in codec 的可复用证据路径,保留当前控制、摘要校验和同一 capture 的恢复。
入口仍是 quota/Turn 的既有上下文投递。canonical outcome owner 产生当前事实,splitContext 只登记可以精确复用的证据,changeTree 构造差分,恢复端再对照当前 capture 的完整 digest。证据内容不赋予验收或执行权限。没有新增配置、存储或第二个决策 owner。
在本 head 上,三类输入的边界如下;表格解释源代码行为,验证结果见后文。
| 触发输入 | 处理与可观察结果 |
|---|---|
| 已完整读取且未变化的证据说明 | 从不可变 baseline 精确复用,原有义务继续有效 |
| 新结论、状态、未知控制或证据变化 | 当前输入完整携带;变化、删除与重排精确重建 |
| baseline 丢失、epoch 改变或 patch 损坏 | 恢复同一当前 capture,不重新准入或扣配额 |
具体改动
共 4 个文件,生产代码 +20/-2、文档 +11、测试 +93。测试覆盖共享 codec 和真实 File/SQLite quota 来源,增加的不是输出快照或替代实现。
先于 diff 阅读的规范:docs/reference/required-work-context.md,固定修订 bee2f29b34f8f53a4dcdd31e1e00a5e2bc10a43a。下列标签用于本次条款映射,不冒充规范原有编号。
- CTX-EXACT:implemented。来源、证据、空值、删除和重排保持当前原文;三表面重建及反例通过。
- CTX-FRESH:implemented。status、planning_satisfied、conclusion、basis_current、independently_verified、revision 和未知控制仍逐轮为当前 literal。
- CTX-RECOVERY:implemented。丢失 baseline、错误 digest、不同 epoch、失败或不完整来源不借旧证据通过。
- MODEL-ADOPTION:deferred。真实模型保留、成本与后续任务收益继续沿原有宿主验收验证。
关键代码讲解
splitContext新增 sources.summary、agent_review.note 和全字符串 evidence_refs 的登记;requirementPath/identity 复用局部路径,其他字段仍留在 fresh。没有通过自然语言猜测哪些状态可省略。changeTree沿用精确结构差分;强制当前路径优先于相同字符串的 baseline 引用。数组索引指向不可变基线,重排不是实体合并。prepareContextDelivery先核验 scope、完整来源、连续性和重建结果,再比较大小;不可用基线走 full。restoreContextDelivery对当前 capture 重新计算期望 patch 和 digest;遗漏控制字段或错误引用都会恢复完整输入。
独立验证:PASS,26 项 TypeScript 测试;PASS,156 个 contract-derived 用例,覆盖三表面以及当前负结论、未知控制、改序、删证据、空数组、结构化非法 note、摘要损坏和基线丢失。真实 File/SQLite 新回归在 base 均 FAIL,在 head 均 PASS;base 的 26 项 TS 检查仅新增用例失败。
合成输入的 full 约 213 KB,delta 约 5.4 KB;这是该 fixture 的传输字节观察,不能推导真实 token、延迟或任务收益。
对主干的风险
最强反例是复用旧 note 时把新的 unmet 结论一起隐藏,或在数组重排后把另一条证据借到当前要求。本次逐字段断言当前状态,并将完整恢复结果与独立当前输入比较;失去基线、失败来源和未知字段也有反向检查。默认 off、cold full 与已有 CLI recovery 路径保持原来的义务、配额及权限含义。
宽范围 Python 检查结果为 168 passed、4 failed、44 skipped。4 个 FAIL 是既有 test_captured_context_reaches_actual_host_without_readmission 的 off/inline × File/SQLite 用例:DSH authority prompt 含 detail_ref,而断言要求不存在。对 immutable base 和本 head 用相同命令复验,均为 4 failed/2 passed,失败参数、断言和行号一致;相关 host adapter、prompt builder 和测试未被本 PR 改动。该失败没有被计为通过,后续恢复由原 host/readback owner 处理。
44 个 SKIP 来自未提供 LOOPX_NATIVE_CHECKPOINT_BIN 的可选原生 checkpoint 检查,因此本次不认证实际宿主的模型历史保留。标准 premerge 的 5 个 direct、14 个 selected 检查均 PASS,包括当前风险 smoke、语义词汇和公开边界检查。未查询、轮询或等待 GitHub CI。
语义与 CI 对齐
本 PR 复用现有 vocabulary 和 owner,没有新增 Enum/Literal/协议状态。原文义务经过精确重建保持 actor、条件、顺序、范围、证据来源和停止要求;默认 off 隔离与“是否应该启用”仍是不同判断。生产增量集中在已有 codec,当前不需要引入新的缓存抽象。
我的整体评价
未发现新增阻断 finding。结论为 APPROVE;交付判断是 justified_increment。long_horizon 与 user_experience 均为 preserved:重复回合中当前义务和恢复链路被保留,没有新增人工准备或确认轮次。减少传输重复的收益已验证,整体任务效果与真实成本仍保留上述资格边界。
已检查 context_delivery.ts、Python wrapper 和文档差分;没有改变渲染页面、布局或可见控件。
原生宿主的真实模型保留和成本不在此次静态页面审阅范围;没有新增 UI 需要截图。
局部 requirementPath/identity 收敛已应用;现有消费者和持久 capture 格式继续保留,兼容性判断为 retain。4 项既有失败仍影响全绿声明,不能由本次源代码批准自动关闭;merge readiness 和 maintainer merge authorization 也须分别满足。本评审固定 head cf66d260395b4c3a22e0ef8102d6aadd35c73335,发布前再次核对 head。
English verdict: APPROVE at cf66d26; no new blocking finding. Exact reconstruction and fresh controls pass; four pre-existing host failures and optional native checkpoint gaps remain disclosed.
Warm context delivery still repeated cumulative acceptance evidence even when the exact baseline already contained it. Reuse unchanged source summaries, review explanations and string evidence references through the existing shared quota/Turn codec. Changed or removed evidence still reconstructs the exact current capture.
Current requirement status, review conclusions, basis currency, independent verification, revisions and unknown fields remain literal on every input. Cold delivery, default-off behavior, failed/incomplete sources, lifecycle invalidation and digest-bound full recovery retain their existing semantics. No new setting, authority or protocol vocabulary is added.
Validation:
test_captured_context_reaches_actual_host_without_readmissionoff/inline cases fail on both base and head because the Host includesdetail_ref; those pre-existing failures are retained as failures.cf66d2603, including all four changed files. The same 26 codec tests also passed on Linux using the existing runtime dependency tree. Remote CI and independent review remain pending; no merge qualification is claimed.loopx checkstill reports unrelated unmigrated registered Goals; this is not reported as a passing full check.The adjacent refactor stays within the existing acceptance adapter: one requirement path/identity is reused for description and evidence handling. No new owner or backend state is introduced. Byte reduction is a transport result, not a claim of model adoption, fees or task effectiveness.