Agents are the AI-powered personas responsible for executing specific roles or responsibilities
Each agent is given:
Agents can be powered by different LLMs (OpenAI, Gemini, etc.).
They collaborate with other agents to achieve the overall crew goal.
Example
from crewai import Agent
researcher = Agent(
role='AI Researcher',
goal='Find the latest trends in LLMs',
backstory='An expert in machine learning with 10 years of experience.'
)
Tasks define what needs to be done → the actual units of work
Each task is assigned to an agent.
A task includes:
Can depend on the output of other tasks (i.e., tasks can be chained).
Example:
from crewai import Task
task1 = Task(
description='Research recent papers on LLM optimization',
expected_output='A summary of the 5 most important papers',
agent=researcher
)
Tools are external capabilities or functions that agents can use to perform their tasks more effectively. They extend what an agent can do beyond just generating text using its language model.
<aside> 💡
Agents sometimes need to:
Fetch data from external sources (e.g., APIs, files, search)
Use custom Python functions (e.g., calculator, converter)
Interact with knowledge bases, databases, or other services </aside>
A tool is a Python function wrapped using Tool from CrewAI.
Example:
from crewai import Tool
def get_latest_news(topic: str) -> str:
# Imagine this fetches news from an API
return f"Latest news on {topic}..."
news_tool = Tool(
name="NewsFetcher",
func=get_latest_news,
description="Fetches the latest news for a given topic"
)