@@ -4,7 +4,7 @@ import { generateCompactId } from '@codebuff/common/util/string'
44
55import { loopAgentSteps } from '../../../run-agent-step'
66import { getAgentTemplate } from '../../../templates/agent-registry'
7- import { filterUnfinishedToolCalls , withSystemTags } from '../../../util/messages'
7+ import { filterUnfinishedToolCalls } from '../../../util/messages'
88
99import type { AgentTemplate } from '@codebuff/common/types/agent-template'
1010import type { Logger } from '@codebuff/common/types/contracts/logger'
@@ -19,7 +19,6 @@ import type {
1919 AgentTemplateType ,
2020 Subgoal ,
2121} from '@codebuff/common/types/session-state'
22- import { Message } from '@codebuff/common/types/messages/codebuff-message'
2322
2423/**
2524 * Checks if a parent agent is allowed to spawn a child agent
@@ -167,21 +166,9 @@ export function createAgentState(
167166 // When including message history, filter out any tool calls that don't have
168167 // corresponding tool responses. This prevents the spawned agent from seeing
169168 // unfinished tool calls which throw errors in the Anthropic API.
170- let messageHistory : Message [ ] = [ ]
171-
172- if ( agentTemplate . includeMessageHistory ) {
173- messageHistory = filterUnfinishedToolCalls ( parentAgentState . messageHistory )
174- messageHistory . push ( {
175- role : 'user' ,
176- content : [
177- {
178- type : 'text' ,
179- text : withSystemTags ( `Subagent ${ agentType } has been spawned.` ) ,
180- } ,
181- ] ,
182- tags : [ 'SUBAGENT_SPAWN' ] ,
183- } )
184- }
169+ const messageHistory = agentTemplate . includeMessageHistory
170+ ? filterUnfinishedToolCalls ( parentAgentState . messageHistory )
171+ : [ ]
185172
186173 return {
187174 agentId,
0 commit comments