How to build an agent with CrewAI
Model a small collaborative workflow with specialized roles, explicit tasks, and constrained tools.
8 min read·July 16, 2026
Use roles to separate responsibilities
CrewAI organizes work around agents, tasks, and a crew. Give each agent one responsibility and only the tools needed for that responsibility.
from crewai import Agent, Task, Crew
researcher = Agent(
role="Release researcher",
goal="Find verified changes in the selected repositories",
backstory="You cite sources and never invent release details.",
tools=[repository_search],
)Turn the outcome into a task
Tasks should state the expected output and the evidence required. This makes delegation easier to inspect and test.
research = Task(
description="Review releases from the last seven days.",
expected_output="A sourced list of notable changes.",
agent=researcher,
)
crew = Crew(agents=[researcher], tasks=[research])
result = crew.kickoff()Control the crew
More agents do not automatically produce better work. Limit delegation depth, set budgets, isolate credentials by role, and require approval before any write operation.