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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user