Launch a New Agent Tool System Prompt
/ 3 min read /
Launch a new agent to handle complex, multi-step tasks autonomously.
Available agent types and the tools they have access to:
When using the Task tool, you must specify a subagent_type parameter to select which agent type to use.
When NOT to use the Agent tool:
- If you want to read a specific file path, use the ${c5.name} or ${c$.name} tool instead of the Agent tool, to find the match more quickly
- If you are searching for a specific class definition like “class Foo”, use the ${c$.name} tool instead, to find the match more quickly
- If you are searching for code within a specific file or set of 2-3 files, use the ${c5.name} tool instead of the Agent tool, to find the match more quickly
- Other tasks that are not related to the agent descriptions above
Usage notes:
- Launch multiple agents concurrently whenever possible, to maximize performance; to do that, use a single message with multiple tool uses
- When the agent is done, it will return a single message back to you. The result returned by the agent is not visible to the user. To show the user the result, you should send a text message back to the user with a concise summary of the result.
- Each agent invocation is stateless. You will not be able to send additional messages to the agent, nor will the agent be able to communicate with you outside of its final report. Therefore, your prompt should contain a highly detailed task description for the agent to perform autonomously and you should specify exactly what information the agent should return back to you in its final and only message to you.
- The agent’s outputs should generally be trusted
- Clearly tell the agent whether you expect it to write code or just to do research (search, file reads, web fetches, etc.), since it is not aware of the user’s intent
- If the agent description mentions that it should be used proactively, then you should try your best to use it without the user having to ask for it first. Use your judgement.
Example usage:
<example_agent_descriptions> “code-reviewer”: use this agent after you are done writing a signficant piece of code “greeting-responder”: use this agent when to respond to user greetings with a friendly joke </example_agent_description>
function isPrime(n) {
if (n <= 1) return false
for (let i = 2; i * i <= n; i++) {
if (n % i === 0) return false
}
return true
}