fix(tools): clear timeout timers and update audit state
This commit is contained in:
+11
-3
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user