Skip to content

feat: add Fork Subagent deep-dive comparison#36

Merged
wenshao merged 2 commits into
mainfrom
feat/fork-subagent-deep-dive
Apr 3, 2026
Merged

feat: add Fork Subagent deep-dive comparison#36
wenshao merged 2 commits into
mainfrom
feat/fork-subagent-deep-dive

Conversation

@wenshao

@wenshao wenshao commented Apr 3, 2026

Copy link
Copy Markdown
Owner

Summary

New comparison article docs/comparison/fork-subagent-deep-dive.md (347 lines) covering Claude Code's implicit Fork Subagent mechanism vs Qwen Code's explicit Agent tool.

Key Content

Section Content
Trigger decision tree subagent_type omitted → implicit fork (feature-gated)
Message construction Byte-identical placeholders for prompt cache sharing
4 cache guarantees System prompt / tools / messages / thinking config
10 fork rules Prevent recursion, enforce structured output
Recursion guard Dual-layer (querySource + message scan)
Worktree isolation Optional git worktree per fork child
Cost model 5 forks × 100K context: Fork=105K vs Normal=500K tokens
Qwen Code comparison subagent_type required, no context inheritance, no cache sharing

Why this matters

Fork Subagent is Claude Code's most sophisticated prompt cache optimization — N children share one cache entry. Previously only mentioned briefly in 09-multi-agent.md and qwen-code-improvement-report.md, never a dedicated deep-dive.

Test plan

  • Verify markdown renders correctly
  • Spot-check source code line references

🤖 Generated with Claude Code

Comprehensive article on Claude Code's implicit fork mechanism vs Qwen Code's
explicit agent tool. Covers: trigger decision tree, FORK_AGENT definition,
message construction for prompt cache sharing, 4 cache consistency guarantees,
10 non-negotiable rules for fork children, dual-layer recursion guard,
worktree isolation, async execution model, cost model comparison (105K vs 500K
tokens for 5 subagents with 100K context).

Key finding: Fork's core value is prompt cache economics — byte-identical
API request prefixes allow N fork children to share one cache entry.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@wenshao wenshao force-pushed the feat/fork-subagent-deep-dive branch from 07962a2 to d944393 Compare April 3, 2026 20:43
@wenshao wenshao requested a review from Copilot April 3, 2026 20:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new deep-dive comparison article explaining Claude Code’s implicit Fork Subagent mechanism versus Qwen Code’s explicit Agent tool, with an emphasis on prompt-cache sharing and execution/recursion/isolation constraints.

Changes:

  • Introduces a new comparison doc covering fork triggering, cache-key prefix construction, and consistency guarantees.
  • Documents fork-specific rules (anti-recursion, structured output) plus async execution and worktree isolation behavior.
  • Provides a side-by-side comparison and token-cost model versus Qwen Code.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/comparison/fork-subagent-deep-dive.md
Comment thread docs/comparison/fork-subagent-deep-dive.md Outdated
Comment thread docs/comparison/fork-subagent-deep-dive.md
Comment thread docs/comparison/fork-subagent-deep-dive.md
1. Unified source paths: forkSubagent.ts# → tools/AgentTool/forkSubagent.ts#
2. Fixed assistant message diagram: added thinking+text to match description
3. Fixed line counts: forkSubagent.ts 211→210, forkedAgent.ts 690→689
   (consistent with other docs citing wc -l)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@wenshao wenshao requested a review from Copilot April 3, 2026 21:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@wenshao wenshao merged commit ed147bf into main Apr 3, 2026
4 checks passed
wenshao added a commit that referenced this pull request Apr 5, 2026
Closed PR #75 — 10 of 16 items duplicated existing 187. Source code
references all verified correct (glm-5.1 self-corrected 8 errors).

Extracted 4 new items to p2-tools:
- #35 preserveQuoteStyle (quote style preservation in edits)
- #36 areFileEditsInputsEquivalent (skip duplicate edits)
- #37 MCP channel plugin allowlist
- #38 SDK message type enrichment (11 → 30+ types)

Total: 191 items.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

2 participants