feat(cli): add read-only Agent View coordination primitives - #8796
Closed
yiliang114 wants to merge 1 commit into
Closed
feat(cli): add read-only Agent View coordination primitives#8796yiliang114 wants to merge 1 commit into
yiliang114 wants to merge 1 commit into
Conversation
This was referenced Aug 9, 2026
Collaborator
Author
|
Superseded by #8804. The implementation now targets 中文说明该草稿已由 #8804 替代。新实现直接基于 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
This stacked draft adds the first executable coordination slice from RFC #8718 on top of #7802. A caller can dispatch a background Agent View session with an explicit read-only profile, receive a machine-readable acknowledgement, and collect a one-shot terminal snapshot by session ID.
The read-only worker starts with a fixed four-tool inspection surface, ignores ambient settings that could add startup side effects, disables hooks, MCP discovery, extensions, cron, memory writes, delegation, shell execution, and sandbox configuration, and rejects nested background dispatch from inside a worker. The supervisor-to-worker sideband now uses ephemeral per-generation credentials and ordered, acknowledged events so stale, duplicated, or out-of-order lifecycle updates cannot mutate the current session.
Why it's needed
Qwen Code already has Agent View lifecycle infrastructure, but it does not yet expose a safe primitive for a coordinator to fan out independent read-only investigations and collect their results. This slice establishes that boundary before adding higher-level task graphs, writer agents, or worktree orchestration, keeping orchestration behavior separable from tool-restriction evaluation as requested in the RFC review.
Reviewer Test Plan
How to verify
qwen --bg --read-only --output-format json "Inspect the repository and summarize the relevant code."; confirm stdout is one JSON dispatch acknowledgement containing the session ID,createdstate, andread-onlyprofile.qwen collect <session-id>; confirm it returns one JSON snapshot with the session state, process state, and current result, and that a unique session-ID prefix is accepted while ambiguous or missing IDs fail clearly.qwen --bg ...; confirm it is rejected before contacting the supervisor.Evidence (Before & After)
Before: #7802 exposes foreground/background Agent View lifecycle commands but has no read-only background profile or collect command.
After: the focused CLI suites pass 480 tests, the CLI startup suite passes 61 tests, the focused core suites pass 514 tests, core typechecking passes, and all changed TypeScript files pass Prettier and ESLint. Full CLI typechecking is currently blocked by the inherited #7802 branch's Ink selection API dependency mismatch; filtering its output reports no errors in this change's files.
Tested on
Environment (optional)
Node.js 22 workspace install; focused Vitest suites and TypeScript/ESLint/Prettier checks.
Risk & Scope
Linked Issues
Related to #8718. Design RFC: #8719. Stacked on #7802.
中文说明
这个 PR 做了什么
这个叠加式 Draft PR 在 #7802 之上实现了 RFC #8718 的第一个可执行协作切片。调用方可以用明确的只读配置分发后台 Agent View 会话,获得机器可读的确认消息,并按会话 ID 一次性收集终态快照。
只读 worker 启动时固定只暴露四个检查工具,并忽略可能引入启动副作用的环境配置;hooks、MCP 发现、扩展、cron、记忆写入、委派、shell 执行和 sandbox 配置均被关闭,同时禁止 worker 内部再次后台分发。supervisor 到 worker 的 sideband 改为使用每个 generation 独立的临时凭据和带确认的有序事件,因此过期、重复或乱序的生命周期更新不能修改当前会话。
为什么需要它
Qwen Code 已有 Agent View 生命周期基础设施,但还没有为 coordinator 提供一个安全的基础能力,用于并发分发独立的只读调研并收集结果。这个切片先建立安全边界,再继续增加高层任务图、writer agent 或 worktree 编排,也让 orchestration 行为和工具限制能够按照 RFC 评审建议分别评测。
Reviewer 测试计划
如何验证
qwen --bg --read-only --output-format json "Inspect the repository and summarize the relevant code."启动后台检查;确认 stdout 仅输出一条 JSON 分发确认,其中包含会话 ID、created状态和read-onlyprofile。qwen collect <session-id>;确认返回一条包含会话状态、进程状态和当前结果的 JSON 快照;唯一的会话 ID 前缀可以使用,歧义或不存在的 ID 会明确失败。qwen --bg ...;确认在接触 supervisor 前即被拒绝。证据(Before & After)
Before:#7802 暴露了前台/后台 Agent View 生命周期命令,但没有只读后台 profile 或 collect 命令。
After:CLI 聚焦测试通过 480 项,CLI 启动测试通过 61 项,core 聚焦测试通过 514 项,core typecheck 通过,全部变更的 TypeScript 文件通过 Prettier 和 ESLint。CLI 全量 typecheck 当前被继承自 #7802 分支的 Ink selection API 依赖不匹配阻塞;过滤输出后,本次变更文件没有错误。
测试平台
环境(可选)
Node.js 22 workspace 安装;执行了聚焦 Vitest、TypeScript、ESLint 和 Prettier 检查。
风险与范围
关联 Issue
关联 #8718。设计 RFC:#8719。叠加在 #7802 上。