Skip to content

Commit ea45eda

Browse files
committed
run agent builder
1 parent 4fec62e commit ea45eda

File tree

4 files changed

+186
-10
lines changed

4 files changed

+186
-10
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import type { AgentDefinition } from '../types/agent-definition'
2+
3+
const definition: AgentDefinition = {
4+
id: 'basic-diff-reviewer',
5+
displayName: 'Basic Diff Reviewer',
6+
model: 'anthropic/claude-4-sonnet-20250522',
7+
toolNames: ['read_files', 'run_terminal_command'],
8+
9+
spawnerPrompt: 'Spawn when you need to review code changes in the git diff',
10+
11+
instructionsPrompt: `Execute the following steps:
12+
1. Run git diff
13+
2. Read the files that have changed
14+
3. Review the changes and suggest improvements`,
15+
}
16+
17+
export default definition
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import type {
2+
AgentDefinition,
3+
AgentStepContext,
4+
ToolCall,
5+
} from '../types/agent-definition'
6+
7+
const definition: AgentDefinition = {
8+
id: 'git-committer',
9+
displayName: 'Intermediate Git Committer',
10+
model: 'anthropic/claude-4-sonnet-20250522',
11+
toolNames: ['read_files', 'run_terminal_command', 'add_message', 'end_turn'],
12+
13+
inputSchema: {
14+
prompt: {
15+
type: 'string',
16+
description: 'What changes to commit',
17+
},
18+
},
19+
20+
spawnerPrompt:
21+
'Spawn when you need to commit code changes to git with an appropriate commit message',
22+
23+
systemPrompt:
24+
'You are an expert software developer. Your job is to create a git commit with a really good commit message.',
25+
26+
instructionsPrompt:
27+
'Follow the steps to create a good commit: analyze changes with git diff and git log, read relevant files for context, stage appropriate files, analyze changes, and create a commit with proper formatting.',
28+
29+
handleSteps: function* ({ agentState, prompt, params }: AgentStepContext) {
30+
// Step 1: Run git diff and git log to analyze changes.
31+
yield {
32+
toolName: 'run_terminal_command',
33+
input: {
34+
command: 'git diff',
35+
process_type: 'SYNC',
36+
timeout_seconds: 30,
37+
},
38+
} satisfies ToolCall
39+
40+
yield {
41+
toolName: 'run_terminal_command',
42+
input: {
43+
command: 'git log --oneline -10',
44+
process_type: 'SYNC',
45+
timeout_seconds: 30,
46+
},
47+
} satisfies ToolCall
48+
49+
// Step 2: Put words in AI's mouth so it will read files next.
50+
yield {
51+
toolName: 'add_message',
52+
input: {
53+
role: 'assistant',
54+
content:
55+
"I've analyzed the git diff and recent commit history. Now I'll read any relevant files to better understand the context of these changes.",
56+
},
57+
} satisfies ToolCall
58+
59+
// Step 3: Let AI generate a step to decide which files to read.
60+
yield 'STEP'
61+
62+
// Step 4: Put words in AI's mouth to analyze the changes and create a commit.
63+
yield {
64+
toolName: 'add_message',
65+
input: {
66+
role: 'assistant',
67+
content:
68+
"Now I'll analyze the changes and create a commit with a good commit message.",
69+
},
70+
} satisfies ToolCall
71+
72+
yield 'STEP_ALL'
73+
},
74+
}
75+
76+
export default definition
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import type { AgentDefinition, ToolCall } from '../types/agent-definition'
2+
3+
const definition: AgentDefinition = {
4+
id: 'advanced-file-explorer',
5+
displayName: 'Dora the File Explorer',
6+
model: 'openai/gpt-5',
7+
8+
spawnerPrompt:
9+
'Spawns multiple file picker agents in parallel to comprehensively explore the codebase from different perspectives',
10+
11+
includeMessageHistory: false,
12+
toolNames: ['spawn_agents', 'set_output'],
13+
spawnableAgents: [`codebuff/file-picker@0.0.1`],
14+
15+
inputSchema: {
16+
prompt: {
17+
description: 'What you need to accomplish by exploring the codebase',
18+
type: 'string',
19+
},
20+
params: {
21+
type: 'object',
22+
properties: {
23+
prompts: {
24+
description:
25+
'List of 1-4 different parts of the codebase that could be useful to explore',
26+
type: 'array',
27+
items: {
28+
type: 'string',
29+
},
30+
},
31+
},
32+
required: ['prompts'],
33+
additionalProperties: false,
34+
},
35+
},
36+
outputMode: 'structured_output',
37+
outputSchema: {
38+
type: 'object',
39+
properties: {
40+
results: {
41+
type: 'string',
42+
description: 'The results of the file exploration',
43+
},
44+
},
45+
required: ['results'],
46+
additionalProperties: false,
47+
},
48+
49+
handleSteps: function* ({ prompt, params }) {
50+
const prompts: string[] = params?.prompts ?? []
51+
const filePickerPrompts = prompts.map(
52+
(focusPrompt) =>
53+
`Based on the overall goal "${prompt}", find files related to this specific area: ${focusPrompt}`,
54+
),
55+
{ toolResult: spawnResult } = yield {
56+
toolName: 'spawn_agents',
57+
input: {
58+
agents: filePickerPrompts.map((promptText) => ({
59+
agent_type: 'codebuff/file-picker@0.0.1',
60+
prompt: promptText,
61+
})),
62+
},
63+
} satisfies ToolCall
64+
yield {
65+
toolName: 'set_output',
66+
input: {
67+
results: spawnResult,
68+
},
69+
} satisfies ToolCall
70+
},
71+
}
72+
73+
export default definition

.agents/types/agent-definition.ts

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export interface AgentDefinition {
6262
*/
6363
inputSchema?: {
6464
prompt?: { type: 'string'; description?: string }
65-
params?: JsonSchema
65+
params?: JsonObjectSchema
6666
}
6767

6868
/** Whether to include conversation history from the parent agent in context.
@@ -83,7 +83,7 @@ export interface AgentDefinition {
8383
outputMode?: 'last_message' | 'all_messages' | 'structured_output'
8484

8585
/** JSON schema for structured output (when outputMode is 'structured_output') */
86-
outputSchema?: JsonSchema
86+
outputSchema?: JsonObjectSchema
8787

8888
// ============================================================================
8989
// Prompts
@@ -116,7 +116,7 @@ export interface AgentDefinition {
116116
/** Programmatically step the agent forward and run tools.
117117
*
118118
* You can either yield:
119-
* - A tool call object with toolName and input properties.
119+
* - A tool call object with toolName and args properties.
120120
* - 'STEP' to run agent's model and generate one assistant message.
121121
* - 'STEP_ALL' to run the agent's model until it uses the end_turn tool or stops includes no tool calls in a message.
122122
*
@@ -126,7 +126,7 @@ export interface AgentDefinition {
126126
* function* handleSteps({ agentStep, prompt, params}) {
127127
* const { toolResult } = yield {
128128
* toolName: 'read_files',
129-
* input: { paths: ['file1.txt', 'file2.txt'] }
129+
* args: { paths: ['file1.txt', 'file2.txt'] }
130130
* }
131131
* yield 'STEP_ALL'
132132
* }
@@ -136,7 +136,7 @@ export interface AgentDefinition {
136136
* while (true) {
137137
* yield {
138138
* toolName: 'spawn_agents',
139-
* input: {
139+
* args: {
140140
* agents: [
141141
* {
142142
* agent_type: 'thinker',
@@ -191,19 +191,29 @@ export interface AgentStepContext {
191191
export type ToolCall<T extends ToolName = ToolName> = {
192192
[K in T]: {
193193
toolName: K
194-
input?: Tools.GetToolParams<K>
194+
input: Tools.GetToolParams<K>
195195
}
196196
}[T]
197197

198198
/**
199199
* JSON Schema definition (for prompt schema or output schema)
200200
*/
201-
export interface JsonSchema {
202-
type: string
203-
properties?: Record<string, any>
201+
export type JsonSchema = {
202+
type?:
203+
| 'object'
204+
| 'array'
205+
| 'string'
206+
| 'number'
207+
| 'boolean'
208+
| 'null'
209+
| 'integer'
210+
description?: string
211+
properties?: Record<string, JsonSchema | boolean>
204212
required?: string[]
205-
[key: string]: any
213+
enum?: Array<string | number | boolean | null>
214+
[k: string]: unknown
206215
}
216+
export type JsonObjectSchema = JsonSchema & { type: 'object' }
207217

208218
// ============================================================================
209219
// Available Tools

0 commit comments

Comments
 (0)