Repository navigation
fix: preserve raw quota decisions for machine consumers - #7493
Conversation
Signed-off-by: huangruiteng <huangrt01@163.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
动机 / Motivation
使用 MCP 完成任务、或通过 Claude 状态栏查看当前工作的用户会遇到这个问题。
机器差分设置开启时,旧版 MCP 把用于展示的分页封装当成原始 quota 决策,完成流程因此在 guard 阶段停止;Claude 详情也可能报不支持的原生声明。新版本仅在这些内部子进程中关闭展示封装,继续读取原来的工作身份和准入决定。
独立实测显示,新 head 能完成原任务并重放为同一结果,额度只记一次;真实拒绝仍不完成或扣额。
本次范围是内部 subprocess transport,不修改机器偏好、交互 Agent 的差分设置、任务准入或 typed settlement owner。
改动思路 / Approach
这里应复用现有 LOOPX_CONTEXT_DELIVERY=off,使机器消费者明确读取原始决策,而不是再给 MCP 写一套分页恢复或准入判断。run_cli 为本次 child process 复制环境,当前参数和旧版 parser fallback 使用同一份环境;三个 Claude 入口在各自独立安装的脚本内采用同一已有约定。机器配置、parent environment、registry/Goal/Agent/Turn 和任务决策仍归原 owner。
结构判断:保留这一 transport 边界。共享准入和结算不变量仍由既有 TypeScript owner 执行,Python 只负责 subprocess IO;当前 PR 仅修四处机器调用方及相应文档、回归。为了去掉几行重复环境设置而新增跨安装目录 helper,会引入新的部署耦合,没有必要。本次有用的改进已经到达完成和重放消费者,但必需的 diff 卫生检查还需一行格式修复。
具体改动 / Changes
依据 docs/reference/required-work-context.md#machine-default,固定规范 revision a704725d6734b618f267568071960760c6620687。machine-default:implemented,已有显式环境 off 覆盖机器继承,saved setting 仍保持;opt-in-native-reuse:implemented,交互差分及原有恢复/准入 owner 保留。新增说明是这些既有边界对机器消费者的具体化,不以新文档反证旧规范。
关键代码讲解
GoalModeMCPControlPlane.run_cli在执行及 legacy retry 时传入 child 环境;没有添加旧 CLI 不认识的新 argv。goal_policy.should_run同样固定 transport,继续只接受布尔should_run,缺失、错误及不可用仍 fail closed。goalmode_cmd.goal_detail与goal_status.main修复两个实际状态读取入口;显示和错误处理仍用原实现。
验证:相关 suite PASS 92,SKIP 5;五项跳过需要显式 native Codex worker,没有用它们支持当前 transport 结论。独立同输入 base/head 对照复现旧版详情报错、当前/legacy MCP 及 completion guard 返回封装;head 均返回原始决策。额外两条实际 SSH MCP 完成/终态路径在 base 的 guard 失败,在 head 完成、读回并重放一次,机器配置不变。关闭态 base/head 与 head 的开关两态,完整 packet 经过明确的临时来源、生成 identity 和观测时钟归一后相同,未删诊断、指令或权限字段。
对主干的风险 / Risks
最危险的反方向是为了恢复完成而绕过真实拒绝。本次实际缺失 adapter 状态的反例仍在 guard 停止,源字节不变、完成未发生、spend 为零;scope 选择和原型声明不授予额外执行权。内部 presentation off 没有改写用户开关,也没有改变任意其他 Goal 的配置。Ruff 和标准 premerge 的 9 catalog、8 risk、1 boundary 检查均通过;没有查询 CI。
[P3] 删除新测试文件的末尾空行。 test_machine_guard_context_contract.py:153 使必需的 git diff --check 返回 2,报告 new blank line at EOF。这是本次新增文件引入的格式失败,不是原始 quota 决策的行为缺陷。最小修复只删除最后的空白行,保留正常末尾换行,再运行 git diff --check a704725d6734b618f267568071960760c6620687...HEAD 和受影响检查。其余 5 项 direct checks 通过;不应把这一失败记成全套通过。
我的整体评价 / Verdict
这项修复能解决真实消费者的阻塞,机制和改动范围相称。long_horizon 与 user_experience 的源码路径均改善:任务可以完成并继续,状态可读,拒绝仍可信,用户无需重复配置或确认。它没有渲染 UI 变更,因此 visual review 不适用;原生安装和长期模型收益未由本次资格证明。复用了既有 vocabulary 和 transport override,没有新增状态或 authority owner。
当前结论为 REQUEST_CHANGES,仅因上述新增文件的必需卫生检查尚未通过;行为验证结论保留。修复格式后在新 head 核对 diff、受影响证据和当前检查即可,不要求无关重构或付费模型实验。
English verdict: REQUEST_CHANGES d7b1868c97a0aacbcf721e57c6f73b453f2759fb: raw-decision transport, completion/replay and denial are verified; remove the new EOF blank line so the required diff check passes.
Machine-level differential context can make machine quota consumers receive a native presentation envelope instead of the raw decision they parse. With the setting enabled, Claude status reads can also fail because they do not declare a supported native Codex run mode. This can hide status or block otherwise admitted work.
Pin
LOOPX_CONTEXT_DELIVERY=offonly in the MCP CLI transport and Claude tool gate/status subprocesses, including legacy retries. The existing transport override preserves older CLI parser compatibility, exact registry/work identity, and fail-closed quota decisions. Interactive differential context and the saved machine preference remain unchanged. The typed Todo completion decision owner is unchanged.Validation:
Scope: Python subprocess transport and bilingual reference clarification; no new decision owner or configuration setting. This is a proposed source fix; deployment and maintainer review remain separate.