Skip to content

feat(collaboration): let existing agent conversations delegate governed work - #4706

Merged
huangruiteng merged 2 commits into
mainfrom
codex/attached-agent-delegation-cli-20260918
Sep 19, 2026
Merged

huangruiteng merged 2 commits into
mainfrom
codex/attached-agent-delegation-cli-20260918

Conversation

@huangruiteng

Copy link
Copy Markdown
Collaborator

Problem and result

An existing shell-capable Agent could not use the bound delegation service without adding MCP tools or launching another lead. loopx delegation list/start/read/wait/resume now exposes that same service to the current conversation. Start returns while the detached worker continues; reconnect and retry retain the original operation, and accepted results still require current canonical completion and artifact verification.

Advances the attached-caller part of roadmap R2/R3 (#4574), reusing #4688 and the clarified contracts in #4702. This does not close the continuous-team milestone.

Implementation

  • Thin CLI adapter; shared bounded wait and lazy MCP import. No new scheduler, Agent factory, grant store or acceptance authority.
  • managed-research-team prepare creates a disposable fixture and bindings without starting a replacement lead. Clarify the required upstream-adoption hash in member tasks/tools after live rejection exposed the missing guidance.
  • Update usage and bilingual RFC checkpoints. Classify the new command on command-specific help and repair the existing missing goal-acceptance classification.
  • Existing CLI/MCP execution owners are reused. Frontend/Lark settings and session-mode behavior are unchanged; no new configuration surface is introduced.

Validation

  • 38 focused tests across CLI processes, shared delegation/MCP and managed research: real File/SQLite authority, client disconnect/retry, single execution, current acceptance, tampered artifacts, invalid inputs, optional MCP absence and prepare-only behavior.
  • Real existing-conversation CLI rehearsal: 2 DSH + 2 Ark workers, including cloud-to-local nested delegation; both cloud members adopted exact upstream hashes. The lead consumed four artifacts and independently completed the report: 5 canonical tasks done, Goal active.
  • Synthetic conclusions: normalized FCF 40 → 25, revision −15; periods incomparable, one current-period source family, corrected repost stale.
  • Preserve failed attempts: stale cloud environment rejected before model work; first model round omitted adoption hashes and failed. Clarifying the output contract produced a successful fresh rehearsal without changing validators. Owned cloud resources were cleaned and absence checked.
  • Final premerge: 18 selected checks passed, plus CLI help/docs smokes, focused Ruff, configured mypy and public-boundary scan. The first premerge was invalidated by an edit during execution and rerun on frozen files. Latest-main rebase added only unrelated presentation files; candidate contents were unchanged.

Dynamic provisioning, unattended wakeup, persistent worker-session policy, and complete inbox/queue/steer remain separate RFC work. Local setup, private data, credentials and raw experiment records are excluded. Runtime changes remain for maintainer merge.

Signed-off-by: huangruiteng <14976749+huangruiteng@users.noreply.github.com>
Signed-off-by: huangruiteng <14976749+huangruiteng@users.noreply.github.com>

@huangruiteng huangruiteng 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.

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

Exact head: bbeab4cfd88e4cc3c6fe814a461c080f907a46a9;base: 3406be3d1724c081e8c004d351d78696a852578b。

没有发现阻断本次交付切片的问题。结论为 APPROVE;此评审不授予 runtime 自合并权限。

动机

按 #4574 的 R2/R3、已合并 #4688 的委派服务和 #4702 的边界判断,这是一项有实际调用者的增量:已有 shell 能力的 Agent 可以继续当前对话,调用受治理的委派服务。旧路径要求 MCP 接入,示例 run 还会启动另一个 lead;新路径让原对话完成派发、结果读回及综合。

本 PR 完成的是这个调用入口,不是整个 G1 持续团队目标。动态建队、原会话无人值守唤醒、完整 inbox/queue/steer 和持久云端 worker 会话仍有明确后续 owner。

改动思路

CLI → 现有 Delegations → TS 执行授权/状态转换 → 原 Turn → 当前 pinned 验收 → canonical Todo 完成 → 产物复核。没有第二套调度器、任务账本或验收规则;模型和工具返回“完成”不能跳过这条链。

比较了不做改动、文档指导调用内部 Python、另建调度层三个方案。71 行 CLI 复用现有 owner,补上稳定入口,维护成本合理。前后版本搜索也确认 configure_delegations、Turn 与验收 owner 均被复用。相关重构限于共用 wait、延迟加载可选 MCP,以及 prepare/run 共用初始化。

具体改动

14 个文件,+358/-17。生产变化包括 CLI 注册/dispatch、命令专属帮助分类及共享 wait;127 行新增测试覆盖进程边界。示例增加 prepare-only 和上游哈希字段说明;使用指南、示例 README、session/roadmap 中英文 checkpoint 同步。顺带补齐既有 goal-acceptance 的帮助分类遗漏,没有改变该命令行为。

关键代码讲解

  • handle_delegation:检查动作、显式 execute、稳定操作 ID 和 brief 大小,随后调用共享服务。ok 表示调用结果,status 和当前验收产物才表示任务结果。
  • Delegations.wait:CLI/MCP 共用有界观察;不启动、不恢复任务,最后再读一次当前状态。
  • prepare_execution:复用隔离 fixture 和 operator binding 初始化,返回入口信息,不另起 lead Turn。原 run 复用它。
  • write_output:工具说明和 scenario.task 明确要求 adopted_dependencies 的完整哈希。底层验证器保持不变;这是实测拒收促成的契约说明修复。

对主干的风险

最强反例是“调用成功、文件存在,但实际重复执行或没有采用上游证据”。真实 CLI 进程测试覆盖断开重连、相同操作不重复调用宿主、无 execute 不启动、错误身份读回和验收后篡改产物;现有 File/SQLite 测试覆盖接收方未采纳时不能完成。

真实模型第一轮确实遗漏了依赖哈希,另有旧云环境拒绝、超时或非 JSON 结果。这些失败没有被覆盖为成功。明确输出字段后重新建立隔离团队,两个云端成员采用准确上游哈希;其中云端分析员自主派发本地核验员。最终 2 DSH + 2 Ark、四份依赖和总报告共 5 个 canonical Todo 完成,Goal active。云端实验资源已清理并读回不存在。合成结论为 FCF 40→25、差值 −15、期间不可比、一个来源家族。

语义与 CI 对齐

复用现有请求/执行词汇,没有新增状态权威。CLI 是可信本地入口,不是远端身份认证或 Agent 创建协议。未提供 execution config 的 MCP 仍只有原来的五个工具;注册、命令可见、prepare/list/read/wait 都不激活模型执行。领域提示只在显式合成示例中加载,不进入通用控制面。Frontend/Lark 配置和会话模式没有变化。

执行了完全相同的 baseline/head MCP 与 File/SQLite 测试,各 15 passed。另有 6 项新 CLI 测试;本次完整聚焦组合为 38 passed。实际进程对照确认旧版缺少命令、缺 MCP 时共享 worker 无法 import,而新入口与延迟加载生效。最终 premerge 18 项通过;CLI 帮助、docs smoke、Ruff、配置范围内 mypy、隐私扫描通过。首次 premerge 因执行中编辑导致范围漂移而无效,冻结文件后重跑通过。

按当前 Goal 解析出的 wait_for_ci=false,没有查询或等待远端 CI;本地必需检查没有遗留失败或跳过。精确范围 change-quality receipt 已核验有效。

我的整体评价

这是完整、可回滚的原会话入口增量:已有执行与验收能力现在能直接被原协调 Agent 复用,真实混合/嵌套链路也闭合了产物依赖。它不会宣称固定绑定等于动态团队、一次协作等于持续多周期运行。最重要的剩余验证是原请求唤醒、动态工作派生及真实项目连续修订周期,按既有 R2/R3 owner 继续推进。

English verdict: APPROVE - HEAD bbeab4c. Thin CLI reuses governed delegation without replacing the lead conversation. Paired baseline/head compatibility, focused process tests, 18 premerge checks, and a real synthetic nested DSH/Ark team passed. Dynamic provisioning and unattended wakeup remain outside scope; maintainer merge required.

@huangruiteng
huangruiteng merged commit 936e043 into main Sep 19, 2026
30 checks passed
@huangruiteng
huangruiteng deleted the codex/attached-agent-delegation-cli-20260918 branch September 19, 2026 05:40
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