Repository navigation
Reuse identical CLI settlement plans within a quota decision - #8406
loopx-agent wants to merge 1 commit into
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: model_agent, gpt-6.1-sol, OpenAI, runtime_reported, reasoning_effort=max
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
同一次 quota guard 会两次渲染输入相同的 CLI 结算计划。对照在 File 和 SQLite 上各跑两个连续 Turn,实际执行 guard、结算和回执读回。四次 guard 均少一次 TypeScript RPC,计划、通知结论和最终扣额一致。这是隔离的真实 CLI 和 TypeScript runtime,使用合成 Todo 与本地权威库。未测真实模型用量或长期任务收益。
改动思路 / Approach
保留原 interaction contract 的两次投影,只复用纯结算计划渲染。作用域限定在一次 quota decision,完整请求变化时重新渲染。缓存用实际 RPC 序列化字节作键,每个调用者拿独立副本;用户通知 cooldown 后仍重算当前 contract。
具体改动 / Changes
评审 0813bdb,基线 71190b6,3 个文件,+77/−4。现有 Turn 契约 保留准入、停止、结算身份与命令。reuse-identical-plan、distinct-inputs-and-copy、original-turn-parity 已验证;production-efficiency 另验。
关键代码讲解
- quota decision 在初次和 cooldown 后投影外建立作用域,退出时恢复外层作用域。
- 缓存与副本 只对完整相同请求复用,TypeScript renderer 仍生成原计划。
对主干的风险 / Risks
最大风险是把前一 Turn 或不同命令权限带到当前计划。File/SQLite 实际 CLI 每次 guard 的渲染调用为 2→1,少传 15,693–15,927 字节;基线与候选逐轮给出相同的 Todo、Turn、通知、完整计划和输出长度。第二轮加入 capability,只有该轮命令带此参数;两轮各扣一次。修改返回副本和同一作用域内输入不同的反例也通过。257 项相关测试通过、1 个 Windows 专项跳过,标准预合并 6 项直接和 13 项自动检查通过。
我的整体评价 / Verdict
认可当前提交。省掉的是一次重复的本地渲染,当前决策仍重新投影。准入、通知和写回顺序都能从最终输出读回,每个调用者仍拿独立副本。未验证真实模型成本变化。
English verdict: APPROVE. Reusing the identical pure CLI rendering saves one RPC per quota decision while preserving distinct inputs, mutation isolation, and original-Turn settlement.
Change
quota should-runcan render CLI settlement guidance during the initial interaction projection and again after notification cooldown. For an identical TypeScript request, reuse that pure rendering within the same quota decision. Recompute the interaction contract after cooldown, and render a fresh plan if any request field changes. There is no cache across decisions.Validation
Matched the real original-quota CLI over two Turns in one synthetic session, with the same progressive context delivery, 12 KB reader page budget, Todo, and independent validator. Main used the built wheel. The C1 control and treatment included the same
mainrevision.ruff checkpassed. The replay used a deterministic fixture. Live model token use and task efficiency remain unmeasured.