
AI Agent Step by Step
Episode 2: AI Agent Step by Step for Evaluators
A Step-by-Step Tutorial for M&E Professionals
What You Will Build
A practical AI agent that automates evaluation tasks like indicator tracking, report drafting, and data quality review. This tutorial guides you through every step from choosing tools to deploying your first working agent.
Prerequisites
Before you start, ensure you have:
- A computer with internet connection (Windows, Mac, or Linux)
- Basic understanding of your M&E workflows (no coding required)
- An account with Anthropic Claude, OpenAI, or Google Gemini (we will walk through this)
- Google account for integration (optional but helpful)
- 30-45 minutes of focused time for setup
Step 1: Choosing Your AI Tool
The first step is selecting which AI model to use. Here is a comparison of the top options for evaluation work:
| AI Tool | Best For | Cost | Setup Difficulty |
|---|---|---|---|
| Claude (Anthropic) | Analysis, coding, structured outputs | $20/month or pay-per-use | Easy |
| OpenAI GPT-4 | Versatile, wide capabilities | $20/month or pay-per-use | Medium |
| Google Gemini | Integration with Google services | Free tier available | Easy |
Recommendation for Evaluators: Start with Claude or Gemini. Both offer excellent reasoning capabilities and are user-friendly for beginners.
Step 2: Creating Your Account
2.1 For Claude (Anthropic)
Instructions:
- Go to claude.ai in your web browser
- Click the “Sign Up” or “Try Claude” button
- Enter your email address and create a password
- Verify your email address (check your inbox for confirmation link)
- Choose a subscription plan (free tier available for basic use)
- Complete your profile with your name and organization (optional)
2.2 For Google Gemini
Instructions:
- Go to gemini.google.com in your browser
- Sign in with your existing Google account, or create one
- Accept the terms of service
- Your Gemini account is now ready to use
Success Check: You should be able to log in and see the chat interface. Try typing a simple test question like “Hello, can you help me with evaluation work?”
Step 3: Installing Required Software
3.1 Install Python (if not already installed)
For Windows:
- Go to python.org/downloads
- Click the yellow “Download Python” button
- Run the installer when downloaded
- Check the box “Add Python to PATH” (this is very important)
- Click “Install Now” and wait for installation to complete
For Mac:
- Open Terminal (search for it in Spotlight or Applications/Utilities)
- Type:
python3 --versionto check if installed - If not installed, go to python.org/downloads and download for Mac
- Follow the installation wizard
3.2 Install a Code Editor
You need a place to write and edit your code. We recommend Visual Studio Code (free):
- Go to code.visualstudio.com
- Click the download button for your operating system
- Run the installer and follow the prompts
- Once installed, open VS Code
- Go to Extensions (icon on left sidebar or Ctrl+Shift+X)
- Search for and install “Python” extension by Microsoft
Step 4: Setting Up Your Project Folder
4.1 Create Your Project Directory
On Windows:
- Open File Explorer
- Navigate to Documents or Desktop
- Right-click and select “New Folder”
- Name it:
eval_agent - Right-click inside the folder and select “Open with Code” (if VS Code installed)
On Mac:
- Open Terminal
- Type:
cd ~/Documents - Type:
mkdir eval_agent - Type:
cd eval_agent - Type:
code .to open in VS Code
4.2 Create Your First Files
In VS Code, create the following files:
- Click the “New File” icon (or Ctrl+N / Cmd+N)
- Save as
agent.py(File → Save As) - Create another file:
.env - Create another file:
requirements.txt
Step 5: Getting Your API Key
You need an API key to connect your agent to the AI model. The API key works like a password that allows your code to access the AI service.
5.1 Get Claude API Key
- Log in to console.anthropic.com
- Go to “API Keys” in the left sidebar
- Click “Create API Key”
- Give it a name like “eval_agent”
- Copy the key that appears (you will not see it again)
- Paste it into your
.envfile
5.2 Get Google Gemini API Key
- Go to makersuite.google.com/app/apikey
- Click “Create API Key”
- Select the project or create a new one
- Copy the generated API key
- Paste it into your
.envfile
5.3 Configure Your .env File
# For Claude
ANTHROPIC_API_KEY=sk-ant-your-key-here# For Gemini (if using)GOOGLE_API_KEY=AIza-your-key-here
# Your timezone (optional)TIMEZONE=UTC
Security Tip: Never share your .env file publicly. Add .env to your .gitignore if using version control.
Step 6: Installing Required Packages
Open your requirements.txt file and add these lines:
anthropic
openai
google-generativeai
python-dotenv
requests
Then, open Terminal (VS Code has one built-in: View → Terminal) and run:
pip install -r requirements.txt
Wait for the installation to complete. You should see “Successfully installed” messages.
Step 7: Writing Your First Agent Code
Open your agent.py file and add this code:
import os
from dotenv import load_dotenv
import anthropic
# Load environment variables
load_dotenv()
# Initialize the Claude client
client = anthropic.Anthropic(
api_key=os.getenv("ANTHROPIC_API_KEY")
)
def evaluate_indicators(indicator_data):
"""
AI agent function to analyze M&E indicators
"""
prompt = f"""
You are an M&E specialist. Analyze the following indicator data:
{indicator_data}
Please provide:
1. Summary of overall performance
2. Indicators that are off-track (below 80% achievement)
3. Three recommendations for improvement
"""
response = client.messages.create(
model="claude-3-sonnet-20240229",
max_tokens=1000,
temperature=0.3,
messages=[
{"role": "user", "content": prompt}
]
)
return response.content[0].text
# Test the agent
if __name__ == "__main__":
sample_data = """
Indicator 1: Students enrolled - Target: 1000, Actual: 850 (85%)
Indicator 2: Teachers trained - Target: 50, Actual: 35 (70%)
Indicator 3: Schools reached - Target: 20, Actual: 18 (90%)
"""
print("Running evaluation agent...")
result = evaluate_indicators(sample_data)
print("\nAI Agent Analysis:")
print("-" * 40)
print(result)
Success Check: This code is ready to run! The next step will show you how to execute it.
Step 8: Running Your Agent
To run your agent:
- In VS Code, make sure you are in the
eval_agentfolder - Open Terminal (View → Terminal)
- Type:
python agent.py - Press Enter and wait for the response
# Expected output:
Running evaluation agent...
AI Agent Analysis:
----------------------------------------
Based on the indicator data provided, here is my analysis:
1. Overall Performance Summary:
- Average achievement across indicators: 81.6%
- 2 out of 3 indicators are on track (>80%)
- 1 indicator is below target
2. Off-Track Indicators:
- Teachers trained: 70% achievement (35/50)
* This is a critical indicator for program success
* 30% shortfall may impact quality of implementation
3. Recommendations for Improvement:
- Review training methodology and consider refresher sessions
- Analyze barriers to teacher participation
- Consider providing incentives or support materials
Step 9: Customizing Your Agent for Real M&E Data
Now that your agent works, customize it for your actual evaluation needs:
def custom_eval_agent(indicator_data, donor_requirements):
"""
Custom agent tailored to your M&E workflow
"""
# 1. Load your specific data
# 2. Apply validation rules
# 3. Generate donor-ready reports
# 4. Flag risks and issues
prompt = f"""
You are a senior M&E expert. Analyze this data:
{indicator_data}
Donor requirements: {donor_requirements}
Generate:
1. A concise executive summary
2. Performance table with green/yellow/red status
3. Key recommendations (max 5)
4. Evidence gaps that need attention
"""
# Your code here
pass
Step 10: Troubleshooting Common Issues
| Issue | Solution |
|---|---|
| Module not found | Run pip install -r requirements.txt again |
| API Key error | Check your .env file and verify the key is correct |
| Connection timeout | Check your internet connection and try again |
| No output | Add print() statements to debug |
Step 11: What’s Next – Expanding Your Agent
Your agent can grow to handle more complex evaluation tasks:
- Connect to Google Sheets or Excel for data input
- Automate weekly or monthly reporting
- Add data quality validation rules
- Generate visualizations and graphs
- Create multi-language reports
Summary Checklist
You have successfully completed:
- Choosing an AI tool (Claude, Gemini, or OpenAI)
- Creating your account and getting an API key
- Installing Python and required software
- Setting up your project folder and files
- Writing your first agent code
- Running your agent with sample data
Take Your AI Agent Skills to the Next Level
Build professional AI agents for evaluation with the AI Agents for Evaluators Certificate – a practical course designed for M&E professionals.
What you will learn:
- Design AI agents for common M&E workflows
- Build reusable prompts with validation rules
- Connect tools like ChatGPT, Claude, Sheets, Make.com, and Zapier
- Validate AI outputs against evidence
- Create a final AI agent package for your own practice
Course Features: 32 lectures · Lifetime access · Certificate included · Self-paced · 241 students enrolled
Enroll Now – $249 Lifetime Access
Best Value: Bundle with AI in M&E course and save 30%
Congratulations on building your first AI agent! Share your experience and questions in the comments below.
Ready to go deeper?
Get certified in building AI agents for evaluation with the AI Agents for Evaluators Certificate.
