You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
'Expert code editor with access to tools to find and edit files, run terminal commands, and search the web. Can handle small to medium sized tasks, or work off of a plan for more complex tasks. For easy tasks, you can spawn this agent directly rather than invoking a researcher or planner first. Spawn mulitple in parallel if needed, but only on totally distinct tasks.',
instructionsPrompt: `You are an expert code editor with deep understanding of software engineering principles.
46
+
47
+
Implement the requested changes, using your judgment as needed, but referring to the original <user_message> as the most important source of information.
48
+
49
+
# Instructions
50
+
51
+
- Read any relevant files that have not already been read. Or, spawn a file-explorer to find any other relevant parts of the codebase.
52
+
- Implement changes using str_replace or write_file.
53
+
- Verify your changes by running tests, typechecking, etc. Keep going until you are sure the changes are correct.
54
+
- You must use the set_output tool before finishing and include the following in your summary:
55
+
- An answer to the user prompt (if they asked a question).
56
+
- An explanation of the changes made.
57
+
- A note on any checks you ran to verify the changes, such as tests, typechecking, etc., and the results of those checks.
58
+
- 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.
59
+
- Do not write a summary outside of the one that you include in the set_output tool.
60
+
- As soon as you use set_output, you must end your turn using the end_turn tool.
agentState=stepResult.agentState// Capture the latest state
74
+
75
+
// Accumulate new tool messages from this step
76
+
const{ messageHistory }=agentState
77
+
78
+
// Extract and accumulate new edit tool results using helper function
79
+
accumulatedEditToolResults.push(
80
+
...getLatestEditToolResults(messageHistory),
81
+
)
82
+
83
+
if(stepResult.stepsComplete){
84
+
break
85
+
}
86
+
87
+
// If we've reached within one of the step limit, ask LLM to summarize progress
88
+
if(stepCount===stepLimit-1){
89
+
yield{
90
+
toolName: 'add_message',
91
+
input: {
92
+
role: 'user',
93
+
content:
94
+
'You have reached the step limit. Please use the set_output tool now to summarize your progress so far including all specific actions you took (note that any file changes will be included automatically in the output), what you still need to solve, and provide any insights that could help complete the remaining work. Please end your turn after using the set_output tool with the end_turn tool.',
95
+
},
96
+
includeToolCall: false,
97
+
}
98
+
99
+
// One final step to produce the summary
100
+
constfinalStepResult=yield'STEP'
101
+
agentState=finalStepResult.agentState
102
+
103
+
// Extract and accumulate final edit tool results using helper function
'Advanced base agent that orchestrates planning, editing, and reviewing for complex coding tasks',
@@ -49,7 +50,7 @@ export function createBase2(
49
50
'spawn_agents',
50
51
'read_files',
51
52
'read_subtree',
52
-
!isFast&&'write_todos',
53
+
!isFast&&!isLite&&'write_todos',
53
54
'str_replace',
54
55
'write_file',
55
56
'ask_user',
@@ -62,10 +63,11 @@ export function createBase2(
62
63
'glob-matcher',
63
64
'researcher-web',
64
65
'researcher-docs',
65
-
'commander',
66
+
isLite ? 'commander-lite' : 'commander',
67
+
isLite&&'editor-gpt-5',
66
68
isMax&&'editor-best-of-n-max',
67
69
isMax&&'thinker-best-of-n-opus',
68
-
'code-reviewer-opus',
70
+
!isLite&&'code-reviewer-opus',
69
71
'context-pruner',
70
72
),
71
73
@@ -115,12 +117,15 @@ Use the spawn_agents tool to spawn specialized agents to help you complete the u
115
117
- **Sequence agents properly:** Keep in mind dependencies when spawning different agents. Don't spawn agents in parallel that depend on each other.
116
118
${buildArray(
117
119
'- Spawn context-gathering agents (file pickers, code-searcher, directory-lister, glob-matcher, and web/docs researchers) before making edits.',
120
+
isLite&&
121
+
'- Spawn the editor-gpt-5 agent to implement the changes after you have gathered all the context you need.',
118
122
isMax&&
119
123
'- Spawn the thinker-best-of-n-opus after gathering context to solve complex problems.',
120
124
isMax&&
121
125
`- Spawn the editor-best-of-n-max agent to implement the changes after you have gathered all the context you need. You must spawn this agent for non-trivial changes, since it writes much better code than you would with the str_replace or write_file tools. Don't spawn the editor in parallel with context-gathering agents.`,
122
126
'- Spawn commanders sequentially if the second command depends on the the first.',
123
127
!isFast&&
128
+
!isLite&&
124
129
'- Spawn a code-reviewer-opus to review the changes after you have implemented the changes.',
125
130
).join('\n ')}
126
131
- **No need to include context:** 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.
@@ -149,10 +154,7 @@ ${buildArray(
149
154
`- **Don't create a summary markdown file:** The user doesn't want markdown files they didn't ask for. Don't create them.`,
150
155
'- **Keep final summary extremely concise:** Write only a few words for each change you made in the final summary.',
151
156
).join('\n')}
152
-
${
153
-
isFast
154
-
? ''
155
-
: `
157
+
156
158
# Response examples
157
159
158
160
<example>
@@ -168,11 +170,25 @@ ${
168
170
169
171
[ You read a few other relevant files using the read_files tool ]
170
172
171
-
[ You implement the changes using the str_replace or write_file tools ]
173
+
${
174
+
isDefault||isFast
175
+
? '[ You implement the changes using the str_replace or write_file tools ]'
176
+
: isLite
177
+
? '[ You implement the changes using the editor-gpt-5 agent ]'
178
+
: '[ You implement the changes using the editor-best-of-n-max agent ]'
179
+
}
172
180
173
-
[ You spawn a code-reviewer, a commander to typecheck the changes, and another commander to run tests, all in parallel ]
181
+
${
182
+
isDefault||isMax
183
+
? '[ You spawn a code-reviewer, a commander to typecheck the changes, and another commander to run tests, all in parallel ]'
184
+
: '[ You spawn a commander to typecheck the changes and another commander to run tests, all in parallel ]'
185
+
}
174
186
175
-
[ You fix the issues found by the code-reviewer and type/test errors ]
187
+
${
188
+
isDefault||isMax
189
+
? '[ You fix the issues found by the code-reviewer and type/test errors ]'
190
+
: '[ You fix the issues found by the type/test errors and spawn more commanders to confirm ]'
191
+
}
176
192
177
193
[ All tests & typechecks pass -- you write a very short final summary of the changes you made ]
@@ -248,12 +263,14 @@ function buildImplementationInstructionsPrompt({
248
263
isFast,
249
264
isDefault,
250
265
isMax,
266
+
isLite,
251
267
hasNoValidation,
252
268
}: {
253
269
isSonnet: boolean
254
270
isFast: boolean
255
271
isDefault: boolean
256
272
isMax: boolean
273
+
isLite: boolean
257
274
hasNoValidation: boolean
258
275
}){
259
276
return`Act as a helpful assistant and freely respond to the user's request however would be most helpful to the user. Use your judgement to orchestrate the completion of the user's request using your specialized sub-agents and tools as needed. Take your time and be comprehensive. Don't surprise the user. For example, don't modify files if the user has not asked you to do so at least implicitly.
@@ -266,17 +283,19 @@ ${buildArray(
266
283
EXPLORE_PROMPT,
267
284
isMax&&
268
285
`- Important: Read as many files as could possibly be relevant to the task over several steps to improve your understanding of the user's request and produce the best possible code changes. Find more examples within the codebase similar to the user's request, dependencies that help with understanding how things work, tests, etc. This is frequently 12-20 files, depending on the task.`,
269
-
!isFast&&
286
+
(isDefault||isMax)&&
270
287
`- For any task requiring 3+ steps, use the write_todos tool to write out your step-by-step implementation plan. Include ALL of the applicable tasks in the list.${isFast ? '' : ' You should include a step to review the changes after you have implemented the changes.'}:${hasNoValidation ? '' : ' You should include at least one step to validate/test your changes: be specific about whether to typecheck, run tests, run lints, etc.'} You may be able to do reviewing and validation in parallel in the same step. Skip write_todos for simple tasks like quick edits or answering questions.`,
288
+
isLite&&
289
+
'- IMPORTANT: You must spawn the editor-gpt-5 agent to implement the changes after you have gathered all the context you need. This agent will do the best job of implementing the changes so you must spawn it for all changes.',
271
290
isMax&&
272
291
`- IMPORTANT: You must spawn the editor-best-of-n-max agent to implement non-trivial code changes, since it will generate the best code changes from multiple implementation proposals. This is the best way to make high quality code changes -- strongly prefer using this agent over the str_replace or write_file tools, unless the change is very straightforward and obvious.`,
273
-
!isMax&&
292
+
(isDefault||isFast)&&
274
293
'- Implement the changes using the str_replace or write_file tools.',
275
294
isFast&&
276
295
'- Implement the changes in one go. Pause after making all the changes to see the tool results of your edits.',
277
296
isFast&&
278
297
'- Do a single typecheck targeted for your changes at most (if applicable for the project). Or skip this step if the change was small.',
279
-
!isFast&&
298
+
(isDefault||isMax)&&
280
299
'- Spawn a code-reviewer-opus to review the changes after you have implemented the changes. (Skip this step only if the change is extremely straightforward and obvious.)',
281
300
!hasNoValidation&&
282
301
`- Test your changes by running appropriate validation commands for the project (e.g. typechecks, tests, lints, etc.). Try to run all appropriate commands in parallel. ${isMax ? ' Typecheck and test the specific area of the project that you are editing *AND* then typecheck and test the entire project if necessary.' : ' If you can, only test the area of the project that you are editing, rather than the entire project.'} You may have to explore the project to find the appropriate commands. Don't skip this step!`,
0 commit comments