Repository navigation
perf(cli): share selected agent collaboration dispatch - #7213
Conversation
Signed-off-by: aihop <4408344+hhyykk@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
APPROVE — 未发现当前 head 的阻断问题。 精确 head f057a3a8997b6e60928c760a9274b796c5fc6c20,完整基线 0c0d3dd31e865782f653ea3195ef36d8fac7b395;当前五文件全部重审,作者数据未直接当作本轮证据。
动机
通过 CLI 查看协作上下文、成员目录和本机能力观察的 Agent 与操作者。
原来三个命令先装载完整命令行再进入原 handler;本次只注册所选命令,并让完整入口也使用同一 dispatcher,保持原有读写与诊断。
真实 File/SQLite 临时环境中的完整结果和 RPC 顺序保持;240个配对样本显示三个命令 p95 均降低,现有 Todo、注册表和状态文件不变,未发现当前 head 的阻断问题。
本次不新增命令、权限或数据缓存,不启动 peer 或模型,不认证完整原生 CLI、发行包、跨平台性能或长期总体收益。
既有 canonical-authority fixture 的8项失败保留;完整原生 CLI、实际 peer/模型采用与完整长期成本仍按既有验收推进。
改动思路
复用原 selected parser、注册函数、handler 和 request scope,删掉三个完整 CLI 的重复分支;减少入口装载与可执行身份解析成本,避免新增语义 owner、桥操作或权威数据缓存。
本 PR 完成三个现有协作命令的调用者接入;新主体和关闭策略仍走原所有者,peer 执行、完整原生 CLI 和 provider 资格保持独立。
保留三个独立后置分支会继续付完整装载成本,并留下两个 dispatch 入口要同步维护;新增另一套 handler 或缓存状态则扩大权威面。当前复用已存在的 parser/dispatcher 生命周期,既删除重复分支,也保留原命令与原 source/能力观察的实时读取。用户不需要换命令或重新输入已知配置。
恢复方案的分阶段整体验收不作为此局部内部修复的附加门。本轮仍核普通消费者、失败/恢复和结果读回,不继承历史结论,也不以测试或记录数量替代长期收益。
具体改动
修改前 docs/architecture/rfcs/typescript-control-plane-migration-v0.md,固定 revision 0c0d3dd31e865782f653ea3195ef36d8fac7b395 的 2.8、Stage 3 和 Payoff-phase PR contract 是本轮依据:对完整命令比较局部性、RPC、原状态与成本,不以移动目录、类型数或新 checkpoint 自证。英中新增 ledger 均明确只完成三命令 caller adoption,不宣布全 CLI、模型或 provider 完成,双语意义相符。
关键代码讲解
_build_selected_parser调用原register_agent_*。三个命令沿原 options/required/choices/no-abbreviation 规则解析;拒绝时回到完整 parser 出原诊断。75项入口测试还检查了 help、未知/缺失参数、错误phase、缩写及双入口真实读写。_dispatch_common_command选择并调用原三 handler,沿原 runtime-root、formatter 和 registry 路由。cli.py后面的三份分支删除,完整入口也消费此 owner,没有增加业务实现或桥操作。dispatch_common_command使用已有 executable-revision request scope;它固定一次命令所用可执行身份,不缓存 Goal/Todo/能力事实。本轮实际新注册成员、可变 claim、移除旧显示和关闭策略的完整调用结果均核对,不只从函数名字判断“实时”。
产品 +29/-24,净+5,测试57行和双语文档20行另计;没有新模块、依赖、语义 owner、bridge operation 或数据缓存。原注册/handler仍是下一条规则变更的落点,完整 parser 是现有兼容入口,退出条件仍为剩余调用者迁移;不为此单一切片强迫完成原生 CLI 重写。与 #7202 的其它 selected commands 责任不同,未重复计算它的收益。
对主干的风险
本轮用实际 canonical File 与 SQLite 的合成 Goal/1Todo/1registered peer、开启策略,执行完整三命令。完整JSON和错误/状态保持,唯一归一化是已验证带时区的 peer_agent_directory_v0.collected_at 观察时钟;业务 RPC 顺序逐项一致,数量仍 1 / 17 / 2。75项入口测试全部通过;其余所选 companion 为39通过、8失败。合并观察为head 114 passed / 8 failed、基线 105 passed / 8 failed,多出的9例来自本次入口参数化。8个失败的原始JUnit保留,归一化只处理临时fixture路径/对象地址及本次已改变的dispatch栈;不变的domain/测试帧和完整错误相等,均落在既有 canonical-authority fixture 缺失,而不是新解析路径。不会把失败数量相同或作者的另一组选集当作归因证据。
另外以真实SQLite验证原注册受众:未登记者即使被 mutable claimed_by 指向也拿不到目录;明确登记后能读取实际旧 canonical work;删除旧显示不改变权威结果。无spawn_policy时,三个命令的完整结果在base/head一致,context为None,不自动激活子任务。能力观察的真实预览/写入/另入口读回仍受原显式操作约束,只是本机观察,不产生credentials或Goal权限。实际host/model child未执行。
独立耗时实验用同一物理私有源码目录,仅切换两份精确Git生产文件,其余生产字节经全diff确认相同。每个provider/命令一轮ABBA warmup排除,再10个ABBA区块,即每arm20样本、共240个完整新Python进程;所有样本保留,计时期间没有本评审的测试/构建并行。以下为本机测得 median / p95,单位ms,并非复用作者的Linux数值:
| 完整命令 | 基线 | 当前 |
|---|---|---|
| file / agent-context | 476 / 498 | 155 / 165 |
| file / agent-directory | 554 / 616 | 276 / 304 |
| file / agent-capabilities | 494 / 507 | 152 / 167 |
| sqlite / agent-context | 505 / 540 | 164 / 173 |
| sqlite / agent-directory | 545 / 600 | 273 / 284 |
| sqlite / agent-capabilities | 544 / 597 | 165 / 188 |
六组均满足原尾延迟回归边界;RPC未减少,收益属于装载/身份解析成本,不能据此宣布总体长期节约。测量后完整 canonical Todo、registry 和状态文件均与原件一致;本机能力观察通过原CLI清除后固定用于全部计时arms。环境是共享macOS、已有warm native runtime,冷daemon、发行包、其它平台和全成本仍未资格。标准premerge 6 direct / 18 selected、Ruff和compile通过;未查询、轮询或等待远端CI。
我的整体评价
复用原 selected parser、注册函数、handler 和 request scope,删掉三个完整 CLI 的重复分支;减少入口装载与可执行身份解析成本,避免新增语义 owner、桥操作或权威数据缓存。 本 PR 完成三个现有协作命令的调用者接入;新主体和关闭策略仍走原所有者,peer 执行、完整原生 CLI 和 provider 资格保持独立。 当前既有业务语义与完整错误保持、真实source受众和关闭路径通过,完整命令的局部成本有独立配对改善,因此批准。不存在新的人手配置、确认或绕过规则;新增/修改数据仍由原注册、能力及canonical owner决定。
检查完整 CLI 入口、handler、双语 checkpoint 与原 frontend/Lark 调用关系,没有渲染页面、布局或控件变化,视觉审查不适用。 未验证发行包、其它操作系统、冷 daemon、GUI 或真实 peer/模型与长期完整成本。 agent_context 原guidance_only与硬受众约束没有混为一谈。原fixture故障继续与代码批准、合并就绪和真实模型采用分开;本评审不授合并、部署或去除他人讨论的权限。
English verdict: APPROVE — f057a3a8997b6e60928c760a9274b796c5fc6c20. The three complete public commands preserve full values, diagnostics, scoped read/write behavior and1/17/2 RPC sequences on real synthetic File/SQLite authorities.75 entrypoint tests pass;8 unchanged fixture failures are independently attributed.240 paired full-command samples improve p95 in all six workloads, with canonical state/registry readback unchanged. Native standard premerge passes; installed/cold-runtime/cross-platform/model utility remain outside this bounded caller adoption.
Goal And Delivered Outcome
Agent collaboration commands still loaded and registered the complete CLI before reaching their handlers.
agent-context,agent-directoryandagent-capabilitiesnow use the existing selected parser and shared dispatcher. Full-parser compatibility callers use that same dispatcher; their old handler branches are removed.The original command registrations, handlers, registry/runtime selection, native-controller guard and output remain. Source and capability observations stay live. The selected request scope pins executable identity without caching authority data.
Basis: the migration RFC's caller-adoption and locality requirements at main
0c0d3dd31e865782f653ea3195ef36d8fac7b395. Intended base:main.Author Declaration
docs/architecture/rfcs/typescript-control-plane-migration-v0.md, §2.8, Stage 3 and §5, at the base above.Scope And Continuation
Complete for these three commands. This is caller adoption, not a new semantic migration. Product diff: 29 added / 24 deleted, net +5 lines. No new module, dependency, bridge operation, semantic owner or state cache. Existing handlers are unchanged. Peer execution, model adoption, the full native CLI and provider promotion remain separate acceptance work.
Overlap check covers current open PR files and responsibilities. #7202 changes the selected dispatch for
refresh-state,checkpoint-context,read-only-map,rewardandoperator-gate; its actual patch does not implement these Agent commands. Other CLI-touching proposals change different domain behavior. This PR does not repeat their work or count their gains.Validation
agent-contextagent-directoryagent-capabilitiesagent-contextagent-directoryagent-capabilitiesInstrumented business RPC sequences are identical before/after on both providers: 1 for
agent-context, 17 foragent-directory, 2 foragent-capabilities. Full JSON matches apart from the directory observation timestamp. No business requests are eliminated or added.Fresh Python processes execute the complete command. Arms run base/head/head/base against the same fixture, with one warmup block excluded and 20 samples per arm per backend/command. The baseline loads only the two original production files from the pinned main; all other source is identical. Canonical File/SQLite fixtures contain one Todo, a registered Agent and enabled multi-subagent policy. Each result is checked against expected peer scope; registry and source Todo bytes remain unchanged. The native runtime is warm. No tests or builds overlap the timed run.
These measurements establish bounded command latency only. Full repository CI, installed-package behavior, supported-host/version coverage and real-model long-horizon benefit have not been qualified here. Existing test failures remain failures. This PR is an author-complete proposal for review, with no merge or release claim.
Frontend / Visual Evidence
UI impact: none. No command, flag, output text, page, control or configuration is added. Existing frontend/Lark consumers retain the same typed owners and readback. Screenshots are not applicable.
Boundary Checklist
mainis the target.