@@ -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,29 +56,33 @@ 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
61- /** Instructions for specific parent agents on when to spawn this agent as a subagent. */
62- parentInstructions ?: Record < SubagentName , string >
63-
6462 // ============================================================================
6563 // Input and Output
6664 // ============================================================================
6765
68- /** The input schema required to spawn the agent. Provide a prompt string and/or a params object. */
66+ /** The input schema required to spawn the agent. Provide a prompt string and/or a params object or none.
67+ * 80% of the time you want just a prompt string with a description:
68+ * inputSchema: {
69+ * prompt: { type: 'string', description: 'A description of what info would be helpful to the agent' }
70+ * }
71+ */
6972 inputSchema ?: {
7073 prompt ?: { type : 'string' ; description ?: string }
7174 params ?: JsonSchema
7275 }
7376
74- /** Whether to include conversation history (defaults to true) */
77+ /** Whether to include conversation history. Defaults to false.
78+ * Use this if the agent needs to know all the previous messages in the conversation.
79+ */
7580 includeMessageHistory ?: boolean
7681
7782 /** How the agent should output a response to its parent (defaults to 'last_message')
7883 * last_message: The last message from the agent, typcically after using tools.
7984 * 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.
85+ * json: Make the agent output a JSON object. Can be used with outputSchema or without if you want freeform json output.
8186 */
8287 outputMode ?: 'last_message' | 'all_messages' | 'json'
8388
@@ -97,14 +102,35 @@ export interface AgentConfig {
97102 *
98103 * Or use 'return' to end the turn.
99104 *
100- * Example:
105+ * Example 1 :
101106 * function* handleSteps({ agentStep, prompt, params}) {
102107 * const { toolResult } = yield {
103108 * toolName: 'read_files',
104109 * args: { paths: ['file1.txt', 'file2.txt'] }
105110 * }
106111 * yield 'STEP_ALL'
107112 * }
113+ *
114+ * Example 2:
115+ * handleSteps: function* ({ agentState, prompt, params }) {
116+ * while (true) {
117+ * yield {
118+ * toolName: 'spawn_agents',
119+ * args: {
120+ * agents: [
121+ * {
122+ * agent_type: 'thinker',
123+ * prompt: 'Think deeply about the user request',
124+ * },
125+ * ],
126+ * },
127+ * }
128+ * const { toolResult: thinkResult } = yield 'STEP'
129+ * if (thinkResult?.toolName === 'end_turn') {
130+ * break
131+ * }
132+ * }
133+ * }
108134 */
109135 handleSteps ?: (
110136 context : AgentStepContext
@@ -148,8 +174,8 @@ export interface ToolResult {
148174 */
149175export interface AgentStepContext {
150176 agentState : AgentState
151- prompt : string | undefined
152- params : Record < string , any > | undefined
177+ prompt ? : string
178+ params ? : Record < string , any >
153179}
154180
155181/**
@@ -257,7 +283,7 @@ export type ModelName =
257283 | 'google/gemini-2.5-pro'
258284 | 'google/gemini-2.5-flash'
259285 | 'x-ai/grok-4-07-09'
260- | string
286+ | ( string & { } )
261287
262288// ============================================================================
263289// Spawnable Agents
@@ -272,7 +298,7 @@ export type SubagentName =
272298 | 'researcher'
273299 | 'thinker'
274300 | 'reviewer'
275- | string
301+ | ( string & { } )
276302
277303// ============================================================================
278304// Utility Types
0 commit comments