Skip to content

Commit 5e2dda2

Browse files
committed
base2-lite!
1 parent 0308b78 commit 5e2dda2

File tree

7 files changed

+298
-148
lines changed

7 files changed

+298
-148
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { publisher } from '../constants'
1+
import { publisher } from '../.agents/constants'
22
import {
33
PLACEHOLDER,
44
type SecretAgentDefinition,
5-
} from '../types/secret-agent-definition'
5+
} from '../.agents/types/secret-agent-definition'
66

7-
import type { Message } from 'types/util-types'
7+
import type { Message } from '../.agents/types/util-types'
88

99
const editor: SecretAgentDefinition = {
1010
id: 'editor-lite',

.agents-graveyard/editor.ts

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
import { publisher } from '../.agents/constants'
2+
import { type SecretAgentDefinition } from '../.agents/types/secret-agent-definition'
3+
4+
import type { Message } from '../.agents/types/util-types'
5+
6+
const editor: SecretAgentDefinition = {
7+
id: 'editor',
8+
publisher,
9+
model: 'anthropic/claude-sonnet-4.5',
10+
displayName: 'Code Editor',
11+
spawnerPrompt:
12+
'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.',
13+
inputSchema: {
14+
prompt: {
15+
type: 'string',
16+
description: 'The coding task to implement',
17+
},
18+
params: {
19+
type: 'object',
20+
properties: {
21+
maxContextLength: {
22+
type: 'number',
23+
},
24+
},
25+
required: [],
26+
},
27+
},
28+
outputMode: 'structured_output',
29+
toolNames: [
30+
'read_files',
31+
'write_file',
32+
'str_replace',
33+
'run_terminal_command',
34+
'code_search',
35+
'spawn_agents',
36+
'add_message',
37+
'set_output',
38+
'end_turn',
39+
],
40+
spawnableAgents: ['file-explorer', 'researcher-web', 'researcher-docs'],
41+
42+
includeMessageHistory: true,
43+
inheritParentSystemPrompt: true,
44+
45+
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.
61+
`,
62+
63+
handleSteps: function* ({ agentState: initialAgentState }) {
64+
const stepLimit = 25
65+
let stepCount = 0
66+
let agentState = initialAgentState
67+
let accumulatedEditToolResults: any[] = []
68+
69+
while (true) {
70+
stepCount++
71+
72+
const stepResult = yield 'STEP'
73+
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+
const finalStepResult = yield 'STEP'
101+
agentState = finalStepResult.agentState
102+
103+
// Extract and accumulate final edit tool results using helper function
104+
accumulatedEditToolResults.push(
105+
...getLatestEditToolResults(agentState.messageHistory),
106+
)
107+
break
108+
}
109+
}
110+
111+
yield {
112+
toolName: 'set_output',
113+
input: {
114+
...agentState.output,
115+
edits: accumulatedEditToolResults,
116+
},
117+
includeToolCall: false,
118+
}
119+
120+
function getLatestEditToolResults(messageHistory: Message[]) {
121+
const lastAssistantMessageIndex = messageHistory.findLastIndex(
122+
(message) => message.role === 'assistant',
123+
)
124+
125+
// Get all edit tool messages after the last assistant message
126+
const newToolMessages = messageHistory
127+
.slice(lastAssistantMessageIndex + 1)
128+
.filter((message) => message.role === 'tool')
129+
.filter(
130+
(message) =>
131+
message.toolName === 'write_file' ||
132+
message.toolName === 'str_replace',
133+
)
134+
135+
// Extract and return new edit tool results
136+
return (
137+
newToolMessages
138+
.flatMap((message) => message.content)
139+
.filter((output) => output.type === 'json')
140+
.map((output) => output.value)
141+
// Only successful edits!
142+
.filter(
143+
(toolResult) =>
144+
toolResult && !('errorMessage' in (toolResult as any)),
145+
)
146+
)
147+
}
148+
},
149+
}
150+
151+
export default editor

.agents/base2/base2-lite.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('lite'),
5+
id: 'base2-lite',
6+
displayName: 'Buffy the Lite Orchestrator',
7+
}
8+
export default definition

.agents/base2/base2.ts

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
} from '../types/secret-agent-definition'
88

99
export function createBase2(
10-
mode: 'fast' | 'default' | 'max',
10+
mode: 'default' | 'lite' | 'max' | 'fast',
1111
options?: {
1212
hasNoValidation?: boolean
1313
planOnly?: boolean
@@ -17,14 +17,15 @@ export function createBase2(
1717
const isDefault = mode === 'default'
1818
const isFast = mode === 'fast'
1919
const isMax = mode === 'max'
20+
const isLite = mode === 'lite'
2021

2122
const isOpus = true
2223
const isSonnet = false
2324
const isGemini = false
2425

2526
return {
2627
publisher,
27-
model: 'anthropic/claude-opus-4.5',
28+
model: isLite ? 'x-ai/grok-4.1-fast' : 'anthropic/claude-opus-4.5',
2829
displayName: 'Buffy the Orchestrator',
2930
spawnerPrompt:
3031
'Advanced base agent that orchestrates planning, editing, and reviewing for complex coding tasks',
@@ -49,7 +50,7 @@ export function createBase2(
4950
'spawn_agents',
5051
'read_files',
5152
'read_subtree',
52-
!isFast && 'write_todos',
53+
!isFast && !isLite && 'write_todos',
5354
'str_replace',
5455
'write_file',
5556
'ask_user',
@@ -62,10 +63,11 @@ export function createBase2(
6263
'glob-matcher',
6364
'researcher-web',
6465
'researcher-docs',
65-
'commander',
66+
isLite ? 'commander-lite' : 'commander',
67+
isLite && 'editor-gpt-5',
6668
isMax && 'editor-best-of-n-max',
6769
isMax && 'thinker-best-of-n-opus',
68-
'code-reviewer-opus',
70+
!isLite && 'code-reviewer-opus',
6971
'context-pruner',
7072
),
7173

@@ -115,12 +117,15 @@ Use the spawn_agents tool to spawn specialized agents to help you complete the u
115117
- **Sequence agents properly:** Keep in mind dependencies when spawning different agents. Don't spawn agents in parallel that depend on each other.
116118
${buildArray(
117119
'- 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.',
118122
isMax &&
119123
'- Spawn the thinker-best-of-n-opus after gathering context to solve complex problems.',
120124
isMax &&
121125
`- 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.`,
122126
'- Spawn commanders sequentially if the second command depends on the the first.',
123127
!isFast &&
128+
!isLite &&
124129
'- Spawn a code-reviewer-opus to review the changes after you have implemented the changes.',
125130
).join('\n ')}
126131
- **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(
149154
`- **Don't create a summary markdown file:** The user doesn't want markdown files they didn't ask for. Don't create them.`,
150155
'- **Keep final summary extremely concise:** Write only a few words for each change you made in the final summary.',
151156
).join('\n')}
152-
${
153-
isFast
154-
? ''
155-
: `
157+
156158
# Response examples
157159
158160
<example>
@@ -168,11 +170,25 @@ ${
168170
169171
[ You read a few other relevant files using the read_files tool ]
170172
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+
}
172180
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+
}
174186
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+
}
176192
177193
[ All tests & typechecks pass -- you write a very short final summary of the changes you made ]
178194
</reponse>
@@ -188,8 +204,6 @@ ${
188204
</response>
189205
190206
</example>
191-
`
192-
}
193207
194208
${PLACEHOLDER.FILE_TREE_PROMPT_SMALL}
195209
${PLACEHOLDER.KNOWLEDGE_FILES_CONTENTS}
@@ -209,6 +223,7 @@ ${PLACEHOLDER.GIT_CHANGES_PROMPT}
209223
isFast,
210224
isDefault,
211225
isMax,
226+
isLite,
212227
hasNoValidation,
213228
}),
214229
stepPrompt: planOnly
@@ -248,12 +263,14 @@ function buildImplementationInstructionsPrompt({
248263
isFast,
249264
isDefault,
250265
isMax,
266+
isLite,
251267
hasNoValidation,
252268
}: {
253269
isSonnet: boolean
254270
isFast: boolean
255271
isDefault: boolean
256272
isMax: boolean
273+
isLite: boolean
257274
hasNoValidation: boolean
258275
}) {
259276
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(
266283
EXPLORE_PROMPT,
267284
isMax &&
268285
`- 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) &&
270287
`- 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.',
271290
isMax &&
272291
`- 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) &&
274293
'- Implement the changes using the str_replace or write_file tools.',
275294
isFast &&
276295
'- Implement the changes in one go. Pause after making all the changes to see the tool results of your edits.',
277296
isFast &&
278297
'- 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) &&
280299
'- 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.)',
281300
!hasNoValidation &&
282301
`- 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!`,

.agents/commander-lite.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import type { AgentDefinition } from './types/agent-definition'
2+
import commander from './commander'
3+
4+
const definition: AgentDefinition = {
5+
...commander,
6+
id: 'commander-lite',
7+
displayName: 'Commander Lite',
8+
model: 'x-ai/grok-4.1-fast',
9+
}
10+
11+
export default definition

.agents/editor/editor-gpt-5.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import editor from './editor'
2-
import type { SecretAgentDefinition } from '../types/secret-agent-definition'
1+
import { createCodeEditor } from './editor'
2+
import type { AgentDefinition } from 'types/agent-definition'
33

4-
const definition: SecretAgentDefinition = {
5-
...editor,
4+
const definition: AgentDefinition = {
5+
...createCodeEditor({ model: 'gpt-5' }),
66
id: 'editor-gpt-5',
7-
model: 'openai/gpt-5.1',
87
}
9-
108
export default definition

0 commit comments

Comments
 (0)