@@ -4,10 +4,7 @@ import {
44 getSystemInfoPrompt ,
55} from '../system-prompt/prompts'
66import { getAgentTemplate } from './agent-registry'
7- import {
8- PLACEHOLDER ,
9- placeholderValues ,
10- } from './types'
7+ import { PLACEHOLDER , placeholderValues } from './types'
118import { parseUserMessage } from '../util/messages'
129import { CodebuffConfigSchema } from '@codebuff/common/json-config/constants'
1310import { escapeString } from '@codebuff/common/util/string'
@@ -21,10 +18,7 @@ import {
2118 getToolsInstructions ,
2219} from '../tools/prompts'
2320
24- import type {
25- AgentTemplate ,
26- PlaceholderValue ,
27- } from './types'
21+ import type { AgentTemplate , PlaceholderValue } from './types'
2822import type { Logger } from '@codebuff/common/types/contracts/logger'
2923import type { ParamsExcluding } from '@codebuff/common/types/function-params'
3024import type {
@@ -229,21 +223,24 @@ export async function getAgentPrompt<T extends StringField>(
229223
230224 // Add tool instructions, spawnable agents, and output schema prompts to instructionsPrompt
231225 if ( promptType . type === 'instructionsPrompt' && agentState . agentType ) {
226+ const hasTools = agentTemplate . toolNames . length > 0
232227 const toolsInstructions = agentTemplate . inheritParentSystemPrompt
233228 ? fullToolList ( agentTemplate . toolNames , await additionalToolDefinitions ( ) )
234229 : getShortToolInstructions (
235230 agentTemplate . toolNames ,
236231 await additionalToolDefinitions ( ) ,
237232 )
233+ const hasSpawnableAgents = agentTemplate . spawnableAgents . length > 0
238234 addendum +=
239- '\n\n' +
240- toolsInstructions +
241- '\n\n' +
242- ( await buildSpawnableAgentsDescription ( {
243- ...params ,
244- spawnableAgents : agentTemplate . spawnableAgents ,
245- agentTemplates,
246- } ) )
235+ ( hasTools ? '\n\n' + toolsInstructions : '' ) +
236+ ( hasSpawnableAgents
237+ ? '\n\n' +
238+ ( await buildSpawnableAgentsDescription ( {
239+ ...params ,
240+ spawnableAgents : agentTemplate . spawnableAgents ,
241+ agentTemplates,
242+ } ) )
243+ : '' )
247244
248245 const parentInstructions = await collectParentInstructions ( {
249246 agentType : agentState . agentType ,
0 commit comments