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.

Diagram

‘Instructions Impact’

โŒ Vague
‘Help me’

๐Ÿ˜• Unpredictable

โœ… Clear
‘Research AI trends’

๐ŸŽฏ Focused


Quick Start

python
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. 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. 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. 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. 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

python
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


Improve Your Instructions

Diagram

Improvement Cycle

โœ๏ธ Write

๐Ÿงช Test

๐Ÿ‘€ Review

๐Ÿ”ง Improve


Template

Copy this template and fill in the blanks:

python
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.