CrewAI Basics
Master CrewAI framework for orchestrating role-playing autonomous AI agents
Your Progress
0 / 5 completedDefining Agents & Roles
In CrewAI, agents are defined by three core attributes: their role (job title), goal (what they aim to achieve), and backstory (expertise and context). This role-based design makes agents feel like real team members with distinct personalities and expertise.
Interactive: Explore Agent Roles
Senior Researcher
Curious, thorough, skeptical of hype
🔧 Creating an Agent in Code
from crewai import Agent
from crewai_tools import SerperDevTool
researcher = Agent(
role='Senior Researcher',
goal='Uncover cutting-edge developments in AI and data science',
backstory="""You work at a leading tech think tank.
Your expertise lies in identifying emerging trends and
analyzing their implications for the industry.""",
verbose=True,
allow_delegation=False, # Can this agent delegate work?
tools=[SerperDevTool()] # Give agent access to tools
)✨ Agent Attributes Explained
role (string)
The job title or functional role. This shapes how the agent approaches tasks. Examples: "Data Scientist", "Marketing Strategist", "Code Reviewer".
goal (string)
The overarching objective the agent is trying to achieve. Should be specific and measurable. Guides decision-making and prioritization.
backstory (string)
Context about the agent's expertise, experience, and personality. Helps the LLM roleplay more authentically. Can be creative and detailed.
tools (list)
Tools the agent can use to accomplish tasks. Examples: web search, file operations, APIs, calculators. Agents autonomously decide when to use tools.
allow_delegation (boolean)
Whether the agent can ask other agents for help. Set to True for managers, False for specialists who should focus on their own work.
🎭 Role Design Best Practices
- •Be specific: "Senior Data Analyst" is better than "Data Person"
- •Add personality: Include traits like "detail-oriented", "creative", "skeptical"
- •Set boundaries: Mention what the agent should/shouldn't do in backstory
- •Match tools to role: Researcher gets search tools, Writer gets file tools