fix(tools): prevent AbortSignal listener leak in exec and process tools

Each tool call added an abort listener to the shared agent signal
without cleanup, exceeding the default 10-listener limit after 11+
exec calls. Fix by using { once: true } and removing the listener
on child process close (exec) to prevent accumulation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
yushen 2026-02-06 19:58:31 +08:00
parent a3f5a21561
commit c24fafadeb
2 changed files with 14 additions and 11 deletions

View file

@ -112,7 +112,7 @@ export function createProcessTool(defaultCwd?: string): AgentTool<typeof Process
if (signal) {
signal.addEventListener("abort", () => {
child.kill("SIGTERM");
});
}, { once: true });
}
resolve({ success: true });