Repository navigation
perf(quota): share repeated evidence history read routes - #7165
Conversation
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
left a comment
There was a problem hiding this comment.
Reviewer: model_agent; gpt-6-astra; OpenAI; runtime_reported; reasoning_effort=xhigh
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机
普通 quota 和 handoff 的重规划调用者会收到多条历史证据,每条重复相同的补读命令。
此前每行重复 Goal、Agent 和路径参数;现在多行共用一次命令模板,选择行后仍能直接补读该条完整证据。
已验证展开后的命令、证据内容、顺序、覆盖和错误语义一致;确定性收益限于减少重复路由文本。
不改变证据选择、强制阅读、评测机会或写权限,不引入跨轮缓存,也不把字节减少视为模型效果提升。
模型对模板的采用和完整输入、补读、时间及任务收益仍需集成实验。
改动思路
共同路由可由已有 Goal、Agent 和命令前缀直接推导,放在现有 TypeScript 投影中即可,无需第二个状态或决策所有者。
本 PR 只合并同一响应内的重复补读路由;跨轮子树缓存与模型效果验证留在各自已有工作中。
入口仍是普通 quota 或完整 handoff,Python 仅传输已有历史,TypeScript 选择和投影证据,history CLI 解析具体引用。相比直接删掉命令,这个方案保留了按需访问;相比跨轮差分,它不依赖上轮缓存。没有新增操作、权限确认或强制阅读步骤。代价是调用者要替换一次明确的占位符,因此不能凭字节节省宣称模型一定更高效。
具体改动
关键代码讲解
projectReplanContext(loopx/control_plane/work_items/replan_context.ts:514):先按原规则选择和生成完整证据,再在有 Agent 且实际展示多行时共用命令路由;模板参与 context identity。空结果、单行、无 Agent 以及前缀含字面占位符的情况保留既有形式,遗漏证据的补读入口没有变化。validateReplanContext(同文件425行):历史逐行格式继续可读;新字段出现时验证非空、恰好一个占位符和完整末尾引用参数。该校验没有授予执行权,也不替代真正 history 的 Goal/Agent 范围校验。test_quota_shared_evidence_command_reads_exact_history_and_preserves_scope经真实 File/SQLite quota 和 history 路径验证回读,原有长历史测试改为展开模板。独立复核另外用同一31条合成历史比较主干与本提交,逐条检查展示的24条补读、完整尾部和只读性,而非只检查字段存在。
规范依据:docs/reference/protocols/agent-scoped-evidence-ledger-v0.md,修订 035a077767d1e9fb9b321e35181ff9ffd81f00ef,按变更前的 Acceptance 判断。本次布局调整依据已接受的无损精简方向,未以修改后的文档自证语义。
验收映射:可读证据、确定性选择、精确补读、显式错误、阅读不记进展、合成验证 均通过当前投影、真实回读、反例及未改语义写入边界核查;模型效果边界明确保留,确定性测试不等于长程效果提升。六个文件为16行生产增量、现有测试扩展和协议说明,没有新服务或状态存储。
对主干的风险
主要风险是模板展开后错误地丢失范围、选择另一个记录,或旧上下文不能再读取。独立基线/首提交16d521de各完成 File、SQLite 两个真实路径,每个路径24次精确补读;错误 Agent、删去 Agent 参数以及删除合成索引后的旧引用均显式失败。完整证据和完整错误负载在限定根路径及派生context identity归一化后保持一致。27项独立 TypeScript 测试通过,涵盖旧格式、非法模板、字面占位符、单行和无 Agent;最终head只追加既有CLI预算测试的模板展开断言,生产文件及上述测试的源保持不变,原始回读证据明确沿用16d521de而不冒充最终head重跑。独立运行最终head整份CLI预算文件得到38通过、1项native temp无法容纳depth-12布局的既有跳过;该布局条件在基线同现且未被本补丁修改。另保留作者当前提交89项TS、43项Python和typecheck证据,不把它们标成我的独立运行。
语义与 CI 对齐
不查询或等待远端CI。作者标准premerge直接检查通过,所选检查16/17通过;唯一失败是 goal_boundary Python读取模块32超过预算30。我在固定主干和精确head用相同命令再次得到完全相同的失败输出;相关Python读取模块与扫描器不在此补丁中。它属于既有无关失败,保留记录及独立合并资格限制,不提高预算或称全绿。没有新枚举;沿用已有证据契约。未改PG存储/权限路径,当前真实验证覆盖File/SQLite;模型采用与总成本仍未测量。
我的整体评价
精确提交 689b12c2dbb61950f66b715ed65322a568fb5a99 的这项增量可以批准:它在已有所有者中可逆地减少重复路由,完整证据、可选阅读和后续恢复路径保留。长程继续工作的契约与用户操作体验判断为 preserved,不能据此判断新实验的分数会更好。共同路由可由已有 Goal、Agent 和命令前缀直接推导,放在现有 TypeScript 投影中即可,无需第二个状态或决策所有者。本 PR 只合并同一响应内的重复补读路由;跨轮子树缓存与模型效果验证留在各自已有工作中。
本 PR 修改 quota JSON 与协议说明;handoff 文本仍读取同一 summary,没有渲染界面变化。模型实际选择并展开模板的采用情况尚未验证。
这里是评审批准,不是main合并授权、全套检查全绿或集成实验已启动。独立实验仍需最终源版本、接收端和资源准入。
English verdict: APPROVE — 689b12c2dbb61950f66b715ed65322a568fb5a99. Independent base/head File and SQLite quota-to-history comparisons preserve complete evidence, exact scoped reads and failure behavior after documented route expansion. 27 focused TS tests passed. The identical pre-existing 32-versus-30 vocabulary ratchet remains a separate validation/merge hold. Live model adoption, total cost and benchmark gains are unverified.
Repeated history-read commands inflate replan context in ordinary quota responses: every visible evidence row repeats the same registry, runtime, Goal and Agent route. Multi-row scoped contexts now carry one
evidence_read_action_template; each row retains its content-bound reference and complete evidence. The Agent substitutes that reference to execute the existing history command, with no additional lookup.This extends the existing TypeScript replan-context projection consumed by quota and Turn callers. It preserves evidence ordering, coverage, source selection, required reads and authority. Single-row contexts retain their executable command; historical per-row contexts remain valid, and routes containing the placeholder literally retain per-row commands. The shared route participates in context identity. This changes the default multi-row presentation; it introduces no cross-turn baseline or incremental-context protocol.
Validation for
689b12c2dbb61950f66b715ed65322a568fb5a99(runtime unchanged from16d521de49bc8867d84599fcb41a731c38dc3a10), based on main035a077767d1e9fb9b321e35181ff9ffd81f00ef:quota should-runfollowed by the emitted history route, including unavailable evidence, wrong-Agent rejection and read-only behavior.goal_boundaryin 32 Python modules against a budget of 30; the same failure reproduces on the unmodified target main. This remains a validation hold, not a pass or merge authorization.An offline, lossless projection comparison over 31 saved solver decisions changes five packets, saving 24,215 serialized bytes across the set (about 1.0%; up to 6,885 bytes in one packet). This is a bounded reduction in repeated routing text, not measured model-token, task-outcome or wall-time improvement. Integrated live evaluation remains separate.
Placement and scope: an optional presentation field in the existing evidence-context contract; no new semantic vocabulary, capability, provider, state writer, frontend operation or Python decision owner. The adjacent reversible cleanup is route sharing itself. Required context and broader quota/Turn convergence remain unchanged.