@@ -21,7 +21,7 @@ export async function agentWorkflow({
2121
2222 let openaiChatMessages : any [ ] = [ ] ;
2323
24- // Get tools definition and start conversation
24+ // Get tools definition and start conversation.
2525
2626 const tools = await step < typeof functions > ( {
2727 taskQueue : "erp" ,
@@ -40,7 +40,7 @@ export async function agentWorkflow({
4040 openaiChatMessages = initialMessages . messages ;
4141 }
4242
43- // Send reply to AI chat with previous messages to continue conversation
43+ // On user reply, send it to AI chat with previous messages to continue conversation.
4444
4545 onEvent ( replyEvent , async ( { streamSid, text } : Reply ) => {
4646 const replyMessage = await step < typeof functions > ( {
@@ -60,7 +60,7 @@ export async function agentWorkflow({
6060 return { text } ;
6161 } ) ;
6262
63- // When AI answer is a tool call, execute function and push results to conversation
63+ // When AI answer is a tool call, execute function and push results to conversation.
6464
6565 onEvent ( toolCallEvent , async ( { function : toolFunction } : ToolCall ) => {
6666 log . info ( "toolCallEvent" , { toolFunction } ) ;
@@ -107,9 +107,10 @@ export async function agentWorkflow({
107107 return { function : toolFunction } ;
108108 } ) ;
109109
110+ // Terminate AI agent workflow.
111+
110112 let ended = false ;
111113 onEvent ( agentEnd , async ( ) => {
112- // Terminate AI agent workflow
113114 log . info ( `agentEnd received` ) ;
114115 ended = true ;
115116 } ) ;
0 commit comments