docs: refresh subagent lifecycle guidance - #7624
Conversation
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
|
Thanks for the PR! Template looks good ✓ Problem: This is a documentation-drift fix — the existing docs describe forks as interactive-only and subagents as stateless/single-use, which no longer matches the shipped implementation (headless fork support, Direction: Aligned — keeping docs accurate is core mission. The updates cover headless forks, continuation, caller-owned worktrees, and completion delivery, all of which are shipped features. Size: Not applicable — docs-only change (2 files, 42+/13-). Approach: Scope feels right. Every edit maps to a specific documentation gap, no unrelated changes or drive-by refactors. The two files are the natural homes for this content. Moving on to code review. 🔍 中文说明感谢贡献! 模板完整 ✓ 问题:这是一个文档漂移修复——现有文档将 fork 描述为仅支持交互模式、将 subagent 描述为无状态/单次执行,与已上线的实现(headless fork 支持、 方向:对齐——保持文档准确是核心使命。更新覆盖了 headless fork、继续流程、调用方拥有的 worktree 和完成通知投递,均为已上线功能。 规模:不适用——仅文档改动(2 个文件,42+/13-)。 方案:范围合理。每处编辑都对应一个具体的文档缺口,没有无关改动或顺手重构。两个文件是这些内容的自然归属。 进入代码审查 🔍 — Qwen Code · qwen3.8-max-preview Reviewed at |
Code ReviewIndependent proposal: For a subagent lifecycle docs refresh, I would update Comparison with the diff: The PR does exactly this. I verified every factual claim against the source code:
No correctness issues, no AGENTS.md violations. TestingDocs-only change — no runtime behavior to exercise in tmux. Verification: Content accuracy verified against source code as detailed above. 中文说明代码审查独立方案: 对于 subagent 生命周期文档刷新,我会更新 与 diff 对比: PR 完全按照这个思路执行。我逐一对照源码验证了每个事实性声明:
无正确性问题,无 AGENTS.md 违规。 测试仅文档改动——无需在 tmux 中运行运行时行为。验证结果:Prettier 格式检查通过, — Qwen Code · qwen3.8-max-preview Reviewed at |
|
Confidence: 5/5 Every factual claim in this PR checks out against the source code — headless fork support, completion notifications, background agent continuation via The changes are focused (2 docs files, no code), the scope matches the stated goal, and formatting passes Prettier and LGTM, approving. ✅ 中文说明置信度:5/5 本 PR 中的每个事实性声明都已对照源码验证——headless fork 支持、完成通知、通过 改动聚焦(2 个文档文件,无代码改动),范围与目标一致,格式通过 Prettier 和 LGTM,批准。✅ — Qwen Code · qwen3.8-max-preview Reviewed at |
qwen-code-ci-bot
left a comment
There was a problem hiding this comment.
LGTM, looks ready to ship. ✅
qwen-code-ci-bot
left a comment
There was a problem hiding this comment.
Reviewed. Suggestions are inline.
— qwen3.7-max via Qwen Code /review
| 2. **Delegation**: The main AI can automatically delegate tasks to appropriate Subagents — or fork itself (`subagent_type: "fork"`) when it needs the parent conversation context | ||
| 3. **Execution**: Subagents work independently, using their configured tools to complete tasks | ||
| 4. **Results**: Background runs notify the main conversation when they finish; foreground opt-outs return results inline | ||
| 4. **Results**: Background runs send a completion notification containing the result to the main conversation; foreground regular subagents return results inline |
There was a problem hiding this comment.
[Suggestion] Interactive forks without run_in_background: true default to the foreground path and return only a placeholder — the fork's actual result is never delivered to the parent conversation. The docs here cover "background runs" (completion notification) and "foreground regular subagents" (inline), but omit the interactive fork case.
The same gap exists in two other places this PR touches:
- The fork prose above (line 17) says forks "normally run detached in the background" without explaining when they don't. The tool schema at
agent.ts:794has the missing guidance: "Set to true for an interactive fork to receive its completion notification." docs/developers/tools/task.mdline 17 describesrun_in_backgroundfor "top-level regular agents" and "headless forks" but omits interactive forks.
Failure scenario: A user launches agent({subagent_type: "fork", prompt: "..."}) in an interactive session without run_in_background: true. The code routes this to the foreground fork path (agent.ts:2463–2471), returns FORK_PLACEHOLDER_RESULT, and the fork's actual result is never delivered.
| 4. **Results**: Background runs send a completion notification containing the result to the main conversation; foreground regular subagents return results inline | |
| 4. **Results**: Background runs send a completion notification containing the result to the main conversation; foreground regular subagents return results inline. Interactive forks require `run_in_background: true` to receive a completion notification; without it, the fork returns only a placeholder. |
— qwen3.7-max via Qwen Code /review
What this PR does
Refreshes the subagent user and developer documentation to match the current agent lifecycle. It documents headless fork support, completion notifications, background-agent discovery and continuation, session roster restoration, and caller-owned worktree behavior.
Why it's needed
The existing guidance still described forks as interactive-only and unable to return results to the parent conversation. It also characterized subagents as stateless, single-use executions, despite the shipped
list_agentsandsend_messagecontinuation flow. These discrepancies could lead users and tool authors to launch duplicate agents or misunderstand supported execution modes.Reviewer Test Plan
How to verify
Compare the documented behavior against the current Agent tool schema and background-task lifecycle: forks should be available in headless sessions and report results through completion notifications; background agents should be discoverable and continuable across running, paused, completed, and restored states; caller-owned worktrees should remain foreground-only and unavailable to forks.
Evidence (Before & After)
N/A — documentation-only change.
Tested on
Environment (optional)
Documentation validation with Prettier and
git diff --check.Risk & Scope
Linked Issues
None.
中文说明
本 PR 做了什么
更新 subagent 的用户与开发者文档,使其与当前 agent 生命周期保持一致。文档现在覆盖 headless fork 支持、完成通知、后台 agent 的发现与继续、会话 roster 恢复,以及调用方拥有的 worktree 行为。
为什么需要
现有文档仍将 fork 描述为仅支持交互模式且无法将结果反馈给父对话;同时也将 subagent 描述为无状态、单次执行,尽管已经上线了基于
list_agents和send_message的继续工作流程。这些差异可能导致用户和工具作者重复启动 agent,或误解当前支持的执行模式。Reviewer Test Plan
How to verify
将文档描述与当前 Agent tool schema 和后台任务生命周期进行对照:fork 应支持 headless 会话并通过完成通知返回结果;后台 agent 应能在 running、paused、completed 和 restored 状态下被发现和继续;调用方拥有的 worktree 应仅支持前台运行,且不能用于 fork。
Evidence (Before & After)
N/A — 仅文档改动。
Tested on
Environment (optional)
使用 Prettier 和
git diff --check验证文档。Risk & Scope
Linked Issues
无。