Skip to content
BotServBotServ
CrewAIAI AgentMulti-AgentFrameworkWorkflowLocal AI

CrewAI

Understand CrewAI: agent crews, roles and tasks for automated workflows.

S

schutzgeist

3 min read
CrewAI

CrewAI

Introduction

CrewAI is a Python framework for building teams of AI agents. Each agent gets a role, a goal, and a set of tools. Together, they tackle complex tasks that a single agent would struggle with alone. It works especially well for workflows that need multiple sequential or parallel steps.

CrewAI at a glance

CrewAI centers on three core ideas: agents, tasks, and a crew. An agent embodies a role like “researcher” or “writer”. A task describes what that agent should do. The crew orchestrates agents and their tasks into a defined workflow. Agents pass their results forward to one another until the overall goal is reached.

Tools, concepts, and techniques

  • CrewAI Python - The main framework. Install via pip.
  • CrewAI Documentation - Official guide with examples.
  • Ollama - Runs locally and can serve as a model backend for CrewAI.
  • Agent - An AI role with a goal, personality, and tools.
  • Task - A clearly defined work package that an agent completes.
  • Crew - The overall structure combining agents and tasks.

Practical example: a simple research crew

from crewai import Agent, Task, Crew
from langchain_ollama import ChatOllama

# Local model via Ollama
llm = ChatOllama(model="llama3.1", base_url="http://localhost:11434")

researcher = Agent(
    role="Researcher",
    goal="Gather information on a topic",
    backstory="You are a precise researcher.",
    llm=llm,
    verbose=True
)

writer = Agent(
    role="Writer",
    goal="Write a clear article from research findings",
    backstory="You are an experienced writer.",
    llm=llm,
    verbose=True
)

research_task = Task(
    description="Research the benefits of local AI.",
    agent=researcher,
    expected_output="Bullet points listing benefits"
)

writing_task = Task(
    description="Write a short article.",
    agent=writer,
    expected_output="A text of around 300 words",
    context=[research_task]
)

crew = Crew(
    agents=[researcher, writer],
    tasks=[research_task, writing_task]
)

result = crew.kickoff()
print(result)

CrewAI runs the research first, then passes the result to the writer. The context=[research_task] parameter tells the writer what to build on.

Common pitfalls and decision guides

  • Too many agents at the start - Begin with two or three roles. More than that makes the workflow hard to follow.
  • Vague task descriptions - Each task needs a clear description and an expected output.
  • Local models run slower - Large crews with many steps require patience on consumer hardware.
  • When to choose CrewAI over LangGraph? CrewAI shines when you want to model roles and parallel tasks. LangGraph is better for cyclic decisions and state management.
  • CrewAI builds on agents with roles, tasks, and a crew structure.
  • It works with Ollama for local models.
  • Task handoffs work through context.
  • Learn more about agents in What is an AI Agent? and LangGraph.

FAQ - Common questions about CrewAI

Does CrewAI run locally?

Yes, with Ollama or LM Studio as your model backend. You don’t need a cloud service.

How many agents do I need?

Often two or three are enough. For more complex workflows, you can add more. The key is that each role is clearly defined.

Is CrewAI free?

Yes, the open-source framework is free. Costs only come up if you use cloud-based models.

Can I learn CrewAI with Python?

Yes. Basic Python knowledge is enough to build your first crews.

How does CrewAI differ from LangGraph?

CrewAI focuses on roles and task distribution. LangGraph focuses on states, decisions, and graph structures.

Which model should I use locally with CrewAI?

A quantized 7B model like Llama 3.1 or Qwen 2 is a good starting point. For larger tasks, more memory and a more capable model help.

Sources

Back to Blog
Share:

Nächster Artikel in AI Agents

Weiterlesen
Dify

Related Posts