You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: common/src/tools/params/tool/spawn-agents.ts
+5-1Lines changed: 5 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -31,10 +31,14 @@ const inputSchema = z
31
31
`Spawn multiple agents and send a prompt and/or parameters to each of them. These agents will run in parallel. Note that that means they will run independently. If you need to run agents sequentially, use spawn_agents with one agent at a time instead.`,
32
32
)
33
33
constdescription=`
34
-
Use this tool to spawn agents to help you complete the user request. Each agent has specific requirements for prompt and params based on their inputSchema.
34
+
Use this tool to spawn agents to help you complete the user request. Each agent has specific requirements for prompt and params based on their tools schema.
35
35
36
36
The prompt field is a simple string, while params is a JSON object that gets validated against the agent's schema.
37
37
38
+
Each agent available is already defined as another tool, or, dynamically defined later in the conversation.
39
+
40
+
You can call agents either as direct tool calls (e.g., \`example-agent\`) or use \`spawn_agents\`. Both formats work, but **prefer using spawn_agents** because it allows you to spawn multiple agents in parallel for better performance. When using direct tool calls, the schema is flat (prompt is a field alongside other params), whereas spawn_agents uses nested \`prompt\` and \`params\` fields.
Use the spawn_agents tool to spawn agents to help you complete the user request.
70
-
71
-
Notes:
72
-
- You can not call the agents as tool names directly: you must use the spawn_agents tool with the correct parameters to spawn them!
73
-
- There are two types of input arguments for agents: prompt and params. The prompt is a string, and the params is a json object. Some agents require only one or the other, some require both, and some require none.
74
-
- Below are the *only* available agents by their agent_type. Other agents may be referenced earlier in the conversation, but they are not available to you.
75
-
76
-
Spawn only the below agents:
171
+
return`You are a subagent that can only spawn the following agents using the spawn_agents tool:
// Add subagent tools message when using parent's tools for prompt caching
204
192
if(useParentTools){
205
-
addendum+=
206
-
`\n\nYou are a subagent that only has access to the following tools: ${agentTemplate.toolNames.join(', ')}. Do not attempt to use any other tools.`
193
+
addendum+=`\n\nYou are a subagent that only has access to the following tools: ${agentTemplate.toolNames.join(', ')}. Do not attempt to use any other tools.`
194
+
195
+
// For subagents with inheritSystemPrompt, include full spawnable agents spec
196
+
// since the parent's system prompt may not have these agents listed
197
+
if(agentTemplate.spawnableAgents.length>0){
198
+
addendum+=
199
+
'\n\n'+
200
+
(awaitbuildFullSpawnableAgentsSpec({
201
+
...params,
202
+
spawnableAgents: agentTemplate.spawnableAgents,
203
+
agentTemplates,
204
+
}))
205
+
}
206
+
}elseif(agentTemplate.spawnableAgents.length>0){
207
+
// For non-inherited tools, agents are already defined as tools with full schemas,
208
+
// so we just list the available agent IDs here
209
+
addendum+=`\n\nYou can spawn the following agents: ${agentTemplate.spawnableAgents.join(', ')}.`
0 commit comments