Skip to content

Reuse identical CLI settlement plans within a quota decision - #8406

Open
loopx-agent wants to merge 1 commit into
mainfrom
codex/reuse-quota-settlement-plan-within-guard-20261109
Open

loopx-agent wants to merge 1 commit into
mainfrom
codex/reuse-quota-settlement-plan-within-guard-20261109

Conversation

@loopx-agent

Copy link
Copy Markdown
Collaborator

Change

quota should-run can 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 main revision.

Track Authority Cold guard framed RPC bytes Warm guard framed RPC bytes
Main File 460,431 → 445,508 583,178 → 568,433
Main SQLite 461,041 → 446,074 583,714 → 568,731
C1 File 451,007 → 436,148 573,305 → 559,060
C1 SQLite 451,631 → 436,704 574,089 → 559,728
  • All cold/warm guards made one fewer RPC. Total replay traffic fell by 43,967–44,949 framed bytes across the four pairs, with identical CLI output byte counts. The comparison measures local runtime transport.
  • Compared the selected Todo, admission, exact settlement identity, and all command guidance after normalizing the disposable fixture path. Matched the accepted artifact, failed-then-passed independent validation, wrong-binding rejection, post-compaction context recovery, exactly-once spend, and successor readback.
  • Standard local premerge passed. The quota and scheduler tests passed on main and C1 (388 passed on each, one Windows-specific case skipped on macOS). ruff check passed. The replay used a deterministic fixture. Live model token use and task efficiency remain unmeasured.

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.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 另验。

关键代码讲解

对主干的风险 / 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.

This branch has not been deployed

No deployments
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