Prompts define the instructions and configuration for LLM interactions in Standard Agents. Each prompt specifies system instructions, model configuration, tools, input validation, and context options.
Key Features
File-based: Defined in agents/prompts/ directory
Auto-discovered: No manual registration required
Type-safe: Full TypeScript support with Zod validation
Composable: Prompts can be exposed as tools for other prompts
Hot-reloadable: Changes trigger HMR in development
import { definePrompt } from '@standardagents/builder';export default definePrompt({ name: 'customer_support', toolDescription: 'Handle customer support inquiries', prompt: `You are a helpful customer support agent.Always be polite and try to resolve issues quickly.`, model: 'gpt-4o', includeChat: true,});
Reference it in an agent:
agents/agents/support_agent.ts
Copy
import { defineAgent } from '@standardagents/builder';export default defineAgent({ name: 'support_agent', sideA: { prompt: 'customer_support', // References the prompt above },});
Zod schema for input validation when called as tool.
Copy
requiredSchema: z.object({ userId: z.string().describe('The user ID to look up'), includeHistory: z.boolean().optional().describe('Include transaction history'),})
import { definePrompt } from '@standardagents/builder';import { z } from 'zod';export default definePrompt({ name: 'user_lookup', toolDescription: 'Look up user information', prompt: 'You help find user information...', model: 'gpt-4o', requiredSchema: z.object({ userId: z.string().describe('The user ID to look up'), includeHistory: z.boolean().optional().describe('Include transaction history'), }),});
import { definePrompt } from '@standardagents/builder';import { z } from 'zod';export default definePrompt({ name: 'customer_support', toolDescription: 'Handle customer support inquiries', prompt: `You are a customer support agent for Acme Corp.Your responsibilities:- Answer questions about products and services- Help resolve issues on first contact- Create support tickets when needed- Escalate to specialists for complex issuesAlways be professional and empathetic.`, model: 'gpt-4o', includeChat: true, tools: [ 'search_knowledge_base', 'lookup_customer', { name: 'create_ticket', includeErrors: true }, ], handoffAgents: ['specialist_agent'],});
interface PromptDefinition< N extends string = string, S extends z.ZodTypeAny = z.ZodTypeAny> { /** Unique name for this prompt */ name: N; /** Description shown when exposed as tool */ toolDescription: string; /** System prompt sent to LLM */ prompt: string; /** Model configuration to use */ model: StandardAgents.Models; /** Expose as callable tool for other prompts */ exposeAsTool?: boolean; /** Include full chat history in LLM context */ includeChat?: boolean; /** Include past tool call results in context */ includePastTools?: boolean; /** Allow parallel execution of tool calls */ parallelToolCalls?: boolean; /** Tool calling strategy */ toolChoice?: 'auto' | 'none' | 'required'; /** Zod schema for input validation */ requiredSchema?: S; /** Available tools */ tools?: (StandardAgents.Callables | ToolConfig)[]; /** Agents that can receive handoffs */ handoffAgents?: StandardAgents.Agents[]; /** Tool to execute before LLM request */ beforeTool?: StandardAgents.Callables; /** Tool to execute after LLM response */ afterTool?: StandardAgents.Callables; /** Extended thinking configuration */ reasoning?: ReasoningConfig;}
interface ToolConfig<T extends string = StandardAgents.Callables> { /** Name of the tool */ name: T; /** Include text response from sub-prompt */ includeTextResponse?: boolean; /** Include tool call details from sub-prompt */ includeToolCalls?: boolean; /** Include error details from sub-prompt */ includeErrors?: boolean; /** Property from args to use as initial message */ initUserMessageProperty?: string;}
// Good - clear structure and expectationsdefinePrompt({ name: 'support_agent', prompt: `You are a customer support agent for Acme Corp.## Your Role- Answer questions about products and services- Help resolve issues on first contact- Create tickets for complex issues## Guidelines- Be professional and empathetic- Ask clarifying questions when needed- Never share internal information## Available ToolsUse these tools to help customers:- search_knowledge_base: Find product information- create_ticket: Create support tickets`, // ...});// Avoid - vague instructionsdefinePrompt({ name: 'support_agent', prompt: 'Help customers.', // ...});
Use Descriptive Tool Descriptions
Copy
// Good - specific and actionabledefinePrompt({ name: 'search_prompt', toolDescription: 'Search the knowledge base for product information, FAQs, and troubleshooting guides. Returns relevant articles.', // ...});// Avoid - too vaguedefinePrompt({ name: 'search_prompt', toolDescription: 'Search stuff', // ...});
Validate Inputs with Zod
Copy
// Good - detailed schema with descriptionsrequiredSchema: z.object({ customerId: z.string().min(1).describe('Customer ID from CRM'), issue: z.string().min(10).describe('Description of the issue'), priority: z.enum(['low', 'medium', 'high']).default('medium'),}).strict()// Avoid - no validationrequiredSchema: z.object({ data: z.any(),})
Enable includeChat for Conversations
Copy
// For conversational promptsdefinePrompt({ name: 'chat_assistant', includeChat: true, // Needed for context // ...});// For single-shot tasksdefinePrompt({ name: 'code_formatter', includeChat: false, // No history needed // ...});