-
Notifications
You must be signed in to change notification settings - Fork 14
fix(agent): reduce unnecessary subagent dispatch #388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,23 @@ | ||
| Launch a new agent to handle complex, multistep tasks autonomously. | ||
| Launch a new agent to handle a self-contained task autonomously when doing so is clearly more efficient than direct tool calls in the current thread. | ||
|
|
||
| When using the agent tool, you must specify a subagent_type parameter to select which agent type to use. | ||
|
|
||
| When to use the agent tool: | ||
| - When you are instructed to execute custom slash commands. Use the agent tool with the slash command invocation as the entire prompt. The slash command can take arguments. For example: Agent(description="Check the file", prompt="/check-file path/to/file.py") | ||
| - When one broad, independent investigation can be delegated and summarized without requiring continuous parent judgment. | ||
| - When multiple hypotheses are genuinely independent and parallel investigation will reduce latency; each subagent should have a distinct scope and stopping condition. | ||
|
|
||
| When NOT to use the agent tool: | ||
| - If you want to read a specific file path, use the Read or Glob 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 Glob 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 Read tool instead of the agent tool, to find the match more quickly | ||
| - If you are checking package scripts, test setup, config files, or another small known area, inspect it directly in the current thread | ||
| - If you are debugging a bug and already have a plausible next file or command to inspect, continue directly instead of delegating that single step | ||
| - Other tasks that are not related to the available agents | ||
|
|
||
|
|
||
| Usage notes: | ||
| 1. 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. The output includes a subagent_session_id you can reuse later to continue the same subagent session. | ||
| 2. Each agent invocation starts with a fresh context unless you provide subagent_session_id to resume the same subagent session (which continues with its previous messages and tool outputs). When starting fresh, 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. | ||
| 2. Each agent invocation starts with a fresh context unless you provide subagent_session_id to resume the same subagent session (which continues with its previous messages and tool outputs). When starting fresh, your prompt should be specific and bounded: state the goal, relevant paths or keywords, what to ignore, and exactly what information the agent should return in its final and only message. | ||
| 3. 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). | ||
| 4. If the proactive trigger applies to the available agents, you should try your best to use it without the user having to ask for it first. Use your judgement. | ||
| 4. Do not use this tool just because an agent is available. Prefer the current thread for small or sequential work; use agent only when it has a clear advantage. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.