Skip to content

Commit 7fcc8d5

Browse files
committed
inline agent inherits onReponseChunk
1 parent 8afbc3c commit 7fcc8d5

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

backend/src/run-programmatic-step.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ export async function runProgrammaticStep(
200200
role: 'assistant' as const,
201201
content: toolCallString,
202202
})
203-
onResponseChunk(toolCallString)
204203
state.sendSubagentChunk({
205204
userInputId,
206205
agentId: agentState.agentId,

backend/src/tools/handlers/handler-function-type.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type {
44
ClientToolName,
55
CodebuffToolCall,
66
} from '@codebuff/common/tools/list'
7+
import { PrintModeEvent } from '@codebuff/common/types/print-mode'
78
import type { ProjectFileContext } from '@codebuff/common/util/file'
89

910
type PresentOrAbsent<K extends PropertyKey, V> =
@@ -22,7 +23,7 @@ export type CodebuffToolHandlerFunction<T extends ToolName = ToolName> = (
2223

2324
fullResponse: string
2425

25-
writeToClient: (chunk: string) => void
26+
writeToClient: (chunk: string | PrintModeEvent) => void
2627

2728
getLatestState: () => any
2829
state: { [K in string]?: any }

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
executeAgent,
77
} from './spawn-agent-utils'
88
import { MAX_AGENT_STEPS_DEFAULT } from '@codebuff/common/constants/agents'
9-
import { expireMessages } from '../../../util/messages'
109

1110
import type { CodebuffToolHandlerFunction } from '../handler-function-type'
1211
import type { CodebuffToolCall } from '@codebuff/common/tools/list'
@@ -24,6 +23,7 @@ export const handleSpawnAgentInline = ((params: {
2423
fileContext: ProjectFileContext
2524
clientSessionId: string
2625
userInputId: string
26+
writeToClient: (chunk: string | PrintModeEvent) => void
2727

2828
getLatestState: () => { messages: CodebuffMessage[] }
2929
state: {
@@ -44,6 +44,7 @@ export const handleSpawnAgentInline = ((params: {
4444
userInputId,
4545
getLatestState,
4646
state,
47+
writeToClient,
4748
} = params
4849
const {
4950
agent_type: agentTypeStr,
@@ -102,10 +103,8 @@ export const handleSpawnAgentInline = ((params: {
102103
localAgentTemplates,
103104
userId,
104105
clientSessionId,
105-
onResponseChunk: (chunk: string | PrintModeEvent) => {
106-
// Child agent output is streamed directly to parent's output
107-
// No need for special handling since we share message history
108-
},
106+
// Inherits parent's onResponseChunk
107+
onResponseChunk: writeToClient,
109108
})
110109

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

0 commit comments

Comments
 (0)