@@ -328,18 +328,12 @@ export async function executeAgent({
328328 isOnlyChild ?: boolean
329329 clearUserPromptMessagesAfterResponse ?: boolean
330330} ) {
331- const width = 60
332- const fullAgentName = `${ agentTemplate . displayName } (${ agentTemplate . id } )`
333- const dashesLength = Math . max (
334- 0 ,
335- Math . floor ( ( width - fullAgentName . length - 2 ) / 2 ) ,
336- )
337- const dashes = '-' . repeat ( dashesLength )
338-
339- // Send agent start notification if this is the only child
340- if ( isOnlyChild ) {
341- onResponseChunk ( `\n\n${ dashes } ${ fullAgentName } ${ dashes } \n\n` )
342- }
331+ onResponseChunk ( {
332+ type : 'subagent_start' ,
333+ agentId : agentTemplate . id ,
334+ displayName : agentTemplate . displayName ,
335+ onlyChild : isOnlyChild ,
336+ } )
343337
344338 // Import loopAgentSteps dynamically to avoid circular dependency
345339 const { loopAgentSteps } = await import ( '../../../run-agent-step' )
@@ -360,18 +354,12 @@ export async function executeAgent({
360354 clearUserPromptMessagesAfterResponse,
361355 } )
362356
363- // Send agent end notification if this is the only child
364- if ( isOnlyChild ) {
365- const endedFullAgentName = `Completed: ${ fullAgentName } `
366- const dashesLength = Math . max (
367- 0 ,
368- Math . floor ( ( width - endedFullAgentName . length - 2 ) / 2 ) ,
369- )
370- const dashesForEndedAgent = '-' . repeat ( dashesLength )
371- onResponseChunk (
372- `\n\n${ dashesForEndedAgent } ${ endedFullAgentName } ${ dashesForEndedAgent } \n\n` ,
373- )
374- }
357+ onResponseChunk ( {
358+ type : 'subagent_finish' ,
359+ agentId : agentTemplate . id ,
360+ displayName : agentTemplate . displayName ,
361+ onlyChild : isOnlyChild ,
362+ } )
375363
376364 if ( result . agentState . runId ) {
377365 parentAgentState . childRunIds . push ( result . agentState . runId )
0 commit comments