@@ -147,14 +147,6 @@ class BedrockAgentFunctionResolver {
147
147
fn : ToolFunction < TParams > ,
148
148
config : Configuration
149
149
) : undefined {
150
- this . #registerTool( fn , config ) ;
151
- return ;
152
- }
153
-
154
- #registerTool< TParams extends Record < string , ParameterValue > > (
155
- handler : ToolFunction < TParams > ,
156
- config : Configuration
157
- ) : void {
158
150
const { name } = config ;
159
151
if ( this . #tools. has ( name ) ) {
160
152
this . #logger. warn (
@@ -163,7 +155,7 @@ class BedrockAgentFunctionResolver {
163
155
}
164
156
165
157
this . #tools. set ( name , {
166
- handler : handler as ToolFunction ,
158
+ handler : fn as ToolFunction ,
167
159
config,
168
160
} ) ;
169
161
this . #logger. debug ( `Tool "${ name } " has been registered.` ) ;
@@ -213,9 +205,9 @@ class BedrockAgentFunctionResolver {
213
205
const tool = this . #tools. get ( toolName ) ;
214
206
215
207
if ( tool == null ) {
216
- this . #logger. error ( `Tool ${ toolName } has not been registered.` ) ;
208
+ this . #logger. error ( `Tool " ${ toolName } " has not been registered.` ) ;
217
209
return new BedrockFunctionResponse ( {
218
- body : `Error: tool ${ toolName } has not been registered.` ,
210
+ body : `Error: tool " ${ toolName } " has not been registered.` ,
219
211
sessionAttributes,
220
212
promptSessionAttributes,
221
213
knowledgeBasesConfiguration,
@@ -238,7 +230,7 @@ class BedrockAgentFunctionResolver {
238
230
break ;
239
231
}
240
232
// this default will also catch array types but we leave them as strings
241
- // because we cannot reliably parse them
233
+ // because we cannot reliably parse them - see discussion in #3710
242
234
default : {
243
235
toolParams [ param . name ] = param . value ;
244
236
break ;
@@ -269,8 +261,12 @@ class BedrockAgentFunctionResolver {
269
261
} ) ;
270
262
} catch ( error ) {
271
263
this . #logger. error ( `An error occurred in tool ${ toolName } .` , error ) ;
264
+ const errorMessage =
265
+ error instanceof Error
266
+ ? `${ error . name } - ${ error . message } `
267
+ : String ( error ) ;
272
268
return new BedrockFunctionResponse ( {
273
- body : `Unable to complete tool execution due to ${ error instanceof Error ? ` ${ error . name } - ${ error . message } ` : String ( error ) } ` ,
269
+ body : `Unable to complete tool execution due to ${ errorMessage } ` ,
274
270
sessionAttributes,
275
271
promptSessionAttributes,
276
272
knowledgeBasesConfiguration,
0 commit comments