@@ -27,41 +27,57 @@ interface ToolDetails {
2727
2828class Agent {
2929 private tools : any [ ] ;
30- private subAgents : any [ ] ;
30+ // private subAgents: any[];
3131 private apiConversationHistory : Message [ ] ;
3232 private maxRun : number ;
3333 private systemPrompt : SystemPrompt ;
3434 private userMessage : Message [ ] ;
3535 private nextUserMessage :any ;
3636
3737
38- constructor ( tools : any = [ ] , systemPrompt : SystemPrompt , maxRun : number = 0 , subAgents : any [ ] = [ ] ) {
38+ constructor ( tools : any = [ ] , systemPrompt : SystemPrompt , maxRun : number = 0 ) {
3939 this . tools = tools ;
4040 this . userMessage = [ ] ;
4141 this . apiConversationHistory = [ ] ;
4242 this . maxRun = maxRun ;
4343 this . systemPrompt = systemPrompt ;
44- this . subAgents = subAgents ;
45- this . subAgents = subAgents . map ( subagent => {
46- subagent . function . name = `subagent--${ subagent . function . name } ` ;
47- return subagent ;
48- } ) ;
49- this . tools = this . tools . concat ( subAgents . map ( subagent => ( {
50- ...subagent
51- } ) ) ) ;
52-
53-
5444
5545 }
5646
5747 async run ( task : TaskInstruction , successCondition : ( ) => boolean = ( ) => true ) : Promise < { success : boolean ; error : string | null , message : string | null } > {
5848
5949
6050 let mentaionedMCPSTool : any [ ] = await task . userMessage . getMentionedMcpsTools ( ) ;
51+
6152 this . tools = [
6253 ...this . tools ,
63- ...mentaionedMCPSTool
54+ ...mentaionedMCPSTool ,
55+
6456 ]
57+ let mentionedAgents = await task . userMessage . getMentionedAgents ( ) ;
58+
59+ // Transform agents into tool format
60+ const agentTools = mentionedAgents . map ( agent => {
61+ return {
62+ type : "function" ,
63+ function : {
64+ name : `subagent--${ agent . unique_id } ` ,
65+ description : agent . longDescription || agent . description ,
66+ parameters : {
67+ type : "object" ,
68+ properties : {
69+ task : {
70+ type : "string" ,
71+ description : "The task to be executed by the tool."
72+ }
73+ } ,
74+ required : [ "task" ]
75+ }
76+ }
77+ } ;
78+ } ) ;
79+
80+ this . tools = this . tools . concat ( agentTools ) ;
6581
6682
6783 let completed = false ;
0 commit comments