Skip to content

Commit 7e08553

Browse files
committed
add sync/async handlers for tools
1 parent e2d9d29 commit 7e08553

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@codebuff/sdk",
33
"private": false,
44
"access": "public",
5-
"version": "0.1.33",
5+
"version": "0.2.0",
66
"description": "Official SDK for Codebuff — AI coding agent & framework",
77
"license": "Apache-2.0",
88
"type": "commonjs",

sdk/src/custom-tool.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export type CustomToolDefinition<
2828
* @param description a description of the tool to be passed to the LLM. This should describe what the tool does and when to use it.
2929
* @param endsAgentStep whether the tool ends the agent step. If `true`, this will be used as a "stop sequence" for the LLM. i.e. it will not be able to call any other tools after this one in a single step and must wait for the tool results. Used for tools that give more information to the LLM.
3030
* @param exampleInputs an array of example inputs for the tool.
31-
* @param execute what to do when the tool is called.
31+
* @param execute what to do when the tool is called. Can be either a sync or async.
3232
* @returns The CustomToolDefinition object
3333
*/
3434
export function getCustomToolDefinition<
@@ -51,7 +51,7 @@ export function getCustomToolDefinition<
5151
description: string
5252
endsAgentStep?: boolean
5353
exampleInputs?: Input[]
54-
execute: (params: Args) => Promise<Output>
54+
execute: (params: Args) => Promise<Output> | Output
5555
}): CustomToolDefinition<ToolName, Args, Input, Output> {
5656
return {
5757
toolName,
@@ -61,6 +61,8 @@ export function getCustomToolDefinition<
6161
description,
6262
endsAgentStep,
6363
exampleInputs,
64-
execute,
64+
execute: async (params) => {
65+
return await execute(params)
66+
},
6567
}
6668
}

0 commit comments

Comments
 (0)