fix(tools): clear timeout timers and update audit state

This commit is contained in:
William Valentin
2026-02-15 21:44:40 -08:00
parent d93c1c9f8d
commit 4cdad8eee9
4 changed files with 607 additions and 491 deletions
+11 -3
View File
@@ -224,6 +224,7 @@ export class ToolExecutor {
agent_tier: context?.tier,
});
let timeoutHandle: NodeJS.Timeout | undefined;
try {
const result = await Promise.race([
(async () => {
@@ -239,9 +240,12 @@ export class ToolExecutor {
}
return tool.execute(args);
})(),
new Promise<ToolResult>((_, reject) =>
setTimeout(() => reject(new Error(`Tool '${toolName}' timed out after ${this.defaultTimeoutMs}ms`)), this.defaultTimeoutMs),
),
new Promise<ToolResult>((_, reject) => {
timeoutHandle = setTimeout(
() => reject(new Error(`Tool '${toolName}' timed out after ${this.defaultTimeoutMs}ms`)),
this.defaultTimeoutMs,
);
}),
]);
const duration = Date.now() - startTime;
@@ -286,6 +290,10 @@ export class ToolExecutor {
output: '',
error: String(errorRedaction.value),
};
} finally {
if (timeoutHandle) {
clearTimeout(timeoutHandle);
}
}
}