Repository navigation
Reduce repeated Goal payloads during Turn admission - #9323
Conversation
Signed-off-by: LoopX Agent <[email protected]>
Signed-off-by: LoopX Agent <[email protected]>
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
使用 LoopX 启动新一轮工作的调用方,需要在读过当前目标和验收要求后才能继续。 大型 Goal 连续经过组合决策、附加上下文和准备读取。基线三次完整发送,候选在可大幅压缩时用更短的内部表示。 本地将重复的目标资料送入真实控制面,三个步骤共用的请求字节明显减少。原决定、附加证据和读取计划仍逐字一致。 评审目标是内部传输、完整来源和读取合同。线上延迟和模型费用此次未测。 部署后的时延与模型效益仍需独立观测。
改动思路 / Approach
准入的三道现有步骤都接收完整目标资料。有足够压缩收益时,请求改用现有压缩载体。接收端复原原字段后执行同一套签名和投影逻辑。
Python 传输层决定是否打包。TypeScript 在校验之前恢复原字段形状,签名和决策仍共用现有 owner。 变更限于三个调用的内部传输与原生读回测试,共用 codec 和持久捕获合同。
具体改动 / Changes
评审提交 5468e4e,基线 d33af49。五个文件,新增 100 行,删除 9 行。包括三处传输和测试,后续提交进一步收紧压缩阈值。 完整差异
按基线 d33af49 的公开契约核对。docs/reference/protocols/turn-envelope-v0.md
- Complete v1 Host entry 已实现。同一重复文本样例,三个 RPC 的请求字节合计从 554,291 降到 52,125。回复大小不变,组合决定、附加上下文和原生读取计划的序列化结果一致。
- Original digest-bound context recovery 已实现。高熵证据列表、1 MiB 以上输入仍走 inline,读回与基线一致。重复携带 inline 和 packed 数据或篡改原签名的输入被拒绝。
- Historical captures retain their original schema and signature 已实现。dense 和超 1 MiB 样例的基线与新头输出逐字一致。历史 session 路径和拒绝测试已运行。
关键代码讲解
- pack_turn_source。用原 16 KiB 到 1 MiB 限额及比较阈值判断是否值得发送。 loopx/control_plane/quota/turn_envelope.py
- _turn_envelope_result。为三条调用替换一个字段,保留数字词元与其他请求参数。 loopx/control_plane/quota/turn_envelope.py
- evaluateTurnEnvelope。先恢复请求字段,再调用现有签名、验证或投影。 loopx/control_plane/quota/turn_envelope.ts
- decodeTurnSource。对新增 context 参数复用同一解码器、输出上限与单一载体校验。 loopx/control_plane/quota/turn_envelope_codec.ts
对主干的风险 / Risks
同一重复文本样例,三个 RPC 的请求字节合计从 554,291 降到 52,125。回复大小不变,组合决定、附加上下文和原生读取计划的序列化结果一致。 高熵证据列表、1 MiB 以上输入仍走 inline,读回与基线一致。重复携带 inline 和 packed 数据或篡改原签名的输入被拒绝。 控制面 Python 三套 113 项通过,standard premerge 6 项直接检查与 16 项选中检查通过。基线的两项成功分支断言已漏列 session_plan,4 项拒绝分支通过。候选补上只含会话沿袭的 call 断言。
语义与 CI 对齐
原生选读继续依赖原 capture 和签名。发布只涉及现有 RPC 词汇。基线的 session_plan 调用数断言错误已在原源码复现,与此补丁引入压缩的路径不同。此次未查询远端 CI。
我的整体评价 / Verdict
批准该提交。重复文本的传输收益已在相同输入和相同原生入口测得。密集和超限来源保持原读回。生产延迟、实际费用与共享环境的效果仍待单独观测。 改动只在内部 TurnEnvelope 传输,未涉及渲染界面。
English verdict: APPROVE at 5468e4e. The existing bounded codec reduces repeated RPC transfers while preserving the Turn decision and native readback.
Outcome
Python sent much of the same Goal source to the TypeScript owner during composition, context attachment and native read preparation. Those three operations now use the existing bounded, lossless codec when its encoded form is less than one third of the inline size. The receiver restores the original shape before signing, validation and projection edits. The 16 KiB to 1 MiB source window, decompression limit, existing capability transport and stored capture format are preserved.
Whole-operation measurements
Compared isolated copies of the same package at
d33af49aaf, with the three production modules from5468e4ed9eoverlaid on the candidate. Each SQLite run read its selected requirements, then settled the original Turn and retried after losing its receipt. Each run recorded exactly one writeback and one spend.The internal transfer fell about 9.6% in all three pairs. Token estimates use o200k_base and include volatile receipt identifiers. Three additional warm pairs without the RPC probe had median summed CLI wall times of 4.93 s on base and 4.03 s on the candidate. These are local observations under variable machine load. Provider billing and deployed host latency remain unmeasured.
A fresh guided first-Goal preview produced identical 46,247-byte output with one RPC on both revisions.
Counterexamples and checks
A revert returns the three callers to inline transport. This change adds no stored schema or user-facing options.