编辑 | blame | 历史 | 原始文档

Selective SubAgent Execution Policy

Agent roles define responsibility. Execution plans decide threads.

Concrete modes

  • inline: execute in the main thread.
  • subagent-readonly: isolate exploration, analysis, QA, security, architecture review, or final review with no writes.
  • subagent-shared: use a SubAgent in the shared workspace only for serialized, non-overlapping writes.
  • subagent-worktree: use an isolated worktree for independent parallel implementation with stable contracts.

Default to inline. Use a SubAgent only when the task is independently describable, inputs are stable, output is structured, scope is bounded, file overlap is low, and isolation or parallelism outweighs coordination cost.

Concurrency gates

  • Assign one writer to each file or module per phase.
  • Run parallel writers only with disjoint write scopes.
  • Keep dependency manifests, lockfiles, migrations, generated code, routing, and integration files under one owner.
  • Serialize work when overlap emerges.
  • Keep repository exploration, security, QA, and review read-only by default.
  • Degrade to sequential inline execution when SubAgents or worktrees are unavailable.

Handoff and return

Every delegated task carries an immutable objective, acceptance criteria, source of truth, inputs, read scope, write scope, required project Skills, prohibited actions, verification, escalation conditions, and required return format.

Use one return contract everywhere:

status
summary
findings_or_changes
artifacts
files_inspected
files_changed
assumptions
risks
verification
unresolved_items
recommended_next_action

A SubAgent returns partial evidence when possible. The main orchestrator decides whether to retry, reject, serialize, or integrate it.