#1 India's Top IT Training Institute
×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
Mentors

Mentors

Meet the industry experts who train and guide you through your course.

Read More →
Free Resources

Free Resources

Free tutorials, interview questions, tools and calculators to help you learn.

Explore →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →

CrewAI Framework: Enabling Multi-Agent Collaboration

CrewAI is an open-source Python framework for building teams of AI agents that work together on a job. You define agents (each with a role, goal, backstory, tools and model), tasks (what to do and what output is expected) and a crew that runs the tasks in order (sequential process) or under a manager agent (hierarchical process). For workflows that need tighter control, CrewAI Flows add event-driven steps and state. It is independent of LangChain and can use most LLM providers. Below is how each piece works, a runnable example, and when a multi-agent setup is worth it.

CrewAI Framework: Enabling Multi-Agent Collaboration

CrewAI Framework: Enabling Multi-Agent Collaboration

Why split work across several agents?

One LLM prompt that must research, analyse, write and check its own work tends to do each part less well. Giving each step to an agent with a narrow role and its own instructions makes the output easier to control and debug, in the same way a team divides work between a researcher, a writer and an editor. The trade-off is more model calls, so more cost and latency.

Core concepts

ConceptWhat it is
AgentAn LLM with a role, goal and backstory that shape its behaviour, optional tools (search, file reading, your own functions) and a chosen llm
TaskA description, an expected_output, the agent responsible, and optional context (outputs of earlier tasks it should use)
CrewA group of agents and tasks plus a process that decides how they run
Processsequential: tasks run in order, each passing output forward. hierarchical: a manager agent plans, delegates and reviews
FlowEvent-driven orchestration with explicit state, used to combine crews with ordinary Python steps and branching
Memory and knowledgeOptional short- and long-term memory, and knowledge sources such as documents that agents can draw on

A runnable example

Install with pip install crewai and set OPENAI_API_KEY (CrewAI also supports Anthropic, Google, local Ollama models and others through its LLM settings). This two-agent crew researches customer complaints and then writes product copy that addresses them.

from crewai import Agent, Task, Crew, Process

researcher = Agent(
    role="Market Researcher",
    goal="Identify the most common customer complaints about {product}",
    backstory="You study product reviews and summarise patterns precisely.",
    llm="gpt-4o-mini",
)

writer = Agent(
    role="Product Copywriter",
    goal="Write honest product copy that answers real customer concerns",
    backstory="You write clear, specific copy with no exaggerated claims.",
    llm="gpt-4o-mini",
)

research_task = Task(
    description="List the five most common complaints buyers have about {product}.",
    expected_output="A numbered list of five complaints, one line each.",
    agent=researcher,
)

write_task = Task(
    description="Write a 120-word product description for our {product} "
                "that addresses the complaints found in the research.",
    expected_output="One paragraph of about 120 words.",
    agent=writer,
    context=[research_task],
)

crew = Crew(
    agents=[researcher, writer],
    tasks=[research_task, write_task],
    process=Process.sequential,
    verbose=True,
)

result = crew.kickoff(inputs={"product": "budget wireless earbuds"})
print(result.raw)

The {product} placeholders are filled from inputs. With verbose=True you see each agent's work in the terminal; result.raw holds the final paragraph, whose wording changes from run to run. As written, the researcher uses only the model's general knowledge. To research live data, give it a tool, for example a web search tool from the crewai-tools package (which needs that search service's API key), or a custom tool that reads your own review database.

Project structure for real apps

For anything larger than a script, the CLI scaffolds a project: crewai create crew review_insights. Agents and tasks then live in config/agents.yaml and config/tasks.yaml, and the Python code wires them together, so prompts can be edited without touching logic.

Sequential vs hierarchical

  • Sequential is predictable and cheaper: you decide the order. Use it when the steps are known, such as research → draft → review.
  • Hierarchical adds a manager (a manager_llm or custom manager agent) that decides who does what and checks results. Use it when the steps depend on the request, accepting more calls and less predictability.
  • Flows are the choice when you need fixed ordering, branching on results, or a mix of AI steps and normal code (for example, validate data in Python, then hand off to a crew).

Practical use cases

  • Content pipelines: researcher, writer and editor agents, with a human approving the final draft.
  • Report generation: one agent pulls data through a SQL or API tool, another analyses it, a third writes the summary.
  • Customer support triage: a classifier agent routes a ticket; a specialist agent drafts a reply from the knowledge base.
  • Code review helpers: separate agents check style, security and test coverage on a diff.

How CrewAI compares with other agent frameworks

FrameworkApproach
CrewAIRole-based agents and tasks; quick to set up; Flows for structured orchestration
LangGraphAgents as explicit graphs of nodes and edges with state; fine-grained control over each step
AutoGen (Microsoft)Agents that collaborate through multi-agent conversations
Provider agent SDKsLighter frameworks from model providers, closely tied to their own APIs and tools

Tips for reliable crews

  1. Write a specific expected_output for every task; vague tasks produce vague results.
  2. Start with two or three agents. Add more only when a step clearly needs its own role.
  3. Give agents tools for facts instead of relying on model memory.
  4. Set limits such as max_iter on agents and watch token usage; multi-agent loops can become expensive.
  5. Keep a human review step before anything is published or sent to customers.

FAQs

Is CrewAI free?

The framework is open source and free to use. You pay for the LLM API calls your agents make, unless you run local models. CrewAI also sells a hosted enterprise platform.

Does CrewAI need LangChain?

No. CrewAI is built independently of LangChain, although it can use tools from other ecosystems.

Can CrewAI use local models?

Yes. You can point an agent's llm at a model served locally by Ollama, which avoids API costs for experiments.

To compare approaches, read LangGraph for agent workflows, multi-agent systems with LangChain and LangChain vs AutoGen. The broader idea is covered in multi-agent systems for real-world problems.

Placed Students

Our Clients

Partners

...