Skip to content

Commit 44b2e4b

Browse files
committed
Tweak agent builder & agent template
1 parent 518ddca commit 44b2e4b

File tree

2 files changed

+41
-33
lines changed

2 files changed

+41
-33
lines changed

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

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ export const agentBuilder = (model: Model): Omit<AgentTemplate, 'id'> => {
111111
'',
112112
'## Best Practices:',
113113
'',
114-
'1. **Purpose-Driven**: Each agent should have a clear, specific purpose',
114+
'1. **Use as few fields as possible**: Leave out fields that are not needed to reduce complexity. Use as few fields as possible to accomplish the task.',
115115
'2. **Minimal Tools**: Only include tools the agent actually needs',
116-
'3. **Clear Prompts**: Write clear, specific system prompts',
116+
'3. **Clear and Concise Prompts**: Write clear, specific prompts that have no unnecessary words',
117117
'4. **Consistent Naming**: Follow naming conventions (kebab-case for IDs)',
118118
'5. **Appropriate Model**: Choose the right model for the task complexity',
119119
'',
@@ -141,8 +141,8 @@ export const agentBuilder = (model: Model): Omit<AgentTemplate, 'id'> => {
141141
142142
For new agents, analyze their request and create a complete agent template that:
143143
- Has a clear purpose and appropriate capabilities
144+
- Leaves out fields that are not needed.
144145
- Uses only the tools it needs
145-
- Has a well-written system prompt
146146
- Follows naming conventions
147147
- Is properly structured
148148
@@ -156,25 +156,10 @@ For editing existing agents:
156156
When editing, always start by reading the current agent file to understand its structure before making changes. Ask clarifying questions if needed, then create or update the template file in the appropriate location.
157157
158158
IMPORTANT: Always end your response with the end_turn tool when you have completed the agent creation or editing task.`,
159-
stepPrompt: `Continue working on the agent template creation or editing. Focus on:
160-
- Understanding the requirements
161-
- Creating or updating a well-structured template
162-
- Following best practices
163-
- Ensuring the agent will work effectively for its intended purpose
164-
- For edits: preserving existing functionality while making requested changes
165-
166-
IMPORTANT: Always end your response with the end_turn tool when you have completed the agent creation or editing task.`,
159+
stepPrompt: '',
167160

168161
// Generator function that defines the agent's execution flow
169-
handleSteps: function* ({
170-
agentState,
171-
prompt,
172-
params,
173-
}: {
174-
agentState: any
175-
prompt: string | undefined
176-
params: Record<string, any> | undefined
177-
}) {
162+
handleSteps: function* ({ agentState, prompt, params }) {
178163
// Step 1: Create directory structure
179164
yield {
180165
toolName: 'run_terminal_command',
@@ -252,12 +237,6 @@ Please create the complete agent template now.`,
252237

253238
// Step 5: Complete agent creation process
254239
yield 'STEP_ALL'
255-
256-
// Step 6: End the turn explicitly
257-
yield {
258-
toolName: 'end_turn',
259-
args: {},
260-
}
261240
},
262241
}
263242
}

common/src/templates/agent-template.d.ts

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,11 @@ export interface AgentConfig {
4343
// Prompts
4444
// ============================================================================
4545

46-
/** Prompt for when to spawn this agent as a subagent. Include the main purpose and use cases. */
46+
/** Prompt for when to spawn this agent as a subagent. Include the main purpose and use cases.
47+
* This field is key if the agent is a subagent and intended to be spawned. */
4748
parentPrompt?: string
4849

49-
/** Background information for the agent. Prefer using instructionsPrompt for agent instructions. */
50+
/** Background information for the agent. Fairly optional. Prefer using instructionsPrompt for agent instructions. */
5051
systemPrompt?: string
5152

5253
/** Instructions for the agent.
@@ -55,7 +56,7 @@ export interface AgentConfig {
5556
instructionsPrompt?: string
5657

5758
/** Prompt inserted at each agent step. Powerful for changing the agent's behavior,
58-
* but prefer instructionsPrompt for most instructions. */
59+
* but usually not necessary for smart models. Prefer instructionsPrompt for most instructions. */
5960
stepPrompt: string
6061

6162
/** Instructions for specific parent agents on when to spawn this agent as a subagent. */
@@ -65,19 +66,26 @@ export interface AgentConfig {
6566
// Input and Output
6667
// ============================================================================
6768

68-
/** The input schema required to spawn the agent. Provide a prompt string and/or a params object. */
69+
/** The input schema required to spawn the agent. Provide a prompt string and/or a params object or none.
70+
* 80% of the time you want just a prompt string with a description:
71+
* inputSchema: {
72+
* prompt: { type: 'string', description: 'A description of what info would be helpful to the agent' }
73+
* }
74+
*/
6975
inputSchema?: {
7076
prompt?: { type: 'string'; description?: string }
7177
params?: JsonSchema
7278
}
7379

74-
/** Whether to include conversation history (defaults to true) */
80+
/** Whether to include conversation history. Defaults to false.
81+
* Use this if the agent needs to know all the previous messages in the conversation.
82+
*/
7583
includeMessageHistory?: boolean
7684

7785
/** How the agent should output a response to its parent (defaults to 'last_message')
7886
* last_message: The last message from the agent, typcically after using tools.
7987
* all_messages: All messages from the agent, including tool calls and results.
80-
* json: Make the agent output a structured JSON object. Can be used with outputSchema or without if you want freeform json output.
88+
* json: Make the agent output a JSON object. Can be used with outputSchema or without if you want freeform json output.
8189
*/
8290
outputMode?: 'last_message' | 'all_messages' | 'json'
8391

@@ -97,14 +105,35 @@ export interface AgentConfig {
97105
*
98106
* Or use 'return' to end the turn.
99107
*
100-
* Example:
108+
* Example 1:
101109
* function* handleSteps({ agentStep, prompt, params}) {
102110
* const { toolResult } = yield {
103111
* toolName: 'read_files',
104112
* args: { paths: ['file1.txt', 'file2.txt'] }
105113
* }
106114
* yield 'STEP_ALL'
107115
* }
116+
*
117+
* Example 2:
118+
* handleSteps: function* ({ agentState, prompt, params }) {
119+
* while (true) {
120+
* yield {
121+
* toolName: 'spawn_agents',
122+
* args: {
123+
* agents: [
124+
* {
125+
* agent_type: 'thinker',
126+
* prompt: 'Think deeply about the user request',
127+
* },
128+
* ],
129+
* },
130+
* }
131+
* const { toolResult: thinkResult } = yield 'STEP'
132+
* if (thinkResult?.toolName === 'end_turn') {
133+
* break
134+
* }
135+
* }
136+
* }
108137
*/
109138
handleSteps?: (
110139
context: AgentStepContext

0 commit comments

Comments
 (0)