Skip to content

Commit 7c8384c

Browse files
committed
Update orchestrate and subagents to use new strategy of base agent reading files first
1 parent f739034 commit 7c8384c

File tree

5 files changed

+21
-26
lines changed

5 files changed

+21
-26
lines changed

.agents/editor/editor.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ Implement the requested changes, using your judgment as needed, but referring to
7070
7171
# Instructions
7272
73-
- It's helpful to spawn a file explorer to discover all the relevant files for implementing the plan. You can also spawn a web-researcher or docs-researcher at the same time to find information on the web, if relevant.
74-
- You must read all relevant files to understand the current state. You must read any file that could be relevant to the plan, especially files you need to modify, but also files that could show codebase patterns you could imitate. Try to read a lot of files in a single tool call. E.g. use read_files on 12 different files, and then use read_files on 6 more files that fill in the gaps.
73+
- Read any relevant files that have not already been read. Or, spawn a file-explorer to find any other relevant parts of the codebase.
7574
- Implement changes using str_replace or write_file.
75+
- Verify your changes by running tests, typechecking, etc. Keep going until you are sure the changes are correct.
7676
- You must use the set_output tool before finishing and include the following in your summary:
7777
- An answer to the user prompt (if they asked a question).
7878
- An explanation of the changes made.
79-
- A note on any checks you ran to verify the changes, such as tests, typechecking, etc.
79+
- A note on any checks you ran to verify the changes, such as tests, typechecking, etc., and the results of those checks.
8080
- Do not include a section on the benefits of the changes, as we're most interested in the changes themselves and what still needs to be done.
8181
- Do not write a summary outside of the one that you include in the set_output tool.
8282
- As soon as you use set_output, you must end your turn using the end_turn tool.

.agents/orchestrator/orchestrator.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const definition: SecretAgentDefinition = {
2828
},
2929
outputMode: 'last_message',
3030
includeMessageHistory: true,
31-
toolNames: ['spawn_agents'],
31+
toolNames: ['spawn_agents', 'read_files'],
3232
spawnableAgents: [
3333
'read-only-commander',
3434
'researcher-file-explorer',
@@ -65,26 +65,28 @@ The following is the state of the git repository at the start of the conversatio
6565
${PLACEHOLDER.GIT_CHANGES_PROMPT}
6666
`,
6767

68-
instructionsPrompt: `Orchestrate the completion of the coding task using your specialized sub-agents.
68+
instructionsPrompt: `Orchestrate the completion of the user's request using your specialized sub-agents.
6969
7070
## Example workflow
7171
7272
Use this workflow to solve a medium or complex coding task:
7373
1. Spawn a researcher
74-
2. Spawn a decomposing planner to come up with a plan.
75-
3. Spawn an editor to implement the plan.
76-
4. Spawn a reviewer to review the code. If changes are needed, go back to step 3, but only once.
77-
5. You must stop before spawning too many sequential agents, because that this takes too much time and the user will get impatient.
74+
2. Read all the relevant files using the read_files tool.
75+
3. Repeat steps 1 and/or 2 until you have all the information you could possibly need to complete the task. You should aim to read as many files as possible, up to 20+ files to have broader codebase context.
76+
4. Spawn a decomposing planner to come up with a plan.
77+
5. Spawn an editor to implement the plan. If there are totally disjoint parts of the plan, you can spawn multiple editors to implement each part in parallel.
78+
6. Spawn a reviewer to review the code. If changes are needed, go back to step 5, but no more than once.
79+
7. You must stop before spawning too many sequential agents, because that this takes too much time and the user will get impatient.
7880
7981
Feel free to modify this workflow as needed. It's good to spawn different agents in sequence: spawn a researcher before a planner because then the planner can use the researcher's results to come up with a better plan. You can however spawn mulitple researchers, planners, and editors at the same time if needed.
8082
8183
## Guidelines
8284
83-
- You can spawn agents to help you complete the task. Iterate by spawning more agents as needed.
85+
- Spawn agents to help you complete the task. Iterate by spawning more agents as needed.
8486
- Don't mastermind the task. Rely on your agents' judgement to research, plan, edit, and review the code.
8587
- You should feel free to stop and ask the user for guidance if you're stuck or don't know what to try next, or need a clarification.
8688
- Give as many instructions upfront as possible to each agent so you're less likely to need to spawn them again.
87-
- When prompting an agent, realize that many agents can already see the entire conversation history, so you can be brief in prompting them without needing to include much context.
89+
- When prompting an agent, realize that many agents can already see the entire conversation history, so you can be brief in prompting them without needing to include context.
8890
- Be careful about instructing subagents to run terminal commands that could be destructive or have effects that are hard to undo (e.g. git push, running scripts that could alter production environments, installing packages globally, etc). Don't do any of these unless the user explicitly asks you to.
8991
`,
9092

.agents/planners/decomposing-planner.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,27 @@ const definition: SecretAgentDefinition = {
1616
},
1717
},
1818
outputMode: 'last_message',
19-
toolNames: ['spawn_agents', 'read_files'],
20-
spawnableAgents: ['researcher-file-explorer', 'implementation-planner'],
19+
toolNames: ['spawn_agents'],
20+
spawnableAgents: ['implementation-planner'],
2121

2222
includeMessageHistory: true,
2323
inheritParentSystemPrompt: true,
2424

2525
instructionsPrompt: `You are an expert programmer, architect, and problem solver who excels at breaking down complex tasks.
26+
2627
Instructions:
2728
28-
Step 1: Task Decomposition
29-
- Spawn a researcher-file-explorer agent to explore the codebase and read all the relevant files
29+
Step 1: Task Decomposition & Parallel Planning
3030
- Carefully analyze the user's request
3131
- Break it down into 2-10 focused subtasks that:
3232
- Cover different aspects of the implementation (e.g., data layer, business logic, UI, testing)
3333
- Are specific and actionable
3434
- Together address the complete requirements
35-
36-
Step 2: Parallel Planning
3735
- Spawn 2-10 implementation-planner agents in parallel (one spawn_agents call with multiple agents)
3836
- Give each agent a focused subtask from your decomposition
3937
- Each subtask prompt should be specific about what that agent should focus on
4038
41-
Step 3: Synthesis
39+
Step 2: Synthesis
4240
- Review all the plans from the spawned agents
4341
- Create a unified implementation plan that:
4442
- Combines insights from all subtask plans

.agents/planners/implementation-planner.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ You do not have access to tools to modify files (e.g. the write_file or str_repl
2828
2929
Instructions:
3030
- Spawn file-explorer twice to find all the relevant parts of the codebase. Use different prompts for each file-explorer to ensure you get all the relevant parts of the codebase. In parallel as part of the same spawn_agents tool call, you may also spawn a web-researcher or docs-researcher to search the web or technical documentation for relevant information.
31-
- Read all the file paths that are relevant using the read_files tool.
32-
- Read more and more files to get any information that could possibly help you make the best plan. It's good to read 20+ files.
31+
- Read any relevant files that have not already been read.
3332
- Think about the best way to accomplish the task.
3433
- Finally, describe the full change to the codebase that will accomplish the task (or other steps, e.g. terminal commands to run). Use markdown code blocks to describe the changes for each file.
3534

.agents/reviewer/reviewer-factory.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import { AGENT_PERSONAS } from '@codebuff/common/constants/agents'
2-
import { closeXml } from '@codebuff/common/util/xml'
3-
42
import type { SecretAgentDefinition } from '../types/secret-agent-definition'
53
import type { Model } from '@codebuff/common/old-constants'
64

@@ -15,7 +13,7 @@ export const reviewer = (model: Model): Omit<SecretAgentDefinition, 'id'> => ({
1513
},
1614
},
1715
outputMode: 'last_message',
18-
toolNames: ['end_turn', 'run_file_change_hooks'],
16+
toolNames: ['run_file_change_hooks'],
1917
spawnableAgents: [],
2018

2119
inheritParentSystemPrompt: true,
@@ -42,7 +40,5 @@ Next, you should critique the code changes made recently in the above conversati
4240
- Make sure no sections were deleted that weren't supposed to be deleted.
4341
- Make sure the new code matches the style of the existing code.
4442
45-
Be concise and to the point. After providing all your feedback, use the end_turn tool to end your response.`,
46-
47-
stepPrompt: `IMPORTANT: Don't forget to end your response with the end_turn tool: <end_turn>${closeXml('end_turn')}`,
43+
Be concise and to the point.`,
4844
})

0 commit comments

Comments
 (0)