Creating Effective Agent Instructions
How to write clear instructions for your AI agents
Instructions are the most important part of your agent. Good instructions = great results.
Quick Start
from praisonaiagents import Agent
# Simple but effective instructions
agent = Agent(
instructions="You are a helpful coding assistant. Explain concepts simply and provide working code examples."
)
agent.start("How do I read a file in Python?")The 4 Parts of Great Instructions
- 1. Role – Who is the agent?
python # โ Vague instructions = "You are a helper" # โ Clear instructions = "You are a senior Python developer with 10 years of experience" - 2. Goal – What should it achieve?
python # โ Vague instructions = "Help with code" # โ Clear instructions = "Help users write clean, efficient Python code with proper error handling" - 3. Style – How should it respond?
python # โ No guidance instructions = "Answer questions" # โ Clear style instructions = "Answer in bullet points. Keep explanations under 3 sentences." - 4. Constraints – What should it avoid?
python # โ With boundaries instructions = """You are a coding assistant. - Only answer programming questions - Never execute dangerous commands - Ask for clarification if the question is unclear"""
Complete Example
from praisonaiagents import Agent
agent = Agent(
name="CodeHelper",
instructions="""You are a senior Python developer.
Your goal: Help users write clean, working Python code.
When answering:
1. First understand what the user wants
2. Provide a working code example
3. Explain the key parts briefly
Style:
- Use simple language
- Include comments in code
- Show expected output
Constraints:
- Only answer Python questions
- Keep explanations short
- Ask if something is unclear"""
)
agent.start("How do I sort a list of dictionaries by a key?")Good vs Bad Instructions
| Aspect | โ Bad | โ Good |
|---|---|---|
| Role | “You are a helper” | “You are a data analyst” |
| Goal | “Help with stuff” | “Analyze sales data and find trends” |
| Style | (none) | “Use bullet points and charts” |
| Constraints | (none) | “Focus only on the provided data” |
Common Mistakes
Too Vague
“Help me” โ Agent doesn’t know what to do
Too Long1000+ words โ Agent gets confused
Contradictory“Be brief” + “Explain everything” โ Conflict
No ExamplesNo sample output โ Inconsistent format
Improve Your Instructions
Template
Copy this template and fill in the blanks:
from praisonaiagents import Agent
agent = Agent(
instructions="""You are a [ROLE] with expertise in [AREA].
Your goal: [WHAT TO ACHIEVE]
When responding:
1. [FIRST STEP]
2. [SECOND STEP]
3. [THIRD STEP]
Style: [HOW TO FORMAT RESPONSES]
Constraints:
- [WHAT TO AVOID]
- [BOUNDARIES]"""
)Next: Agent Tools
Learn how to give your agents superpowers with tools.