Skip to content

Commit 0efc1d7

Browse files
committed
Stream child outputs if only child. Use labeled dividers
1 parent 454cc1f commit 0efc1d7

File tree

4 files changed

+33
-11
lines changed

4 files changed

+33
-11
lines changed

backend/src/run-programmatic-step.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ export async function runProgrammaticStep(
196196
toolCall.toolName,
197197
toolCall.input,
198198
)
199+
onResponseChunk(toolCallString)
199200
state.messages.push({
200201
role: 'assistant' as const,
201202
content: toolCallString,

backend/src/tools/handlers/tool/spawn-agent-inline.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,11 @@ export const handleSpawnAgentInline = ((params: {
105105
localAgentTemplates,
106106
userId,
107107
clientSessionId,
108-
// Inherits parent's onResponseChunk
109-
onResponseChunk: writeToClient,
108+
onResponseChunk: (chunk) => {
109+
// Disabled.
110+
// Inherits parent's onResponseChunk
111+
// writeToClient(chunk)
112+
},
110113
})
111114

112115
// Update parent's message history with child's final state

backend/src/tools/handlers/tool/spawn-agent-utils.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ export async function executeAgent({
301301
userId,
302302
clientSessionId,
303303
onResponseChunk,
304+
isOnlyChild = false,
304305
}: {
305306
ws: WebSocket
306307
userInputId: string
@@ -314,11 +315,21 @@ export async function executeAgent({
314315
userId?: string
315316
clientSessionId: string
316317
onResponseChunk: (chunk: string | PrintModeEvent) => void
318+
isOnlyChild?: boolean
317319
}) {
320+
const width = 60
321+
const fullAgentName = `${agentTemplate.displayName} (${agentTemplate.id})`
322+
const dashes = '-'.repeat(Math.floor((width - fullAgentName.length - 2) / 2))
323+
324+
// Send agent start notification if this is the only child
325+
if (isOnlyChild) {
326+
onResponseChunk(`\n\n${dashes} ${fullAgentName} ${dashes}\n\n`)
327+
}
328+
318329
// Import loopAgentSteps dynamically to avoid circular dependency
319330
const { loopAgentSteps } = await import('../../../run-agent-step')
320331

321-
return await loopAgentSteps(ws, {
332+
const result = await loopAgentSteps(ws, {
322333
userInputId,
323334
prompt,
324335
params,
@@ -332,6 +343,19 @@ export async function executeAgent({
332343
clientSessionId,
333344
onResponseChunk,
334345
})
346+
347+
// Send agent end notification if this is the only child
348+
if (isOnlyChild) {
349+
const endedFullAgentName = `Completed: ${fullAgentName}`
350+
const dashesForEndedAgent = '-'.repeat(
351+
Math.floor(width - endedFullAgentName.length - 2) / 2,
352+
)
353+
onResponseChunk(
354+
`\n\n${dashesForEndedAgent} ${endedFullAgentName} ${dashesForEndedAgent}\n\n`,
355+
)
356+
}
357+
358+
return result
335359
}
336360

337361
/**

backend/src/tools/handlers/tool/spawn-agents.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,9 @@ export const handleSpawnAgents = ((params: {
127127
localAgentTemplates,
128128
userId,
129129
clientSessionId,
130+
isOnlyChild: agents.length === 1,
130131
onResponseChunk: (chunk: string | PrintModeEvent) => {
131-
const agentsThatShouldStreamToClient = [
132-
'editor',
133-
'editor-gpt-5-high',
134-
]
135-
if (
136-
agents.length === 1 &&
137-
agentsThatShouldStreamToClient.includes(agents[0].agent_type)
138-
) {
132+
if (agents.length === 1) {
139133
writeToClient(chunk)
140134
}
141135
if (typeof chunk !== 'string') {

0 commit comments

Comments
 (0)