Skip to content

Commit 1c8e260

Browse files
committed
Reviewer editor in max mode
1 parent d5ed4c7 commit 1c8e260

File tree

4 files changed

+156
-20
lines changed

4 files changed

+156
-20
lines changed

.agents/base2/base2.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ export function createBase2(
7777
isDefault && 'editor',
7878
isMax && 'editor-multi-prompt',
7979
isMax && 'thinker-best-of-n-opus',
80-
!isLite && 'code-reviewer',
80+
isDefault && 'code-reviewer',
81+
isMax && 'reviewer-editor-gpt-5',
8182
'context-pruner',
8283
),
8384

@@ -140,9 +141,10 @@ Use the spawn_agents tool to spawn specialized agents to help you complete the u
140141
isMax &&
141142
`- IMPORTANT: You must spawn the editor-multi-prompt 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.`,
142143
'- Spawn commanders sequentially if the second command depends on the the first.',
143-
!isFast &&
144-
!isLite &&
144+
isDefault &&
145145
'- Spawn a code-reviewer to review the changes after you have implemented the changes.',
146+
isMax &&
147+
'- Spawn a reviewer-editor-gpt-5 to review the changes after you have implemented the changes.',
146148
).join('\n ')}
147149
- **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.
148150
- **Never spawn the context-pruner agent:** This agent is spawned automatically for you and you don't need to spawn it yourself.
@@ -204,13 +206,13 @@ ${
204206
205207
${
206208
isDefault || isMax
207-
? '[ You spawn a code-reviewer, a commander to typecheck the changes, and another commander to run tests, all in parallel ]'
209+
? `[ You spawn a ${isDefault ? 'code-reviewer' : 'reviewer-editor-gpt-5'}, a commander to typecheck the changes, and another commander to run tests, all in parallel ]`
208210
: '[ You spawn a commander to typecheck the changes and another commander to run tests, all in parallel ]'
209211
}
210212
211213
${
212214
isDefault || isMax
213-
? '[ You fix the issues found by the code-reviewer and type/test errors ]'
215+
? `[ You fix the issues found by the ${isDefault ? 'code-reviewer' : 'reviewer-editor-gpt-5'} and type/test errors ]`
214216
: '[ You fix the issues found by the type/test errors and spawn more commanders to confirm ]'
215217
}
216218
@@ -330,7 +332,7 @@ ${buildArray(
330332
isFast &&
331333
'- Do a single typecheck targeted for your changes at most (if applicable for the project). Or skip this step if the change was small.',
332334
(isDefault || isMax) &&
333-
'- Spawn a code-reviewer to review the changes after you have implemented the changes. (Skip this step only if the change is extremely straightforward and obvious.)',
335+
`- Spawn a ${isDefault ? 'code-reviewer' : 'reviewer-editor-gpt-5'} to review the changes after you have implemented the changes. (Skip this step only if the change is extremely straightforward and obvious.)`,
334336
!hasNoValidation &&
335337
`- 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, unless the change is very small and targeted (< 10 lines and unlikely to have a type error)!`,
336338
`- Inform the user that you have completed the task in one sentence or a few short bullet points.${isSonnet ? " Don't create any markdown summary files or example documentation files, unless asked by the user." : ''}`,
@@ -363,7 +365,7 @@ function buildImplementationStepPrompt({
363365
isMax &&
364366
`You must spawn the 'editor-multi-prompt' agent to implement code changes, since it will generate the best code changes.`,
365367
(isDefault || isMax) &&
366-
'Spawn code-reviewer to review the changes after you have implemented the changes and in parallel with typechecking or testing.',
368+
`Spawn ${isDefault ? 'code-reviewer' : 'reviewer-editor-gpt-5'} to review the changes after you have implemented the changes and in parallel with typechecking or testing.`,
367369
`After completing the user request, summarize your changes in a sentence${isFast ? '' : ' or a few short bullet points'}.${isSonnet ? " Don't create any summary markdown files or example documentation files, unless asked by the user." : ''} Don't repeat yourself, especially if you have already concluded and summarized the changes in a previous step -- just end your turn.`,
368370
!isFast &&
369371
!noAskUser &&

.agents/editor/editor.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -120,19 +120,6 @@ Write out your complete implementation now, formatting all changes as tool calls
120120
},
121121
includeToolCall: false,
122122
}
123-
124-
// Extract only tool calls from text, removing any commentary
125-
function extractToolCallsOnly(text: string): string {
126-
const toolExtractionPattern =
127-
/<codebuff_tool_call>[\s\S]*?<\/codebuff_tool_call>/g
128-
const matches: string[] = []
129-
130-
for (const match of text.matchAll(toolExtractionPattern)) {
131-
matches.push(match[0])
132-
}
133-
134-
return matches.join('\n')
135-
}
136123
},
137124
} satisfies Omit<AgentDefinition, 'id'>
138125
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { AgentDefinition } from 'types/agent-definition'
2+
import { createCodeEditor } from './editor'
3+
4+
const definition: AgentDefinition = {
5+
...createCodeEditor({ model: 'gpt-5' }),
6+
reasoningOptions: {
7+
effort: 'high',
8+
},
9+
inheritParentSystemPrompt: false,
10+
id: 'reviewer-editor-gpt-5',
11+
}
12+
export default definition

.agents/editor/reviewer-editor.ts

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
import { AgentDefinition, StepText } from 'types/agent-definition'
2+
import { publisher } from '../constants'
3+
4+
export const createCodeEditor = (options: {
5+
model: 'gpt-5' | 'opus'
6+
}): Omit<AgentDefinition, 'id'> => {
7+
const { model } = options
8+
return {
9+
publisher,
10+
model:
11+
options.model === 'gpt-5'
12+
? 'openai/gpt-5.1'
13+
: 'anthropic/claude-opus-4.5',
14+
displayName: 'Code Editor',
15+
spawnerPrompt:
16+
'Expert code reviewer that reviews recent code changes and makes improvements.',
17+
outputMode: 'structured_output',
18+
toolNames: ['write_file', 'str_replace', 'set_output'],
19+
20+
includeMessageHistory: true,
21+
inheritParentSystemPrompt: true,
22+
23+
instructionsPrompt: `You are an expert code reviewer with deep understanding of software engineering principles. You were spawned to review recent code changes and make improvements. Do not spawn a reviewer agent, you are the reviewer agent and have already been spawned.
24+
25+
Analyze the recent code changes and make improvements. However, try to only make changes that you are confident are fully correct and the user would want. It's ok to not make any changes.
26+
27+
Important: You can not make any other tool calls besides editing files. You cannot read more files, write todos, spawn agents, or set output. set_output in particular should not be used. Do not call any of these tools!
28+
29+
Write out what changes you would make using the tool call format below. Use this exact format for each file change:
30+
31+
<codebuff_tool_call>
32+
{
33+
"cb_tool_name": "str_replace",
34+
"path": "path/to/file",
35+
"replacements": [
36+
{
37+
"old": "exact old code",
38+
"new": "exact new code"
39+
},
40+
{
41+
"old": "exact old code 2",
42+
"new": "exact new code 2"
43+
},
44+
]
45+
}
46+
</codebuff_tool_call>
47+
48+
OR for new files or major rewrites:
49+
50+
<codebuff_tool_call>
51+
{
52+
"cb_tool_name": "write_file",
53+
"path": "path/to/file",
54+
"instructions": "What the change does",
55+
"content": "Complete file content or edit snippet"
56+
}
57+
</codebuff_tool_call>
58+
59+
${
60+
model === 'gpt-5'
61+
? ''
62+
: `Before you start writing your implementation, you should use <think> tags to think about the best way to implement the changes.
63+
64+
You can also use <think> tags interspersed between tool calls to think about the best way to implement the changes.
65+
66+
<example>
67+
68+
<think>
69+
[ Long think about the best way to implement the changes ]
70+
</think>
71+
72+
<codebuff_tool_call>
73+
[ First tool call to implement the feature ]
74+
</codebuff_tool_call>
75+
76+
<codebuff_tool_call>
77+
[ Second tool call to implement the feature ]
78+
</codebuff_tool_call>
79+
80+
<think>
81+
[ Thoughts about a tricky part of the implementation ]
82+
</think>
83+
84+
<codebuff_tool_call>
85+
[ Third tool call to implement the feature ]
86+
</codebuff_tool_call>
87+
88+
</example>`
89+
}
90+
91+
### Simplify the code.
92+
93+
See if there's a simpler design that is more maintainable and easier to understand.
94+
95+
See if you can remove any of the following:
96+
- fallback code that is not really needed anymore
97+
- any unnecessary type casts
98+
- any dead code
99+
- any added try/catch blocks -- these clutter the code and are often unnecessary.
100+
- any optional arguments -- these make the code more complex and harder to understand.
101+
- any unused imports
102+
103+
### Improve the code
104+
- Instead of creating new functions, reuse existing functions if possible.
105+
- New components usually should be added to a new file, not added to an existing file.
106+
- Utilities that could be reused should be moved to a shared utilities file.
107+
108+
Write out your edits now.`,
109+
110+
handleSteps: function* ({ agentState: initialAgentState, logger }) {
111+
const initialMessageHistoryLength =
112+
initialAgentState.messageHistory.length
113+
const { agentState } = yield 'STEP'
114+
const { messageHistory } = agentState
115+
116+
const newMessages = messageHistory.slice(initialMessageHistoryLength)
117+
118+
yield {
119+
toolName: 'set_output',
120+
input: {
121+
output: {
122+
messages: newMessages,
123+
},
124+
},
125+
includeToolCall: false,
126+
}
127+
},
128+
} satisfies Omit<AgentDefinition, 'id'>
129+
}
130+
131+
const definition = {
132+
...createCodeEditor({ model: 'opus' }),
133+
id: 'reviewer-editor',
134+
}
135+
export default definition

0 commit comments

Comments
 (0)