File tree Expand file tree Collapse file tree 3 files changed +5
-7
lines changed
Expand file tree Collapse file tree 3 files changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -316,7 +316,7 @@ export class MagmaAgent {
316316 } ) ,
317317 tools : Object . fromEntries (
318318 this . tools
319- . filter ( ( t ) => t . enabled ( this ) )
319+ . filter ( ( t ) => t . enabled ( this , ctx ) )
320320 . map ( ( t ) => [ t . name , convertMagmaToolToAISDKTool ( t ) ] )
321321 ) ,
322322 messages : [ ...this . getSystemPrompts ( ctx ) , ...completionMessages ] ,
@@ -623,14 +623,12 @@ export class MagmaAgent {
623623 */
624624 private async executeTools ( {
625625 message,
626- allowList = [ ] ,
627626 trace,
628627 requestId,
629628 send,
630629 ctx,
631630 } : {
632631 message : AssistantModelMessage ;
633- allowList ?: string [ ] ;
634632 trace : TraceEvent [ ] ;
635633 requestId : string ;
636634 send : MagmaSendFunction ;
@@ -653,7 +651,7 @@ export class MagmaAgent {
653651
654652 try {
655653 const tool = this . tools
656- . filter ( ( t ) => t . enabled ( this ) || allowList . includes ( t . name ) )
654+ . filter ( ( t ) => t . enabled ( this , ctx ) )
657655 . find ( ( t ) => t . name === toolCall . toolName ) ;
658656 if ( ! tool )
659657 throw new Error ( `No tool found to handle call for ${ toolCall . toolName } ()` ) ;
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ export function tool(args?: {
2121 name ?: string ;
2222 description ?: string ;
2323 cache ?: boolean ;
24- enabled ?: ( agent : MagmaAgent ) => boolean ;
24+ enabled ?: ( agent : MagmaAgent , ctx : Record < string , any > ) => boolean ;
2525} ) {
2626 return function < R extends MagmaToolReturnType | Promise < MagmaToolReturnType > > (
2727 target : object ,
@@ -32,7 +32,7 @@ export function tool(args?: {
3232 name ?: string ;
3333 description ?: string ;
3434 cache ?: boolean ;
35- enabled ?: ( agent : MagmaAgent ) => boolean ;
35+ enabled ?: ( agent : MagmaAgent , ctx : Record < string , any > ) => boolean ;
3636 } ;
3737 }
3838 >
Original file line number Diff line number Diff line change @@ -54,6 +54,6 @@ export type MagmaTool = {
5454 description : string ;
5555 params : MagmaToolObjectParam [ 'properties' ] ;
5656 target : MagmaToolTarget ;
57- enabled : ( agent : MagmaAgent ) => boolean ;
57+ enabled : ( agent : MagmaAgent , ctx : Record < string , any > ) => boolean ;
5858 cache ?: boolean ;
5959} ;
You can’t perform that action at this time.
0 commit comments