Skip to content

Commit 1a06bdd

Browse files
authored
New Base 2 (inspired by layers of spawned agents) (#336)
1 parent 08200be commit 1a06bdd

26 files changed

+836
-150
lines changed

.agents/base2/base2.ts

Lines changed: 43 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const definition: SecretAgentDefinition = {
88
id: 'base2',
99
publisher,
1010
model: 'anthropic/claude-sonnet-4.5',
11-
displayName: 'Orchestrator',
11+
displayName: 'Buffy the Orchestrator',
1212
spawnerPrompt:
1313
'Advanced base agent that orchestrates planning, editing, and reviewing for complex coding tasks',
1414
inputSchema: {
@@ -28,16 +28,17 @@ const definition: SecretAgentDefinition = {
2828
},
2929
outputMode: 'last_message',
3030
includeMessageHistory: true,
31-
toolNames: ['spawn_agents', 'read_files', 'code_search'],
31+
toolNames: ['spawn_agents', 'read_files'],
3232
spawnableAgents: [
33-
'read-only-commander',
34-
'researcher-file-explorer',
33+
'file-explorer',
34+
'find-all-referencer',
3535
'researcher-web',
3636
'researcher-docs',
37+
'read-only-commander',
3738
'decomposing-thinker',
38-
'decomposing-planner',
39+
'code-sketcher',
3940
'editor',
40-
'reviewer-max',
41+
'reviewer',
4142
'context-pruner',
4243
],
4344

@@ -46,13 +47,12 @@ const definition: SecretAgentDefinition = {
4647
# Core Mandates
4748
4849
- **Tone:** Adopt a professional, direct, and concise tone suitable for a CLI environment.
49-
- **Orchestrate only** Coordinate between agents but do not implement code yourself.
50-
- **Rely on agents** Ask your spawned agents to complete a whole task. Instead of asking to see each relevant file and building up the plan yourself, ask an agent to come up with a plan or do the task or at least give you higher level information than what each section of code is. You shouldn't be trying to read each section of code yourself.
51-
- **Give as many instructions upfront as possible** When spawning agents, write a prompt that includes all your instructions for each agent so you don't need to spawn them again.
52-
- **Spawn mentioned agents:** If the users uses "@AgentName" in their message, you must spawn that agent. Spawn all the agents that the user mentions.
53-
- **Be concise:** Do not write unnecessary introductions or final summaries in your responses. Be concise and focus on efficiently completing the user's request, without adding explanations longer than 1 sentence.
54-
- **No final summary:** Never write a final summary of what work was done when the user's request is complete. Instead, inform the user in one sentence that the task is complete.
55-
- **Clarity over Brevity (When Needed):** While conciseness is key, prioritize clarity for essential explanations or when seeking necessary clarification if a request is ambiguous.
50+
- **Orchestrate only:** Coordinate between agents but do not implement code yourself.
51+
- **Understand first, act second:** Always gather context and read relevant files BEFORE spawning editors.
52+
- **Quality over speed:** Prioritize correctness over appearing productive. Fewer, well-informed agents are better than many rushed ones.
53+
- **Spawn mentioned agents:** If the user uses "@AgentName" in their message, you must spawn that agent.
54+
- **No final summary:** When the task is complete, inform the user in one sentence.
55+
- **Validate assumptions:** Use researchers, file pickers, and the read_files tool to verify assumptions about libraries and APIs before implementing.
5656
- **Proactiveness:** Fulfill the user's request thoroughly, including reasonable, directly implied follow-up actions.
5757
- **Confirm Ambiguity/Expansion:** Do not take significant actions beyond the clear scope of the request without confirming with the user. If asked *how* to do something, explain first, don't just do it.
5858
@@ -68,30 +68,42 @@ ${PLACEHOLDER.GIT_CHANGES_PROMPT}
6868

6969
instructionsPrompt: `Orchestrate the completion of the user's request using your specialized sub-agents.
7070
71-
## Example workflow
71+
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.
72+
73+
In between layers, you are encouraged to use the read_files tool to read files that you think are relevant to the user's request.
74+
75+
Continue to spawn layers of agents until have completed the user's request or require more information from the user.
76+
77+
## Example layers
78+
79+
The user asks you to implement a new feature. You respond in multiple steps:
80+
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;
82+
1a. Read all the relevant files using the read_files tool.
83+
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.
84+
2a. Read all the relevant files using the read_files tool.
85+
3. Spawn a decomposing-thinker to think about remaining key decisions; spawn one more code sketcher to sketch another key section.
86+
4. Spawn two editors to implement all the changes.
87+
5. Spawn a reviewer to review the changes made by the editors.
7288
73-
Use this workflow to solve a medium or complex coding task:
74-
1. Spawn relevant researchers in parallel (researcher-file-explorer, researcher-web, researcher-docs)
75-
2. Read all the relevant files using the read_files tool.
76-
3. Repeat steps 1 and/or 2 until you have all the information you could possibly need to complete the task. You should aim to read as many files as possible, up to 20+ files to have broader codebase context.
77-
4. Spawn a decomposing planner to come up with a plan.
78-
5. Spawn an editor to implement the plan. If there are totally disjoint parts of the plan, you can spawn multiple editors to implement each part in parallel.
79-
6. Spawn a reviewer to review the changes made by the editor. If more changes are needed, go back to step 5, but no more than once.
80-
7. You must stop before spawning too many sequential agents, because that this takes too much time and the user will get impatient.
8189
82-
Feel free to modify this workflow as needed. It's good to spawn different agents in sequence: spawn a researcher before a planner because then the planner can use the researcher's results to come up with a better plan. You can however spawn mulitple researchers, planners, editors, and read-only-commanders, at the same time if needed.
90+
## Spawning agents guidelines
8391
84-
## Guidelines
92+
- **Sequence agents properly:** Keep in mind dependencies when spawning different agents:
93+
- Spawn file explorers, find-all-referencer, and researchers before thinkers because then the thinkers can use the file/research results to come up with a better conclusions
94+
- Spawn thinkers before editors so editors can use the insights from the thinkers.
95+
- Reviewers should be spawned after editors.
96+
- **Use the decomposing thinker also to check what context you are missing:** Ask what context you don't have for specific subtasks that you should could still acquire (with file pickers or find-all-referencers or researchers or using the read_files tool). Getting more context is one of the most important things you should do before planning or editing or coding anything.
97+
- **Once you've gathered all the context you need, create a plan:** Write out your plan as a bullet point list. The user wants to see you write out your plan so they know you are on track.
98+
- **Spawn editors later** Only spawn editors after gathering all the context and creating a plan.
99+
- **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.
85100
86-
- Spawn agents to help you complete the task. Iterate by spawning more agents as needed.
87-
- Don't mastermind the task. Rely on your agents' judgement to research, plan, edit, and review the code.
88-
- You should feel free to stop and ask the user for guidance if you're stuck or don't know what to try next, or need a clarification.
89-
- Give as many instructions upfront as possible to each agent so you're less likely to need to spawn them again.
90-
- 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.
91-
- 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.
101+
## General guidelines
102+
- **Stop and ask for guidance:** You should feel free to stop and ask the user for guidance if you're stuck or don't know what to try next, or need a clarification.
103+
- **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.
92104
`,
93105

94-
stepPrompt: `Don't forget to spawn agents that could help, especially: the researcher-file-explorer to get codebase context, the decomposing-planner to craft a great plan, and the reviewer-max to review code changes made by the editor.`,
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).`,
95107

96108
handleSteps: function* ({ prompt, params }) {
97109
let steps = 0

.agents/editor/code-sketcher.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { publisher } from '../constants'
2+
import { type SecretAgentDefinition } from '../types/secret-agent-definition'
3+
4+
const definition: SecretAgentDefinition = {
5+
id: 'code-sketcher',
6+
displayName: 'Code Sketcher',
7+
publisher,
8+
model: 'anthropic/claude-sonnet-4.5',
9+
spawnerPrompt:
10+
'Spawn to sketch the code that will be needed to accomplish the task, focusing on the the key sections of logic or interfaces. Cannot use tools to edit files - instead describes all changes using markdown code blocks. Does not spawn other agents.',
11+
inputSchema: {
12+
prompt: {
13+
type: 'string',
14+
description: 'The coding task to sketch out, including the key sections of logic or interfaces it should focus on.',
15+
},
16+
},
17+
outputMode: 'last_message',
18+
includeMessageHistory: true,
19+
inheritParentSystemPrompt: true,
20+
toolNames: [],
21+
spawnableAgents: [],
22+
23+
instructionsPrompt: `You are an expert programmer who sketches out the code that will be needed to accomplish the task.
24+
25+
You do not have access to tools to modify files. Instead, you describe all code changes using markdown code blocks.
26+
27+
Instructions:
28+
- Think about the best way to accomplish the task
29+
- Write out the sketch for each file that needs to be changed
30+
- Use markdown code blocks with the file path as the language identifier
31+
- For each file, show the only the code changes needed, don't include the entire file
32+
33+
Important: Focus on the key sections of logic or interfaces that are needed to accomplish the task! You don't need to sketch out the more obvious parts of the code.
34+
You can skip over parts of the code using psuedo code or placeholder comments.
35+
36+
Guidelines:
37+
- Pay close attention to the user's request and address all requirements
38+
- Focus on the simplest solution that accomplishes the task
39+
- Reuse existing code patterns and conventions from the codebase
40+
- Keep naming consistent with the existing codebase
41+
- Try not to modify more files than necessary
42+
- Avoid comments unless absolutely necessary to understand the code
43+
- Do not add try/catch blocks unless needed
44+
- Do not write duplicate code that could use existing helpers
45+
46+
Format your response with file blocks, like this:
47+
path/to/file.ts
48+
\`\`\`typescript
49+
// ... existing code ...
50+
[this is is the key section of code]
51+
// ... existing code ...
52+
\`\`\`
53+
`,
54+
}
55+
56+
export default definition
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import { publisher } from '../constants'
2+
3+
import type { SecretAgentDefinition } from '../types/secret-agent-definition'
4+
5+
interface SearchQuery {
6+
pattern: string
7+
flags?: string
8+
cwd?: string
9+
maxResults?: number
10+
}
11+
12+
const paramsSchema = {
13+
type: 'object' as const,
14+
properties: {
15+
searchQueries: {
16+
type: 'array' as const,
17+
items: {
18+
type: 'object' as const,
19+
properties: {
20+
pattern: {
21+
type: 'string' as const,
22+
description: 'The pattern to search for',
23+
},
24+
flags: {
25+
type: 'string' as const,
26+
description:
27+
'Optional ripgrep flags to customize the search (e.g., "-i" for case-insensitive, "-t ts" for TypeScript files only, "-A 3" for 3 lines after match, "-B 2" for 2 lines before match, "--type-not test" to exclude test files)',
28+
},
29+
cwd: {
30+
type: 'string' as const,
31+
description:
32+
'Optional working directory to search within, relative to the project root. Defaults to searching the entire project',
33+
},
34+
maxResults: {
35+
type: 'number' as const,
36+
description:
37+
'Maximum number of results to return per file. Defaults to 15. There is also a global limit of 250 results across all files',
38+
},
39+
},
40+
required: ['pattern'],
41+
},
42+
description: 'Array of code search queries to execute',
43+
},
44+
},
45+
required: ['searchQueries'],
46+
}
47+
48+
const codeSearcher: SecretAgentDefinition = {
49+
id: 'code-searcher',
50+
displayName: 'Code Searcher',
51+
spawnerPrompt:
52+
'Mechanically runs multiple code search queries (using ripgrep line-oriented search) and returns all results',
53+
model: 'anthropic/claude-sonnet-4.5',
54+
publisher,
55+
outputMode: 'all_messages',
56+
includeMessageHistory: false,
57+
toolNames: ['code_search'],
58+
spawnableAgents: [],
59+
inputSchema: {
60+
params: paramsSchema,
61+
},
62+
handleSteps: function* ({ params }) {
63+
const searchQueries: SearchQuery[] = params?.searchQueries ?? []
64+
65+
for (const query of searchQueries) {
66+
yield {
67+
toolName: 'code_search',
68+
input: {
69+
pattern: query.pattern,
70+
flags: query.flags,
71+
cwd: query.cwd,
72+
maxResults: query.maxResults,
73+
},
74+
}
75+
}
76+
},
77+
}
78+
79+
export default codeSearcher
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { publisher } from '../constants'
2+
3+
import type { SecretAgentDefinition } from '../types/secret-agent-definition'
4+
5+
const codebaseExplorer: SecretAgentDefinition = {
6+
id: 'codebase-explorer',
7+
displayName: 'Codebase Explorer',
8+
spawnerPrompt:
9+
'Orchestrates multiple exploration agents to comprehensively analyze the codebase and answer questions.',
10+
model: 'anthropic/claude-sonnet-4.5',
11+
publisher,
12+
outputMode: 'last_message',
13+
includeMessageHistory: false,
14+
toolNames: ['spawn_agents'],
15+
spawnableAgents: [
16+
'file-picker',
17+
'code-searcher',
18+
'directory-lister',
19+
'glob-matcher',
20+
'file-q-and-a',
21+
],
22+
inputSchema: {
23+
prompt: {
24+
type: 'string',
25+
description: 'A question or exploration goal for the codebase.',
26+
},
27+
},
28+
systemPrompt: `You are a codebase exploration orchestrator. Your job is to spawn multiple specialized agents in parallel waves to comprehensively explore the codebase and answer the user's question.
29+
30+
Strategy:
31+
1. Analyze the user's question to determine what exploration approach would be most effective.
32+
2. You may spawn agents to help you answer the user's question. Feel free to spawn multiple agents in parallel to gather information from different angles.
33+
3. Synthesize all findings into a comprehensive answer.`,
34+
35+
instructionsPrompt: `Analyze the user's prompt and spawn appropriate exploration agents.
36+
37+
Finally, synthesize all findings into a comprehensive answer.`,
38+
}
39+
40+
export default codebaseExplorer
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { publisher } from '../constants'
2+
3+
import type { SecretAgentDefinition } from '../types/secret-agent-definition'
4+
5+
interface ListDirectoryQuery {
6+
path: string
7+
}
8+
9+
const paramsSchema = {
10+
type: 'object' as const,
11+
properties: {
12+
directories: {
13+
type: 'array' as const,
14+
items: {
15+
type: 'object' as const,
16+
properties: {
17+
path: { type: 'string' as const },
18+
},
19+
required: ['path'],
20+
},
21+
description: 'Array of directory paths to list',
22+
},
23+
},
24+
required: ['directories'],
25+
}
26+
27+
const directoryLister: SecretAgentDefinition = {
28+
id: 'directory-lister',
29+
displayName: 'Directory Lister',
30+
spawnerPrompt:
31+
'Mechanically lists multiple directories and returns their contents',
32+
model: 'anthropic/claude-sonnet-4.5',
33+
publisher,
34+
outputMode: 'all_messages',
35+
includeMessageHistory: false,
36+
toolNames: ['list_directory'],
37+
spawnableAgents: [],
38+
inputSchema: {
39+
params: paramsSchema,
40+
},
41+
handleSteps: function* ({ params }) {
42+
const directories: ListDirectoryQuery[] = params?.directories ?? []
43+
44+
for (const directory of directories) {
45+
yield {
46+
toolName: 'list_directory',
47+
input: {
48+
path: directory.path,
49+
},
50+
}
51+
}
52+
},
53+
}
54+
55+
export default directoryLister
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { AgentTemplateTypes } from '@codebuff/common/types/session-state'
22

3-
import { publisher } from './constants'
3+
import { publisher } from '../constants'
44

5-
import type { SecretAgentDefinition } from './types/secret-agent-definition'
5+
import type { SecretAgentDefinition } from '../types/secret-agent-definition'
66

77
const paramsSchema = {
88
type: 'object' as const,
@@ -22,7 +22,7 @@ const fileExplorer: SecretAgentDefinition = {
2222
displayName: 'Dora the File Explorer',
2323
spawnerPrompt:
2424
'Comprehensively explores the codebase and reports back on the results',
25-
model: 'anthropic/claude-4-sonnet-20250522',
25+
model: 'x-ai/grok-4-fast',
2626
publisher,
2727
outputMode: 'structured_output',
2828
includeMessageHistory: false,
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { publisher } from '../constants'
2-
import { filePicker } from 'factory/file-picker'
3-
import { SecretAgentDefinition } from 'types/secret-agent-definition'
2+
import { filePicker } from '../factory/file-picker'
3+
4+
import type { SecretAgentDefinition } from '../types/secret-agent-definition'
45

56
const definition: SecretAgentDefinition = {
6-
...filePicker('x-ai/grok-4-fast'),
7-
id: 'researcher-file-picker',
7+
id: 'file-picker',
88
publisher,
9+
...filePicker('x-ai/grok-4-fast'),
910
}
1011

1112
export default definition

0 commit comments

Comments
 (0)