Chuyển đến nội dung chính

Lesson 10: CrewAI — Building a "team" of AI Agents

Multi-agent with CrewAI: define Agents (role, goal, backstory), Tasks, and Crew orchestration. Build content pipeline: Researcher → Writer → Editor.

🧠 AI & ML — Lesson 9 Lesson 10: CrewAI — Building an AI "team". Agent

Build AI Agents: From Zero to Production

Part 4: Agentic Frameworks

xdev.asia

Introduction

A single agent has limits. CrewAI allows you to create teams of agents with different roles, collaborating to complete complex tasks — just like real teams.


1. CrewAI Concepts

from crewai import Agent, Task, Crew

researcher = Agent(
    role="Senior Researcher",
    goal="Tìm kiếm và tổng hợp thông tin chính xác",
    backstory="Bạn là researcher 10 năm kinh nghiệm...",
    tools=[web_search_tool],
)

writer = Agent(
    role="Content Writer",
    goal="Viết bài viết hấp dẫn từ research",
    backstory="Bạn là technical writer...",
)

editor = Agent(
    role="Editor",
    goal="Review và polish bài viết",
    backstory="Bạn là senior editor...",
)

# Define tasks
research_task = Task(description="Research about AI Agents trends 2025", agent=researcher)
write_task = Task(description="Write a blog post from the research", agent=writer)
edit_task = Task(description="Edit and polish the blog post", agent=editor)

# Assemble crew
crew = Crew(agents=[researcher, writer, editor], tasks=[research_task, write_task, edit_task])
result = crew.kickoff()

Summary

  • CrewAI = team of agents with specialized roles
  • Agent = role + goal + backstory + tools
  • Task = work item assigned to an agent
  • Process types: sequential, hierarchical, consensual

Exercises

  1. Build a content creation pipeline: Researcher → Writer → Editor
  2. Implement hierarchical process with Manager agent
  3. Add custom tools for each agent
  4. Compare output quality: 1 agent vs 3-agent crew