Writing Agent Instructions
Craft instructions that produce consistent, high-quality agent behavior.Overview
Instructions define how your agent behaves—its personality, communication style, decision-making approach, and operational boundaries. Well-written instructions are the difference between an agent that delights users and one that frustrates them.Instruction Structure
A complete instruction set covers these areas:Writing the Role
Define the agent’s identity and purpose clearly.Good Roles
Avoid Vague Roles
Defining Guidelines
Guidelines shape day-to-day behavior.Behavioral Guidelines
Task-Specific Guidelines
Response Format
Tell the agent how to structure outputs.Format Guidelines
Examples
Setting Constraints
Define clear boundaries for what agents should never do.Security Constraints
Behavioral Constraints
Scope Constraints
Handling Edge Cases
Prepare agents for unusual situations.Testing Instructions
Validate that instructions produce desired behavior.Test Cases
Create test scenarios:Iteration Process
- Write initial instructions
- Test with representative queries
- Identify gaps or undesired behaviors
- Refine instructions
- Repeat