Skip to content

Commit 5b5d0f2

Browse files
committed
Correct the sub-agent tool description's working-tree claim
The task tool description and the isolated-run comment both said the sub-agent unconditionally shares your working tree, which is only true in the default dispatch mode. Worktree isolation snapshots the dispatcher's last commit, so uncommitted and untracked changes are never visible to a sub-agent running in that mode.
1 parent e3fd0d1 commit 5b5d0f2

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

src/subagent/run.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,12 @@ export function createSubAgentRunController(
205205
};
206206
}
207207

208-
// Spin up an isolated, autonomous agent loop against the same working tree,
209-
// hand it one task, and return its final report. The sub-agent shares the
210-
// dispatcher's cwd so its edits land in the real repo, but gets its own posix
211-
// tool instances and its own git-backed context store so the two loops never
212-
// trample each other's state.
208+
// Spin up an isolated, autonomous agent loop, hand it one task, and return
209+
// its final report. `params.cwd` is either the dispatcher's own cwd (shared
210+
// mode) or a worktree snapshotted from the dispatcher's last commit
211+
// (isolated mode, see task-tool.ts's useWorktree) — either way this loop
212+
// gets its own posix tool instances and its own git-backed context store so
213+
// the two loops never trample each other's state.
213214
export async function runSubAgent(params: RunSubAgentParams): Promise<string> {
214215
return withSubAgentSlot(() => runSubAgentInner(params), {
215216
reentrant: params.nested === true,

src/subagent/task-tool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export const TaskToolArgs = type({
6464
export const taskToolDefinition: ToolDefinition = {
6565
name: "task",
6666
description:
67-
"Spawn a sub-agent (a short-lived child agent) for one self-contained job. This is not a checklist item — use manage_tasks for your own work list. The sub-agent has the full file, search, and shell toolset, uses this session's permission gate (saved grants and auto mode when eligible; you may be prompted for other consequential actions), and returns a structured report (Summary / Findings / Blockers / Paths). Use it to parallelize exploration (\"map every caller of X\") or hand off a well-scoped implementation so your own context stays focused. Fire several task calls in one turn to run sub-agents in parallel. When launching multiple agents with the same profile, assign each a distinct lens in description and prompt so they do not duplicate work. The sub-agent cannot ask you questions and shares your working tree. Write a clear brief: context = durable background; prompt = actionable goal; goals = optional manage_tasks seeds. Prefer the typed spawn contract so leaves finish without thrashing: intent (explore|implement|review|plan|general), success_criteria (done-when checklist), do_not (scope fence), report_focus (what Findings must cover). After thrash / no-progress / repetition / never-acted salvage, re-dispatching the identical brief (same prompt/agent/intent/success_criteria/do_not) is refused — change the brief to retry; maxTurns or tier alone does not unlock it. Turn-budget salvage may invite a higher maxTurns a few times, then stops recommending re-dispatch until a successful complete resets the same-brief retry budget.",
67+
"Spawn a sub-agent (a short-lived child agent) for one self-contained job. This is not a checklist item — use manage_tasks for your own work list. The sub-agent has the full file, search, and shell toolset, uses this session's permission gate (saved grants and auto mode when eligible; you may be prompted for other consequential actions), and returns a structured report (Summary / Findings / Blockers / Paths). Use it to parallelize exploration (\"map every caller of X\") or hand off a well-scoped implementation so your own context stays focused. Fire several task calls in one turn to run sub-agents in parallel. When launching multiple agents with the same profile, assign each a distinct lens in description and prompt so they do not duplicate work. The sub-agent cannot ask you questions. Depending on dispatch configuration it either shares your working tree directly, or runs isolated in its own git worktree snapshotted from your last commit — in the isolated case, any uncommitted or untracked changes in your working tree are excluded. Write a clear brief: context = durable background; prompt = actionable goal; goals = optional manage_tasks seeds. Prefer the typed spawn contract so leaves finish without thrashing: intent (explore|implement|review|plan|general), success_criteria (done-when checklist), do_not (scope fence), report_focus (what Findings must cover). After thrash / no-progress / repetition / never-acted salvage, re-dispatching the identical brief (same prompt/agent/intent/success_criteria/do_not) is refused — change the brief to retry; maxTurns or tier alone does not unlock it. Turn-budget salvage may invite a higher maxTurns a few times, then stops recommending re-dispatch until a successful complete resets the same-brief retry budget.",
6868
inputSchema: {
6969
type: "object",
7070
properties: {

0 commit comments

Comments
 (0)