Skip to content

Commit daef202

Browse files
committed
Optimize task tool prompt
1 parent 2f7ed2f commit daef202

1 file changed

Lines changed: 2 additions & 41 deletions

File tree

packages/opencode/src/tool/task.txt

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@ Launch a new agent to handle complex, multistep tasks autonomously.
22

33
When using the Task tool, you must specify a subagent_type parameter to select which agent type to use.
44

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-
85
When NOT to use the Task tool:
96
- 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
10-
- If you are searching for a specific class definition like "class Foo", use the Glob tool instead, to find the match more quickly
7+
- If you are searching for a specific class definition like "class Foo", use the Grep tool instead, to find the match more quickly
118
- 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
12-
- Other tasks that are not related to the agent descriptions above
9+
- If no available agent is a good fit for the task, use other tools directly
1310

1411

1512
Usage notes:
@@ -19,39 +16,3 @@ Usage notes:
1916
4. The agent's outputs should generally be trusted
2017
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. Tell it how to verify its work if possible (e.g., relevant test commands).
2118
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.
22-
23-
Example usage (NOTE: The agents below are fictional examples for illustration only - use the actual agents listed above):
24-
25-
<example_agent_descriptions>
26-
"code-reviewer": use this agent after you are done writing a significant piece of code
27-
"greeting-responder": use this agent when to respond to user greetings with a friendly joke
28-
</example_agent_description>
29-
30-
<example>
31-
user: "Please write a function that checks if a number is prime"
32-
assistant: Sure let me write a function that checks if a number is prime
33-
assistant: First let me use the Write tool to write a function that checks if a number is prime
34-
assistant: I'm going to use the Write tool to write the following code:
35-
<code>
36-
function isPrime(n) {
37-
if (n <= 1) return false
38-
for (let i = 2; i * i <= n; i++) {
39-
if (n % i === 0) return false
40-
}
41-
return true
42-
}
43-
</code>
44-
<commentary>
45-
Since a significant piece of code was written and the task was completed, now use the code-reviewer agent to review the code
46-
</commentary>
47-
assistant: Now let me use the code-reviewer agent to review the code
48-
assistant: Uses the Task tool to launch the code-reviewer agent
49-
</example>
50-
51-
<example>
52-
user: "Hello"
53-
<commentary>
54-
Since the user is greeting, use the greeting-responder agent to respond with a friendly joke
55-
</commentary>
56-
assistant: "I'm going to use the Task tool to launch the with the greeting-responder agent"
57-
</example>

0 commit comments

Comments
 (0)