task.txt 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. Launch a new agent to handle complex, multi-step tasks autonomously.
  2. Available agent types and the tools they have access to:
  3. {agents}
  4. When using the Task tool, you must specify a subagent_type parameter to select which agent type to use.
  5. When to use the Task tool:
  6. - When you are instructed to execute custom slash commands. Use the Task tool with the slash command invocation as the entire prompt. The slash command can take arguments. For example: Task(description="Check the file", prompt="/check-file path/to/file.py")
  7. When NOT to use the Task tool:
  8. - If you want to read a specific file path, use the Read or Glob tool instead of the Task tool, to find the match more quickly
  9. - If you are searching for a specific class definition like "class Foo", use the Glob tool instead, to find the match more quickly
  10. - If you are searching for code within a specific file or set of 2-3 files, use the Read tool instead of the Task tool, to find the match more quickly
  11. - Other tasks that are not related to the agent descriptions above
  12. Usage notes:
  13. 1. Launch multiple agents concurrently whenever possible, to maximize performance; to do that, use a single message with multiple tool uses
  14. 2. 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.
  15. 3. Each agent invocation is stateless unless you provide a session_id. 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.
  16. 4. The agent's outputs should generally be trusted
  17. 5. 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
  18. 6. 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.
  19. Example usage (NOTE: The agents below are fictional examples for illustration only - use the actual agents listed above):
  20. <example_agent_descriptions>
  21. "code-reviewer": use this agent after you are done writing a significant piece of code
  22. "greeting-responder": use this agent when to respond to user greetings with a friendly joke
  23. </example_agent_description>
  24. <example>
  25. user: "Please write a function that checks if a number is prime"
  26. assistant: Sure let me write a function that checks if a number is prime
  27. assistant: First let me use the Write tool to write a function that checks if a number is prime
  28. assistant: I'm going to use the Write tool to write the following code:
  29. <code>
  30. function isPrime(n) {
  31. if (n <= 1) return false
  32. for (let i = 2; i * i <= n; i++) {
  33. if (n % i === 0) return false
  34. }
  35. return true
  36. }
  37. </code>
  38. <commentary>
  39. Since a significant piece of code was written and the task was completed, now use the code-reviewer agent to review the code
  40. </commentary>
  41. assistant: Now let me use the code-reviewer agent to review the code
  42. assistant: Uses the Task tool to launch the code-reviewer agent
  43. </example>
  44. <example>
  45. user: "Hello"
  46. <commentary>
  47. Since the user is greeting, use the greeting-responder agent to respond with a friendly joke
  48. </commentary>
  49. assistant: "I'm going to use the Task tool to launch the with the greeting-responder agent"
  50. </example>