Skip to content

Commit 9c10f8b

Browse files
committed
Updates for agent-template.d.ts
1 parent 1d719d1 commit 9c10f8b

File tree

1 file changed

+51
-26
lines changed

1 file changed

+51
-26
lines changed

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

Lines changed: 51 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26,32 +26,33 @@ export interface AgentConfig {
2626
/** Human-readable name for the agent */
2727
name: string
2828

29-
/** Description of what this agent does */
29+
/** Description of what this agent does. Provided to the parent agent so it knows when to spawn this agent. */
3030
purpose: string
3131

32-
/** AI model to use for this agent */
32+
/** AI model to use for this agent. Can be any model in OpenRouter: https://openrouter.ai/models */
3333
model: ModelName
3434

35-
/** Main system prompt defining the agent's behavior */
36-
systemPrompt: string
35+
/** Background information for the agent. */
36+
systemPrompt?: string
3737

38-
/** Optional: Tools this agent can use (defaults to common file editing tools) */
38+
/** Instructions for the agent. This prompt is inserted after each user input.
39+
* Updating this prompt is the best way to shape the agent's behavior. */
40+
userInputPrompt?: string
41+
42+
/** Tools this agent can use (defaults to common file editing tools) */
3943
tools?: ToolName[]
4044

41-
/** Optional: Other agents this agent can spawn */
45+
/** Other agents this agent can spawn */
4246
spawnableAgents?: SpawnableAgentName[]
4347

44-
/** Optional: Advanced generator function for programmatic control */
45-
handleSteps?: (context: AgentStepContext) => AsyncGenerator<any, any, any>
46-
}
47-
/**
48-
* Advanced configuration interface with all options (for power users)
49-
*/
50-
export interface AdvancedAgentConfig extends AgentConfig {
51-
/** Version string (defaults to '1.0.0') */
48+
// ============================================================================
49+
// Advanced fields below!
50+
// ============================================================================
51+
52+
/** Version string (if not provided, will default to '0.0.1' and be bumped on each publish) */
5253
version?: string
5354

54-
/** How the agent should output responses (defaults to 'last_message') */
55+
/** How the agent should output responses after spawned (defaults to 'last_message') */
5556
outputMode?: 'last_message' | 'all_messages' | 'json'
5657

5758
/** JSON schema for structured output (when outputMode is 'json') */
@@ -60,31 +61,53 @@ export interface AdvancedAgentConfig extends AgentConfig {
6061
/** Whether to include conversation history (defaults to true) */
6162
includeMessageHistory?: boolean
6263

63-
/** Prompt template for user input (defaults to standard template) */
64-
userInputPrompt?: string
65-
66-
/** Prompt for continuing agent steps (defaults to standard template) */
64+
/** Prompt inserted at each agent step. Powerful for changing the agent's behavior. */
6765
agentStepPrompt?: string
6866

6967
/** Instructions for spawned sub-agents */
7068
parentInstructions?: Record<SpawnableAgentName, string>
69+
70+
/** Programmatically step the agent forward and run tools.
71+
*
72+
* Example:
73+
* function* handleSteps({ agentStep, prompt, params}) {
74+
* const { toolResult } = yield {
75+
* toolName: 'read_files',
76+
* paths: ['file1.txt', 'file2.txt'],
77+
* }
78+
* yield 'STEP_ALL'
79+
* }
80+
*/
81+
handleSteps?: (
82+
context: AgentStepContext
83+
) => Generator<
84+
ToolName | 'STEP' | 'STEP_ALL',
85+
void,
86+
{ agentState: AgentState; toolResult: ToolResult | undefined }
87+
>
7188
}
7289

7390
// ============================================================================
7491
// Supporting Types
7592
// ============================================================================
7693

94+
export interface AgentState {
95+
agentId: string
96+
parentId: string
97+
messageHistory: Message[]
98+
}
99+
77100
/**
78101
* Context provided to handleSteps generator function
79102
*/
80103
export interface AgentStepContext {
81-
agentState: any
82-
prompt: string
83-
params: any
104+
agentState: AgentState
105+
prompt: string | undefined
106+
params: Record<string, any> | undefined
84107
}
85108

86109
/**
87-
* JSON Schema definition (for advanced users)
110+
* JSON Schema definition (for prompt schema or output schema)
88111
*/
89112
export interface JsonSchema {
90113
type: string
@@ -221,8 +244,10 @@ export const FileEditorExample: AgentConfig = {
221244
purpose: 'Specialized in reading and editing files',
222245
model: 'anthropic/claude-4-sonnet-20250522',
223246
tools: ['read_files', 'write_file', 'str_replace', 'end_turn'],
224-
systemPrompt:
225-
'You are a file editing specialist. Help users read, write, and modify files with precision and care.',
247+
userInputPrompt: `
248+
1. Read all the files you need first to get as much context as possible.
249+
2. Make the edits, preferring to use str_replace.
250+
`.trim(),
226251
}
227252

228253
/**
@@ -255,7 +280,7 @@ export const CodeAnalyzerExample: AgentConfig = {
255280
/**
256281
* Example configuration using advanced features
257282
*/
258-
export const AdvancedExample: AdvancedAgentConfig = {
283+
export const AdvancedExample: AgentConfig = {
259284
id: 'advanced-agent',
260285
name: 'Advanced Agent',
261286
purpose: 'Demonstrates advanced configuration options',

0 commit comments

Comments
 (0)