fix(agent): release task spawn slot when progress reporting throws

In #registerSpawnJob the markRunning()/reportProgress() calls sat between
semaphore.acquire() and the try whose finally releases the slot. If progress
reporting threw there, the acquired task.maxConcurrency slot leaked and
permanently shrank subagent concurrency. Move those statements inside the try
so finally always releases. The abort-before-execution branch is unchanged
(releases once and throws before the try is entered — not a double release).

Refs #3464
This commit is contained in:
can1357
2026-06-25 20:48:38 +02:00
parent ecd6f608e5
commit 06ca03dbd8
2 changed files with 7 additions and 6 deletions
+6 -6
View File
@@ -798,13 +798,13 @@ export class TaskTool implements AgentTool<TaskToolSchemaInstance, TaskToolDetai
onSettled?.(true);
throw new Error("Aborted before execution");
}
markRunning();
progress.status = "running";
await reportProgress(
`Running background task ${agentId}...`,
buildDetails("running", ownJobId) as unknown as Record<string, unknown>,
);
try {
markRunning();
progress.status = "running";
await reportProgress(
`Running background task ${agentId}...`,
buildDetails("running", ownJobId) as unknown as Record<string, unknown>,
);
const result = await this.#executeSync(
toolCallId,
spawnParams,