Skip to content

Commit 01d02a8

Browse files
committed
base2 with file researcher!
1 parent 769b109 commit 01d02a8

File tree

2 files changed

+125
-0
lines changed

2 files changed

+125
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { type SecretAgentDefinition } from '../../types/secret-agent-definition'
2+
import { createBase2 } from 'base2/base2'
3+
4+
const base2 = createBase2('fast')
5+
const definition: SecretAgentDefinition = {
6+
...base2,
7+
id: 'base2-with-file-researcher',
8+
displayName: 'Buffy the Orchestrator',
9+
spawnableAgents: ['file-researcher', ...(base2.spawnableAgents ?? [])],
10+
instructionsPrompt: `Orchestrate the completion of the user's request using your specialized sub-agents. Take your time and be comprehensive.
11+
12+
## Example workflow
13+
14+
The user asks you to implement a new feature. You respond in multiple steps:
15+
16+
1. Spawn a file-researcher to find relevant files; spawn 1 docs researcher to find relevant docs.
17+
2. Read ALL the files that the file-researcher found using the read_files tool. This is the only time you should use read_files on a long list of files -- it is expensive to do this more than once!
18+
3. Read any other files that you think could be relevant to the user's request.
19+
4. Write out your implementation plan as a bullet point list.
20+
5. Use the str_replace or write_file tools to make the changes.
21+
6. Inform the user that you have completed the task in one sentence without a final summary. Don't create any summary markdown files, unless asked by the user. If you already finished the user request and said you're done, then don't say anything else.`,
22+
23+
stepPrompt: undefined,
24+
25+
handleSteps: function* ({ params, logger }) {
26+
while (true) {
27+
// Run context-pruner before each step
28+
yield {
29+
toolName: 'spawn_agent_inline',
30+
input: {
31+
agent_type: 'context-pruner',
32+
params: params ?? {},
33+
},
34+
includeToolCall: false,
35+
} as any
36+
37+
const { stepsComplete } = yield 'STEP'
38+
if (stepsComplete) break
39+
}
40+
},
41+
}
42+
43+
export default definition
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import { buildArray } from '@codebuff/common/util/array'
2+
3+
import { publisher } from '../constants'
4+
import { type SecretAgentDefinition } from '../types/secret-agent-definition'
5+
6+
export const createFileResearcher: () => Omit<
7+
SecretAgentDefinition,
8+
'id'
9+
> = () => {
10+
return {
11+
publisher,
12+
model: 'anthropic/claude-sonnet-4.5',
13+
displayName: 'File Researcher',
14+
spawnerPrompt:
15+
"Expert researcher that finds relevant information about a coding task and creates a report with the relevant parts of the codebase and how they relate to the user's request.",
16+
inputSchema: {
17+
prompt: {
18+
type: 'string',
19+
description: 'A coding task to research',
20+
},
21+
},
22+
includeMessageHistory: true,
23+
inheritParentSystemPrompt: true,
24+
outputMode: 'structured_output',
25+
outputSchema: {
26+
type: 'object',
27+
properties: {
28+
report: {
29+
type: 'string',
30+
description:
31+
"A concise report on the relevant parts of the codebase and how they relate to the user's request. Give the facts only, don't include any opinions, plans, or recommendations. Don't list implementation steps; this is just a research report. Be extremely brief in this report.",
32+
},
33+
relevantFiles: {
34+
type: 'array',
35+
items: { type: 'string' },
36+
description:
37+
'A comprehensive list of the paths of files that are relevant to the coding task.',
38+
},
39+
},
40+
required: ['report', 'relevantFiles'],
41+
},
42+
toolNames: ['spawn_agents', 'set_output'],
43+
spawnableAgents: buildArray(
44+
'file-picker-max',
45+
'code-searcher',
46+
'directory-lister',
47+
'glob-matcher',
48+
'commander',
49+
'context-pruner',
50+
),
51+
52+
instructionsPrompt: `Research the coding task and create a report with a list of relevant files. Take your time and be comprehensive. Your primary aim is to provide the comprehensive list of relevant files quickly.
53+
54+
## Example workflow
55+
56+
You recieve a coding task to implement a new feature. You do research in multiple rounds of agents and then compile the information into a report.
57+
58+
1. Spawn two different file-picker-max's with different prompts to find relevant files; spawn two different code-searchers and a glob-matcher to find more relevant files and answer questions about the codebase.
59+
2. Spawn one more file-picker-max and one more code-searcher with different prompts to find relevant files.
60+
3. Now the most important part: use the set_output tool to compile the information into a report. The report should have facts only and not include a plan or recommendations or any other information. Finally, include ALL the relevant files in the report.
61+
4. End your turn.`,
62+
handleSteps: function* () {
63+
while (true) {
64+
// Run context-pruner before each step
65+
yield {
66+
toolName: 'spawn_agent_inline',
67+
input: {
68+
agent_type: 'context-pruner',
69+
params: {},
70+
},
71+
includeToolCall: false,
72+
} as any
73+
74+
const { stepsComplete } = yield 'STEP'
75+
if (stepsComplete) break
76+
}
77+
},
78+
}
79+
}
80+
81+
const definition = { ...createFileResearcher(), id: 'file-researcher' }
82+
export default definition

0 commit comments

Comments
 (0)