EngineeringCertification

Building Teams of AI Agents with CrewAI

Moving beyond single-agent prompt loops: orchestrating multi-agent collaboration with specialized roles, tools, and sequential or hierarchical processes.

Kushan Manahara

November 3, 2024 · 4 min read

00
Building Teams of AI Agents with CrewAI

Single-agent systems often hit a ceiling when tasks require multiple distinct skill sets. Ask a single LLM to perform deep technical research, synthesize 20 search results, write a production-ready blog post, and review its own citations, and it will inevitably compromise on quality, forget instructions, or hallucinate citations.

CrewAI solves this by borrowing organizational structure from human engineering teams: dividing work among specialized agents that communicate, pass artifacts, and hold each other accountable under an explicit management process.

The Core Building Blocks

  • Agent: An autonomous actor configured with a distinct role (its job title), a goal (its primary objective), and a backstory (which sets its personality, tone, and cognitive boundaries in system prompts).
  • Task: A discrete unit of work assigned to an agent, specifying the description of the work and the exact expected_output schema.
  • Tools: Capabilities attached to specific agents (web search, scrapers, database connectors, code interpreters).
  • Process: How the tasks are executed: Sequential (linear pipeline where task N's output feeds task N+1) or Hierarchical (a manager agent dynamically plans, delegates, and reviews results).

A Production-Ready Crew in Python

Here is a complete, runnable CrewAI script establishing a collaborative two-agent research team:

agent_crew.py
import os
from crewai import Agent, Task, Crew, Process
from crewai_tools import SerperDevTool

# Configure API keys
os.environ["SERPER_API_KEY"] = "your_serper_api_key"
os.environ["OPENAI_API_KEY"] = "your_openai_api_key"

search_tool = SerperDevTool()

# 1. Senior Research Analyst Agent
senior_researcher = Agent(
    role="Senior AI Research Analyst",
    goal="Uncover cutting-edge developments in multi-agent systems and summarize empirical findings",
    backstory="""You are an expert AI researcher at a top-tier lab. You have an eye for separating 
    genuine architectural breakthroughs from marketing hype. You rigorously verify all claims.""",
    tools=[search_tool],
    verbose=True,
    memory=True,
)

# 2. Technical Technical Writer Agent
tech_writer = Agent(
    role="Principal Systems Writer",
    goal="Translate dense technical research into actionable, engaging engineering articles",
    backstory="""You are a veteran systems engineer and technical essayist. You explain complex protocols 
    with intuitive analogies, clean code examples, and zero fluff.""",
    tools=[],
    verbose=True,
)

# 3. Define Sequenced Tasks
research_task = Task(
    description="Investigate recent advancements in the Model Context Protocol (MCP) in 2025/2026. Focus on enterprise adoption and tooling.",
    expected_output="A structured 5-bullet summary of verified findings with source URLs.",
    agent=senior_researcher,
)

writing_task = Task(
    description="Using the research findings, compose an insightful 400-word engineering briefing explaining how developers should adopt MCP.",
    expected_output="A complete markdown article with an introduction, key technical takeaways, and conclusion.",
    agent=tech_writer,
)

# 4. Form the Crew and Execute
tech_crew = Crew(
    agents=[senior_researcher, tech_writer],
    tasks=[research_task, writing_task],
    process=Process.sequential,
    verbose=True,
)

result = tech_crew.kickoff()
print("\n### Final Synthesized Output:\n", result)

Key Engineering Takeaways

After completing the Practical Multi AI Agents and Advanced Use Cases with crewAI certification (taught by João Moura on DeepLearning.AI), three critical lessons stand out for production agent architectures:

  • Strict Guardrails on Delegation: When using allow_delegation=True, agents can enter endless polite conversation loops ('Can you check this?' 'Sure, here is X, can you review?'). Always set explicit max_iter limits.
  • Backstories Are Prompt Engineering: The backstory is not decorative flavor text. It primes the LLM's attention mechanism to discard irrelevant reasoning paths and stick to its designated domain.
  • Tool Granularity: Agents perform far better with three small, deterministic, single-purpose tools than one massive 'swiss-army knife' tool with dozens of optional parameters.

The verified certificate is viewable on DeepLearning.AI.

Written by

Kushan Manahara

Responses (0)

Verified name, role, and email required before posting.

No responses yet

Be the first to share your thoughts, benchmarks, or feedback above.