summaryrefslogtreecommitdiff
path: root/packages/server/src/tools/tools.ts
diff options
context:
space:
mode:
authorTaylor Mullen <[email protected]>2025-05-09 23:29:02 -0700
committerN. Taylor Mullen <[email protected]>2025-05-10 00:21:09 -0700
commit6b518dc9e4c601c0108768932dc1450c036075fd (patch)
treeaac19953db5a8cc2d1a68f46b51f1e5bef570e0e /packages/server/src/tools/tools.ts
parent090198a7d644f24c617bd35db6a287b930729280 (diff)
Enable tools to cancel active execution.
- Plumbed abort signals through to tools - Updated the shell tool to properly cancel active requests by killing the entire child process tree of the underlying shell process and then report that the shell itself was canceled. Fixes https://b.corp.google.com/issues/416829935
Diffstat (limited to 'packages/server/src/tools/tools.ts')
-rw-r--r--packages/server/src/tools/tools.ts5
1 files changed, 3 insertions, 2 deletions
diff --git a/packages/server/src/tools/tools.ts b/packages/server/src/tools/tools.ts
index ac04450d..7bb05a95 100644
--- a/packages/server/src/tools/tools.ts
+++ b/packages/server/src/tools/tools.ts
@@ -64,7 +64,7 @@ export interface Tool<
* @param params Parameters for the tool execution
* @returns Result of the tool execution
*/
- execute(params: TParams): Promise<TResult>;
+ execute(params: TParams, signal: AbortSignal): Promise<TResult>;
}
/**
@@ -141,9 +141,10 @@ export abstract class BaseTool<
* Abstract method to execute the tool with the given parameters
* Must be implemented by derived classes
* @param params Parameters for the tool execution
+ * @param signal AbortSignal for tool cancellation
* @returns Result of the tool execution
*/
- abstract execute(params: TParams): Promise<TResult>;
+ abstract execute(params: TParams, signal: AbortSignal): Promise<TResult>;
}
export interface ToolResult {