Skip to content

Commit 845d906

Browse files
committed
Create inline file explorer max & base2 max
1 parent d690688 commit 845d906

File tree

4 files changed

+118
-61
lines changed

4 files changed

+118
-61
lines changed

.agents/base2/base2-max.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { createBase2 } from './base2'
2+
3+
const definition = { ...createBase2('max'), id: 'base2-max' }
4+
5+
export default definition

.agents/base2/base2.ts

Lines changed: 73 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,55 @@
1+
import { buildArray } from '@codebuff/common/util/array'
2+
13
import { publisher } from '../constants'
24
import {
35
PLACEHOLDER,
46
type SecretAgentDefinition,
57
} from '../types/secret-agent-definition'
68

7-
const definition: SecretAgentDefinition = {
8-
id: 'base2',
9-
publisher,
10-
model: 'anthropic/claude-sonnet-4.5',
11-
displayName: 'Buffy the Orchestrator',
12-
spawnerPrompt:
13-
'Advanced base agent that orchestrates planning, editing, and reviewing for complex coding tasks',
14-
inputSchema: {
15-
prompt: {
16-
type: 'string',
17-
description: 'A coding task to complete',
18-
},
19-
params: {
20-
type: 'object',
21-
properties: {
22-
maxContextLength: {
23-
type: 'number',
9+
export const createBase2: (mode: 'normal' | 'max') => SecretAgentDefinition = (
10+
mode,
11+
) => {
12+
const isMax = mode === 'max'
13+
return {
14+
id: 'base2',
15+
publisher,
16+
model: 'anthropic/claude-sonnet-4.5',
17+
displayName: 'Buffy the Orchestrator',
18+
spawnerPrompt:
19+
'Advanced base agent that orchestrates planning, editing, and reviewing for complex coding tasks',
20+
inputSchema: {
21+
prompt: {
22+
type: 'string',
23+
description: 'A coding task to complete',
24+
},
25+
params: {
26+
type: 'object',
27+
properties: {
28+
maxContextLength: {
29+
type: 'number',
30+
},
2431
},
32+
required: [],
2533
},
26-
required: [],
2734
},
28-
},
29-
outputMode: 'last_message',
30-
includeMessageHistory: true,
31-
toolNames: ['spawn_agents', 'read_files'],
32-
spawnableAgents: [
33-
'file-explorer',
34-
'find-all-referencer',
35-
'researcher-web',
36-
'researcher-docs',
37-
'read-only-commander',
38-
'decomposing-thinker',
39-
'code-sketcher',
40-
'editor',
41-
'reviewer',
42-
'context-pruner',
43-
],
44-
45-
systemPrompt: `You are Buffy, a strategic coding assistant that orchestrates complex coding tasks through specialized sub-agents.
35+
outputMode: 'last_message',
36+
includeMessageHistory: true,
37+
toolNames: ['spawn_agents', 'spawn_agent_inline', 'read_files'],
38+
spawnableAgents: buildArray(
39+
isMax && 'inline-file-explorer-max',
40+
'file-picker',
41+
'find-all-referencer',
42+
'researcher-web',
43+
'researcher-docs',
44+
'read-only-commander',
45+
'decomposing-thinker',
46+
'code-sketcher',
47+
'editor',
48+
'reviewer',
49+
'context-pruner',
50+
),
51+
52+
systemPrompt: `You are Buffy, a strategic coding assistant that orchestrates complex coding tasks through specialized sub-agents.
4653
4754
# Core Mandates
4855
@@ -66,7 +73,7 @@ The following is the state of the git repository at the start of the conversatio
6673
${PLACEHOLDER.GIT_CHANGES_PROMPT}
6774
`,
6875

69-
instructionsPrompt: `Orchestrate the completion of the user's request using your specialized sub-agents.
76+
instructionsPrompt: `Orchestrate the completion of the user's request using your specialized sub-agents.
7077
7178
You spawn agents in "layers". Each layer is one spawn_agents tool call composed of multiple agents that answer your questions, do research, think, edit, and review.
7279
@@ -78,7 +85,11 @@ Continue to spawn layers of agents until have completed the user's request or re
7885
7986
The user asks you to implement a new feature. You respond in multiple steps:
8087
81-
1. Spawn a file explorer with different prompts to find relevant files; spawn a find-all-referencer to find more relevant files and answer questions about the codebase; spawn 1 docs research to find relevant docs;
88+
${
89+
isMax
90+
? '1. Spawn an inline-file-explorer-max to explore the codebase and read all relevant files (this is the only agent you should use spawn_agent_inline for); spawn 1 docs research to find relevant docs.'
91+
: '1. Spawn a file explorer with different prompts to find relevant files; spawn a find-all-referencer to find more relevant files and answer questions about the codebase; spawn 1 docs research to find relevant docs.'
92+
}
8293
1a. Read all the relevant files using the read_files tool.
8394
2. Spawn one more file explorer and one more find-all-referencer with different prompts to find relevant files; spawn a decomposing thinker with questions on a key decision; spawn a decomposing thinker to plan out the feature part-by-part. Spawn a code sketcher to sketch out one key section of the code that is the most important or difficult.
8495
2a. Read all the relevant files using the read_files tool.
@@ -103,26 +114,30 @@ The user asks you to implement a new feature. You respond in multiple steps:
103114
- **Be careful about terminal commands:** Be careful about instructing subagents to run terminal commands that could be destructive or have effects that are hard to undo (e.g. git push, running scripts that could alter production environments, installing packages globally, etc). Don't do any of these unless the user explicitly asks you to.
104115
`,
105116

106-
stepPrompt: `Don't forget to spawn agents that could help, especially: the file-explorer and find-all-referencer to get codebase context, the decomposing thinker to think about key decisions, the code sketcher to sketch out the key sections of code, and the reviewer/decomposing-reviewer to review code changes made by the editor(s).`,
107-
108-
handleSteps: function* ({ prompt, params }) {
109-
let steps = 0
110-
while (true) {
111-
steps++
112-
// Run context-pruner before each step
113-
yield {
114-
toolName: 'spawn_agent_inline',
115-
input: {
116-
agent_type: 'context-pruner',
117-
params: params ?? {},
118-
},
119-
includeToolCall: false,
120-
} as any
121-
122-
const { stepsComplete } = yield 'STEP'
123-
if (stepsComplete) break
124-
}
125-
},
117+
stepPrompt: isMax
118+
? `Don't forget to spawn agents that could help, especially: the inline-file-explorer-max to get codebase context, the decomposing thinker to think about key decisions, the code sketcher to sketch out the key sections of code, and the reviewer to review code changes made by the editor(s).`
119+
: `Don't forget to spawn agents that could help, especially: the file-explorer and find-all-referencer to get codebase context, the decomposing thinker to think about key decisions, the code sketcher to sketch out the key sections of code, and the reviewer to review code changes made by the editor(s).`,
120+
121+
handleSteps: function* ({ prompt, params }) {
122+
let steps = 0
123+
while (true) {
124+
steps++
125+
// Run context-pruner before each step
126+
yield {
127+
toolName: 'spawn_agent_inline',
128+
input: {
129+
agent_type: 'context-pruner',
130+
params: params ?? {},
131+
},
132+
includeToolCall: false,
133+
} as any
134+
135+
const { stepsComplete } = yield 'STEP'
136+
if (stepsComplete) break
137+
}
138+
},
139+
}
126140
}
127141

142+
const definition = createBase2('normal')
128143
export default definition
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { publisher } from '../constants'
2+
3+
import type { SecretAgentDefinition } from '../types/secret-agent-definition'
4+
5+
const definition: SecretAgentDefinition = {
6+
id: 'inline-file-explorer-max',
7+
displayName: 'Inline File Explorer Max',
8+
spawnerPrompt:
9+
'Ask this agent to explore area of the codebase and read all relevant files. Spawn this agent inline',
10+
model: 'anthropic/claude-sonnet-4.5',
11+
publisher,
12+
outputMode: 'last_message',
13+
includeMessageHistory: true,
14+
inheritParentSystemPrompt: true,
15+
toolNames: ['spawn_agents', 'read_files', 'end_turn'],
16+
spawnableAgents: ['file-explorer', 'find-all-referencer'],
17+
inputSchema: {
18+
prompt: {
19+
type: 'string',
20+
description:
21+
'The area(s) of the codebase to explore and read all relevant files. Give as much detail as possible.',
22+
},
23+
},
24+
instructionsPrompt: `You are a codebase exploration agent that is good at exploring area of the codebase and reading all relevant files.
25+
26+
Repeat the following steps in multiple rounds:
27+
1. Spawn a file explorer and a find-all-referencer or two to explore the codebase
28+
2. Read all relevant files
29+
3. Go back to step 1 and repeat
30+
31+
The goal is to maximize the amount of context you can gather. Once you have read 20+ files or are sure you have read **all** relevant files use the end_turn tool to end the turn.
32+
You must use this end_turn tool as soon as you have read all relevant files.`,
33+
}
34+
35+
export default definition

backend/src/tools/handlers/tool/spawn-agent-inline.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export const handleSpawnAgentInline = ((
6666
userInputId,
6767
getLatestState,
6868
state,
69+
writeToClient,
6970
} = params
7071
const {
7172
agent_type: agentTypeStr,
@@ -126,9 +127,10 @@ export const handleSpawnAgentInline = ((
126127
fingerprintId,
127128
parentSystemPrompt: system,
128129
onResponseChunk: (chunk) => {
129-
// Disabled.
130-
// Inherits parent's onResponseChunk
131-
// writeToClient(chunk)
130+
// Inherits parent's onResponseChunk, except for context-pruner (TODO: add an option for it to be silent?)
131+
if (agentType !== 'context-pruner') {
132+
writeToClient(chunk)
133+
}
132134
},
133135
clearUserPromptMessagesAfterResponse: false,
134136
})

0 commit comments

Comments
 (0)