Skip to content

Commit 93f6495

Browse files
committed
base2-editor (thinks before implementing)
1 parent 4a5f830 commit 93f6495

File tree

3 files changed

+69
-10
lines changed

3 files changed

+69
-10
lines changed

.agents/base2/base2-editor.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { createBase2 } from './base2'
2+
3+
const definition = {
4+
...createBase2('default', { useEditor: true }),
5+
id: 'base2-editor',
6+
displayName: 'Buffy the Editor Orchestrator',
7+
}
8+
export default definition

.agents/base2/base2.ts

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,14 @@ export function createBase2(
1111
options?: {
1212
hasNoValidation?: boolean
1313
planOnly?: boolean
14+
useEditor?: boolean
1415
},
1516
): Omit<SecretAgentDefinition, 'id'> {
16-
const { hasNoValidation = mode === 'fast', planOnly = false } = options ?? {}
17+
const {
18+
hasNoValidation = mode === 'fast',
19+
planOnly = false,
20+
useEditor = false,
21+
} = options ?? {}
1722
const isDefault = mode === 'default'
1823
const isFast = mode === 'fast'
1924
const isMax = mode === 'max'
@@ -65,6 +70,7 @@ export function createBase2(
6570
'researcher-docs',
6671
isLite ? 'commander-lite' : 'commander',
6772
isLite && 'editor-gpt-5',
73+
useEditor && 'editor',
6874
isMax && 'editor-best-of-n-max',
6975
isMax && 'thinker-best-of-n-opus',
7076
!isLite && 'code-reviewer-opus',
@@ -119,6 +125,8 @@ Use the spawn_agents tool to spawn specialized agents to help you complete the u
119125
'- Spawn context-gathering agents (file pickers, code-searcher, directory-lister, glob-matcher, and web/docs researchers) before making edits.',
120126
isLite &&
121127
'- Spawn the editor-gpt-5 agent to implement the changes after you have gathered all the context you need.',
128+
useEditor &&
129+
'- Spawn the editor agent to implement the changes after you have gathered all the context you need.',
122130
isMax &&
123131
'- Spawn the thinker-best-of-n-opus after gathering context to solve complex problems.',
124132
isMax &&
@@ -171,11 +179,13 @@ ${buildArray(
171179
[ You read a few other relevant files using the read_files tool ]
172180
173181
${
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 ]'
182+
useEditor
183+
? `[ You implement the changes using the editor agent ]`
184+
: isDefault || isFast
185+
? '[ You implement the changes using the str_replace or write_file tools ]'
186+
: isLite
187+
? '[ You implement the changes using the editor-gpt-5 agent ]'
188+
: '[ You implement the changes using the editor-best-of-n-max agent ]'
179189
}
180190
181191
${
@@ -225,6 +235,7 @@ ${PLACEHOLDER.GIT_CHANGES_PROMPT}
225235
isMax,
226236
isLite,
227237
hasNoValidation,
238+
useEditor,
228239
}),
229240
stepPrompt: planOnly
230241
? buildPlanOnlyStepPrompt({})
@@ -233,6 +244,7 @@ ${PLACEHOLDER.GIT_CHANGES_PROMPT}
233244
isMax,
234245
hasNoValidation,
235246
isSonnet,
247+
useEditor,
236248
}),
237249

238250
handleSteps: function* ({ params }) {
@@ -265,13 +277,15 @@ function buildImplementationInstructionsPrompt({
265277
isMax,
266278
isLite,
267279
hasNoValidation,
280+
useEditor,
268281
}: {
269282
isSonnet: boolean
270283
isFast: boolean
271284
isDefault: boolean
272285
isMax: boolean
273286
isLite: boolean
274287
hasNoValidation: boolean
288+
useEditor: boolean
275289
}) {
276290
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.
277291
@@ -287,6 +301,8 @@ ${buildArray(
287301
`- 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.`,
288302
isLite &&
289303
'- 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.',
304+
useEditor &&
305+
'- IMPORTANT: You must spawn the editor 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 non-trivial changes. Do not pass any prompt or params to the editor agent when spawning it. It will make its own best choices of what to do.',
290306
isMax &&
291307
`- 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.`,
292308
(isDefault || isFast) &&
@@ -308,15 +324,19 @@ function buildImplementationStepPrompt({
308324
isMax,
309325
hasNoValidation,
310326
isSonnet,
327+
useEditor,
311328
}: {
312329
isFast: boolean
313330
isMax: boolean
314331
hasNoValidation: boolean
315332
isSonnet: boolean
333+
useEditor: boolean
316334
}) {
317335
return buildArray(
318336
isMax &&
319337
`Keep working until the user's request is completely satisfied${!hasNoValidation ? ' and validated' : ''}, or until you require more information from the user.`,
338+
useEditor &&
339+
`You must spawn the 'editor' agent to implement code changes, since it will do the best job of implementing the changes.`,
320340
isMax &&
321341
`You must spawn the 'editor-best-of-n-max' agent to implement code changes, since it will generate the best code changes.`,
322342
isMax && 'Spawn the thinker-best-of-n-opus to solve complex problems.',

.agents/editor/editor.ts

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const createCodeEditor = (options: {
99
options.model === 'gpt-5' ? 'openai/gpt-5.1' : 'anthropic/claude-opus-4.5',
1010
displayName: 'Code Editor',
1111
spawnerPrompt:
12-
'Expert code editor. Do not specify an input prompt for this agent; it inherits the context of the entire conversation with the user. Make sure to read any files intended to be edited before spawning this agent as it cannot read files on its own.',
12+
"Expert code editor that implements code changes based on the user's request. Do not specify an input prompt for this agent; it inherits the context of the entire conversation with the user. Make sure to read any files intended to be edited before spawning this agent as it cannot read files on its own.",
1313
outputMode: 'structured_output',
1414
toolNames: ['write_file', 'str_replace', 'set_output'],
1515

@@ -52,7 +52,35 @@ OR for new files or major rewrites:
5252
}
5353
</codebuff_tool_call>
5454
55-
After the edit tool calls, you can optionally mention any follow-up steps to take, like deleting a file, or a sepcific way to validate the changes. There's no need to use the set_output tool as your entire response will be included in the output.
55+
IMPORTANT: Before you start writing your implementation, you should use <think> tags to think about the best way to implement the changes. You should think really really hard to make sure you implement the changes in the best way possible. Take as much time as you to think through all the cases to produce the best changes.
56+
57+
You can also use <think> tags interspersed between tool calls to think about the best way to implement the changes.
58+
59+
<example>
60+
61+
<think>
62+
[ Long think about the best way to implement the changes ]
63+
</think>
64+
65+
<codebuff_tool_call>
66+
[ First tool call to implement the feature ]
67+
</codebuff_tool_call>
68+
69+
<codebuff_tool_call>
70+
[ Second tool call to implement the feature ]
71+
</codebuff_tool_call>
72+
73+
<think>
74+
[ Thoughts about a tricky part of the implementation ]
75+
</think>
76+
77+
<codebuff_tool_call>
78+
[ Third tool call to implement the feature ]
79+
</codebuff_tool_call>
80+
81+
</example>
82+
83+
After the edit tool calls, you can optionally mention any follow-up steps to take, like deleting a file, or a sepcific way to validate the changes. You should not summarize your changes, just stop when you're done. There's no need to use the set_output tool as your entire response will be included in the output.
5684
5785
Your implementation should:
5886
- Be complete and comprehensive
@@ -110,5 +138,8 @@ Write out your complete implementation now, formatting all changes as tool calls
110138
},
111139
})
112140

113-
const editor = createCodeEditor({ model: 'opus' })
114-
export default editor
141+
const definition = {
142+
...createCodeEditor({ model: 'opus' }),
143+
id: 'editor',
144+
}
145+
export default definition

0 commit comments

Comments
 (0)