Skip to content

Commit 6262b29

Browse files
committed
Freebuff with editor gpt
1 parent 8713040 commit 6262b29

File tree

2 files changed

+129
-2
lines changed

2 files changed

+129
-2
lines changed

agents/base2/base2.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export function createBase2(
8484
isMax && 'editor-multi-prompt',
8585
'tmux-cli',
8686
'browser-use',
87+
isFree && 'editor-gpt',
8788
isFree && 'code-reviewer-lite',
8889
isDefault && 'code-reviewer',
8990
isMax && 'code-reviewer-multi-prompt',
@@ -149,7 +150,7 @@ Use the spawn_agents tool to spawn specialized agents to help you complete the u
149150
isMax &&
150151
`- 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.`,
151152
isFree &&
152-
'- Implement code changes using the str_replace or write_file tools directly.',
153+
'- Implement code changes using the editor-gpt agent after you have gathered all the context you need. You must spawn this agent for all non-trivial changes since it is much better at writing code than you.',
153154
isFree &&
154155
'- Spawn a code-reviewer-lite to review the changes after you have implemented the changes.',
155156
'- Spawn bashers sequentially if the second command depends on the the first.',
@@ -208,7 +209,7 @@ ${buildArray(
208209
${isDefault
209210
? `[ You implement the changes using the editor agent ]`
210211
: isFast || isFree
211-
? '[ You implement the changes using the str_replace or write_file tools ]'
212+
? '[ You implement the changes using the editor-gpt agent ]'
212213
: '[ You implement the changes using the editor-multi-prompt agent ]'
213214
}
214215
@@ -333,6 +334,8 @@ ${buildArray(
333334
`- 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.`,
334335
(isDefault || isMax) &&
335336
`- For quick problems, briefly explain your reasoning to the user. If you need to think longer, write your thoughts within the <think> tags. Finally, for complex problems, spawn the thinker agent to help find the best solution. (gpt-5-agent is a last resort for complex problems)`,
337+
isFree &&
338+
'- IMPORTANT: You must spawn the editor-gpt 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. For quick follow-ups or simple changes, you can use the str_replace or write_file tools directly to make the changes.',
336339
isDefault &&
337340
'- 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.',
338341
isMax &&
@@ -375,6 +378,8 @@ function buildImplementationStepPrompt({
375378
isMax &&
376379
`Keep working until the user's request is completely satisfied${!hasNoValidation ? ' and validated' : ''}, or until you require more information from the user.`,
377380
'You must use the skill tool to load any potentially relevant skills.',
381+
isFree &&
382+
`You must spawn the editor-gpt agent to implement non-trivial code changes. For obvious or simple changes, you can use the str_replace or write_file tools directly to make the changes.`,
378383
isMax &&
379384
`You must spawn the 'editor-multi-prompt' agent to implement code changes rather than using the str_replace or write_file tools, since it will generate the best code changes.`,
380385
(isDefault || isMax) &&

agents/editor/editor-gpt.ts

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
2+
import { publisher } from '../constants'
3+
4+
import type { AgentDefinition } from '../types/agent-definition'
5+
6+
export const createCodeEditor = (options: {
7+
model: 'gpt-5' | 'opus' | 'minimax'
8+
}): Omit<AgentDefinition, 'id'> => {
9+
const { model } = options
10+
return {
11+
publisher,
12+
model:
13+
options.model === 'gpt-5'
14+
? 'openai/gpt-5.4'
15+
: options.model === 'minimax'
16+
? 'minimax/minimax-m2.5'
17+
: 'anthropic/claude-opus-4.6',
18+
...(options.model === 'opus' && {
19+
providerOptions: {
20+
only: ['amazon-bedrock'],
21+
},
22+
}),
23+
displayName: 'Editor',
24+
spawnerPrompt:
25+
"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 gather as much context as possible and read any related files (be extremely comprehensive!) before spawning this agent as it cannot read files on its own.",
26+
outputMode: 'structured_output',
27+
toolNames: [
28+
// 'read_files',
29+
// 'read_subtree',
30+
// 'skill',
31+
// 'set_output',
32+
// 'code_search',
33+
// 'list_directory',
34+
// 'glob',
35+
'write_file',
36+
'str_replace',
37+
'patch_file'
38+
],
39+
spawnableAgents: [
40+
// 'file-picker',
41+
// 'researcher-web',
42+
// 'researcher-docs',
43+
// 'basher',
44+
// 'tmux-cli',
45+
// 'browser-use',
46+
// 'context-pruner',
47+
],
48+
includeMessageHistory: true,
49+
systemPrompt: `You are a code editor called upon solely to modify files without using other tools. After you finish, another agent will complete the overall task, including running the type checker, running tests, etc. Your job is only to do one pass on the file editing.`,
50+
instructionsPrompt: `You are an expert code editor with deep understanding of software engineering principles. You were spawned to generate an implementation for the user's request. Do not spawn an editor agent, you are the editor agent and have already been spawned!
51+
52+
Your task is to write out ALL the code changes needed to complete the user's request in a single comprehensive response.
53+
54+
Important: You DO NOT have access to tools other than patch_file, write_file, or str_replace file editing tools. You cannot read more files, search the codebase, use glob patterns, run terminal commands (e.g. running the type checker), or use any other tools. You must implement the changes with the context you have already gathered. The rest of the task will be finished by another agent.
55+
56+
${model === 'opus'
57+
? `Before you start writing your implementation, you should use <think> tags to think about the best way to implement the changes.
58+
59+
You can also use <think> tags interspersed between tool calls to think about the best way to implement the changes.
60+
61+
<example>
62+
63+
<think>
64+
[ Long think about the best way to implement the changes ]
65+
</think>
66+
67+
[ First tool call to implement the feature ]
68+
69+
[ Second tool call to implement the feature ]
70+
71+
<think>
72+
[ Thoughts about a tricky part of the implementation ]
73+
</think>
74+
75+
[ Third tool call to implement the feature ]
76+
77+
...
78+
79+
[ Last tool call to implement the feature ]
80+
</example>` : ''}
81+
82+
Your implementation should:
83+
- Be complete and comprehensive
84+
- Include all necessary changes to fulfill the user's request
85+
- Follow the project's conventions and patterns
86+
- Be as simple and maintainable as possible
87+
- Reuse existing code wherever possible
88+
- Be well-structured and organized
89+
90+
More style notes:
91+
- Try/catch blocks clutter the code -- use them sparingly.
92+
- Optional arguments are code smell -- better to use required arguments.
93+
- New components often should be added to a new file, not added to an existing file.
94+
95+
Write out your complete implementation now. Your job is only to make these specific changes and not to do anything else (e.g. do not use terminal commands, do not review the code, do not write any final summary). You must stop abruptly as soon as you have made the last edit.`,
96+
97+
handleSteps: function* ({ agentState: initialAgentState, logger }) {
98+
const initialMessageHistoryLength =
99+
initialAgentState.messageHistory.length
100+
const { agentState } = yield 'STEP_ALL'
101+
const { messageHistory } = agentState
102+
103+
const newMessages = messageHistory.slice(initialMessageHistoryLength)
104+
105+
yield {
106+
toolName: 'set_output',
107+
input: {
108+
output: {
109+
messages: newMessages,
110+
},
111+
},
112+
includeToolCall: false,
113+
}
114+
},
115+
} satisfies Omit<AgentDefinition, 'id'>
116+
}
117+
118+
const definition = {
119+
...createCodeEditor({ model: 'gpt-5' }),
120+
id: 'editor-gpt',
121+
}
122+
export default definition

0 commit comments

Comments
 (0)