Skip to content

Commit f31ddc8

Browse files
committed
Revert "Include a system message that an agent was spawned (since the spawn tool call is no longer included)"
This reverts commit fda79bb.
1 parent de51c93 commit f31ddc8

File tree

2 files changed

+4
-23
lines changed

2 files changed

+4
-23
lines changed

.agents/context-pruner.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,6 @@ const definition: AgentDefinition = {
172172
if (lastInstructionsPromptIndex !== -1) {
173173
currentMessages.splice(lastInstructionsPromptIndex, 1)
174174
}
175-
const lastSubagentSpawnIndex = currentMessages.findLastIndex((message) =>
176-
message.tags?.includes('SUBAGENT_SPAWN'),
177-
)
178-
if (lastSubagentSpawnIndex !== -1) {
179-
currentMessages.splice(lastSubagentSpawnIndex, 1)
180-
}
181175

182176
// Initial check - if already under limit, return
183177
const initialTokens = countMessagesTokens(currentMessages)

packages/agent-runtime/src/tools/handlers/tool/spawn-agent-utils.ts

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { generateCompactId } from '@codebuff/common/util/string'
44

55
import { loopAgentSteps } from '../../../run-agent-step'
66
import { getAgentTemplate } from '../../../templates/agent-registry'
7-
import { filterUnfinishedToolCalls, withSystemTags } from '../../../util/messages'
7+
import { filterUnfinishedToolCalls } from '../../../util/messages'
88

99
import type { AgentTemplate } from '@codebuff/common/types/agent-template'
1010
import 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

Comments
 (0)