@@ -142,25 +142,6 @@ export async function formatPrompt(
142142}
143143type StringField = 'systemPrompt' | 'instructionsPrompt' | 'stepPrompt'
144144
145- export async function collectParentInstructions ( params : {
146- agentType : string
147- agentTemplates : Record < string , AgentTemplate >
148- } ) : Promise < string [ ] > {
149- const { agentType, agentTemplates } = params
150- const instructions : string [ ] = [ ]
151-
152- for ( const template of Object . values ( agentTemplates ) ) {
153- if ( template . parentInstructions ) {
154- const instruction = template . parentInstructions [ agentType ]
155- if ( instruction ) {
156- instructions . push ( instruction )
157- }
158- }
159- }
160-
161- return instructions
162- }
163-
164145const additionalPlaceholders = {
165146 systemPrompt : [ PLACEHOLDER . TOOLS_PROMPT , PLACEHOLDER . AGENTS_PROMPT ] ,
166147 instructionsPrompt : [ ] ,
@@ -189,11 +170,9 @@ export async function getAgentPrompt<T extends StringField>(
189170 const {
190171 agentTemplate,
191172 promptType,
192- fileContext,
193173 agentState,
194174 agentTemplates,
195175 additionalToolDefinitions,
196- logger,
197176 } = params
198177
199178 let promptValue = agentTemplate [ promptType . type ]
@@ -203,21 +182,13 @@ export async function getAgentPrompt<T extends StringField>(
203182 }
204183 }
205184
206- if ( promptValue === undefined ) {
207- return undefined
208- }
209-
210185 let prompt = await formatPrompt ( {
211186 ...params ,
212187 prompt : promptValue ,
213188 tools : agentTemplate . toolNames ,
214189 spawnableAgents : agentTemplate . spawnableAgents ,
215190 } )
216191
217- if ( prompt . trim ( ) === '' ) {
218- return undefined
219- }
220-
221192 let addendum = ''
222193
223194 if ( promptType . type === 'stepPrompt' && agentState . agentType && prompt ) {
@@ -227,36 +198,21 @@ export async function getAgentPrompt<T extends StringField>(
227198
228199 // Add tool instructions, spawnable agents, and output schema prompts to instructionsPrompt
229200 if ( promptType . type === 'instructionsPrompt' && agentState . agentType ) {
230- const hasTools = agentTemplate . toolNames . length > 0
231201 const toolsInstructions = agentTemplate . inheritParentSystemPrompt
232202 ? fullToolList ( agentTemplate . toolNames , await additionalToolDefinitions ( ) )
233203 : getShortToolInstructions (
234204 agentTemplate . toolNames ,
235205 await additionalToolDefinitions ( ) ,
236206 )
237- const hasSpawnableAgents = agentTemplate . spawnableAgents . length > 0
238207 addendum +=
239- ( hasTools ? '\n\n' + toolsInstructions : '' ) +
240- ( hasSpawnableAgents
241- ? '\n\n' +
242- ( await buildSpawnableAgentsDescription ( {
243- ...params ,
244- spawnableAgents : agentTemplate . spawnableAgents ,
245- agentTemplates,
246- } ) )
247- : '' )
248-
249- const parentInstructions = await collectParentInstructions ( {
250- agentType : agentState . agentType ,
251- agentTemplates,
252- } )
253-
254- if ( parentInstructions . length > 0 ) {
255- addendum += '\n\n## Additional Instructions for Spawning Agents\n\n'
256- addendum += parentInstructions
257- . map ( ( instruction ) => `- ${ instruction } ` )
258- . join ( '\n' )
259- }
208+ '\n\n' +
209+ toolsInstructions +
210+ '\n\n' +
211+ ( await buildSpawnableAgentsDescription ( {
212+ ...params ,
213+ spawnableAgents : agentTemplate . spawnableAgents ,
214+ agentTemplates,
215+ } ) )
260216
261217 // Add output schema information if defined
262218 if ( agentTemplate . outputSchema ) {
@@ -283,5 +239,10 @@ export async function getAgentPrompt<T extends StringField>(
283239 }
284240 }
285241
286- return prompt + addendum
242+ const combinedPrompt = ( prompt + addendum ) . trim ( )
243+ if ( combinedPrompt === '' ) {
244+ return undefined
245+ }
246+
247+ return combinedPrompt
287248}
0 commit comments