Skip to content

Commit ab4819b

Browse files
committed
Update agent builder a bit
1 parent 73bcca5 commit ab4819b

File tree

6 files changed

+56
-40
lines changed

6 files changed

+56
-40
lines changed

backend/src/templates/agents/agent-builder.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
openrouterModels,
77
AGENT_DEFINITION_FILE,
88
} from '@codebuff/common/constants'
9-
import { AgentTemplateTypes } from '@codebuff/common/types/session-state'
109
import z from 'zod/v4'
1110

1211
import type { AgentTemplate } from '../types'
@@ -64,7 +63,10 @@ export const agentBuilder = (
6463

6564
files
6665
.filter(
67-
(file) => file.endsWith('.ts') && file.startsWith('diff-reviewer'),
66+
(file) =>
67+
file.endsWith('.ts') &&
68+
(file.startsWith('diff-reviewer') ||
69+
file === 'your-custom-agent.ts'),
6870
)
6971
.forEach((filename) => {
7072
try {
@@ -119,15 +121,7 @@ export const agentBuilder = (
119121
'set_output',
120122
'end_turn',
121123
] satisfies ToolName[],
122-
spawnableAgents: allAvailableAgents
123-
? (allAvailableAgents as any[])
124-
: [
125-
AgentTemplateTypes.file_picker,
126-
AgentTemplateTypes.researcher,
127-
AgentTemplateTypes.thinker,
128-
AgentTemplateTypes.reviewer,
129-
AgentTemplateTypes.agent_builder,
130-
],
124+
spawnableAgents: [],
131125

132126
systemPrompt: [
133127
'# Bob the Agent Builder',
@@ -270,11 +264,17 @@ IMPORTANT: Always end your response with the end_turn tool when you have complet
270264
// Step 5: Copy example agent files to .agents/ directory
271265
for (const [filename, content] of Object.entries(exampleAgentContents)) {
272266
if (content) {
267+
// Copy your-custom-agent.ts to top level .agents directory, others to examples
268+
const targetPath =
269+
filename === 'your-custom-agent.ts'
270+
? `${AGENT_TEMPLATES_DIR}/${filename}`
271+
: `${EXAMPLES_DIR}/${filename}`
272+
273273
yield {
274274
toolName: 'write_file',
275275
args: {
276-
path: `${EXAMPLES_DIR}/${filename}`,
277-
instructions: `Copy example agent file ${filename}`,
276+
path: targetPath,
277+
instructions: `Copy ${filename === 'your-custom-agent.ts' ? 'custom agent template' : 'example agent'} file ${filename}`,
278278
content: content,
279279
},
280280
}

common/src/constants/agents.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@ export const AGENT_PERSONAS = {
2424
purpose: 'Base agent that orchestrates the full response.',
2525
} as const,
2626

27-
base_agent_builder: {
28-
displayName: 'Buffy the Enthusiastic Agent Builder',
29-
purpose:
30-
'Enhanced base agent that can create custom agents and handle all coding tasks',
31-
} as const,
32-
3327
superagent: {
3428
displayName: 'Superagent',
3529
purpose:
@@ -77,7 +71,7 @@ export const AGENT_PERSONAS = {
7771
} as const,
7872
agent_builder: {
7973
displayName: 'Bob the Agent Builder',
80-
purpose: 'Creates new agent templates for the codebuff mult-agent system',
74+
purpose: 'Creates new agent templates for the codebuff multi-agent system',
8175
hidden: false,
8276
} as const,
8377
} as const satisfies Partial<

common/src/util/examples/diff-reviewer-1.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ import type { AgentDefinition } from '../types/agent-definition'
22

33
const definition: AgentDefinition = {
44
id: 'diff-reviewer-1',
5-
65
displayName: 'Diff Reviewer (Level 1)',
7-
model: 'openai/gpt-5',
6+
model: 'anthropic/claude-4-sonnet-20250522',
87
toolNames: ['read_files', 'run_terminal_command'],
98

109
spawnPurposePrompt:

common/src/util/examples/diff-reviewer-2.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
const definition: AgentDefinition = {
77
id: 'diff-reviewer-2',
88
displayName: 'Diff Reviewer (Level 2)',
9-
model: 'openai/gpt-5',
9+
model: 'anthropic/claude-4-sonnet-20250522',
1010

1111
inputSchema: {
1212
prompt: {

common/src/util/examples/diff-reviewer-3.ts

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ import type {
55

66
const definition: AgentDefinition = {
77
id: 'diff-reviewer-3',
8-
98
displayName: 'Diff Reviewer (Level 3)',
10-
model: 'openai/gpt-5',
9+
model: 'anthropic/claude-4-sonnet-20250522',
1110
inputSchema: {
1211
prompt: {
1312
type: 'string',
@@ -18,7 +17,7 @@ const definition: AgentDefinition = {
1817
outputMode: 'last_message',
1918

2019
toolNames: ['read_files', 'run_terminal_command', 'spawn_agents'],
21-
spawnableAgents: ['james/file-explorer@0.1.3'],
20+
spawnableAgents: ['codebuff/file-explorer@0.0.1'],
2221

2322
spawnPurposePrompt:
2423
'Spawn when you need to review code changes in the git diff',
@@ -77,23 +76,11 @@ Use the following guidelines while reviewing the changes:
7776
args: {
7877
role: 'assistant',
7978
content:
80-
'Now I will spawn a file explorer to find any missing codebase context.',
81-
},
82-
}
83-
84-
yield 'STEP'
85-
86-
// Step 5: Put words in the AI's mouth to review the changes.
87-
yield {
88-
toolName: 'add_message',
89-
args: {
90-
role: 'assistant',
91-
content: 'Here is my comprehensive review of the changes.',
79+
'Now I will spawn a file explorer to find any missing codebase context, and then review the changes.',
9280
},
9381
}
9482

95-
// Step 6: Let AI review the changes in a final step. (The last message is also the agent's output.)
96-
yield 'STEP'
83+
yield 'STEP_ALL'
9784
},
9885
}
9986

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* EDIT ME to create your own agent!
3+
*
4+
* Change any field below, and consult the AgentDefinition type for information on all fields and their purpose.
5+
*
6+
* Run your agent with:
7+
* > codebuff --agent git-committer
8+
*
9+
* Or, run codebuff normally, and use the '@' menu to mention your agent, and codebuff will spawn it for you.
10+
*
11+
* Finally, you can publish your agent with 'codebuff publish your-custom-agent'.
12+
*/
13+
14+
import type { AgentDefinition } from './types/agent-definition'
15+
16+
const definition: AgentDefinition = {
17+
id: 'git-committer',
18+
displayName: 'Git Committer',
19+
20+
model: 'anthropic/claude-4-sonnet-20250522',
21+
toolNames: ['read_files', 'run_terminal_command', 'spawn_agents'],
22+
spawnableAgents: ['codebuff/file-explorer@0.0.1'],
23+
24+
spawnPurposePrompt:
25+
'Spawn when you need to commit changes to the git repository',
26+
27+
instructionsPrompt: `Execute the following steps:
28+
1. Run git diff
29+
2. Spawn a file explorer to find all relevant files to the change so you have the maximum context
30+
3. Read any relevant files
31+
4. Commit the changes to the git repository with a message that describes the changes`,
32+
33+
// Add more fields here to customize your agent further: system prompt, input/output schema, handleSteps, etc.
34+
}
35+
36+
export default definition

0 commit comments

Comments
 (0)