DS DevShelfHub Projects · AI tools
Tutorials / CrewAI / Reference / Classes / Crew
Class core

Crew: Reference Guide

By DevShelfHub

The orchestrator: binds agents + tasks + process + shared services (memory, knowledge, embedder, manager).

See the CrewAI API reference index, CrewAI introduction, and core concepts for surrounding context.

What is Crew?

Crew is the object you wire once and then execute: it owns the ordered list of agents, the task graph, the Process (sequential vs hierarchical), and cross-cutting services such as embedder configuration, crew-level knowledge_sources, shared memory toggles, and optional planning via AgentPlanner. kickoff() runs the full loop and returns a CrewOutput with per-task outputs and token_usage; train(), test(), and replay() support the training-and-evaluation workflow without rewriting your definitions.

Hierarchical mode is where most production surprises appear: you must supply manager_llm or manager_agent so the manager can delegate, and you should expect higher latency than sequential pipelines because the manager re-reads context between delegations. max_rpm applies globally across agents unless you also cap per-agent max_rpm — combine both when you hit provider rate limits. security_config attaches fingerprints and redaction defaults for telemetry, which matters the moment you log prompts in regulated environments.

When a Flow wraps a Crew, treat the Crew as a pure domain block: keep IO at the Flow layer and pass narrow inputs into kickoff(inputs={...}) so tasks stay deterministic. For YAML-first projects, @CrewBase still constructs a Crew under the hood — the class reference here is the imperative mirror of that layout.

When to Use

The default container for multi-agent work.

Use Cases

  • Research pipelines
  • Content factories
  • Triage systems

Key Features

  • Process selection
  • Shared memory & knowledge
  • Manager-agent / manager-LLM
  • Planning support

When NOT to Use

Single-step utilities — LiteAgent suffices.

Notes

kickoff inputs must match task templates

Placeholders such as {topic} are filled from kickoff(inputs={...}). Missing keys surface as late failures deep in the planner — validate keys in your API layer before enqueueing jobs.

Planning doubles LLM calls

planning=True prepends an AgentPlanner summary ahead of every iteration. Budget tokens accordingly and pick a small planning_llm when the planner only routes work.

Token usage lives on CrewOutput

Always inspect crew.kickoff(...).token_usage for prompt, completion, and cached_prompt counts when billing internally. Do not infer spend from stdout verbose logs alone.

Hierarchical mode needs a manager

Without manager_llm or manager_agent, hierarchical crews either fall back to surprising defaults or fail early. Treat manager configuration as required, not optional, when Process.hierarchical is selected.

Import

python
from crewai import Crew

Key Parameters

Parameter Type Default Purpose
agents list[Agent] Workers.
tasks list[Task] Units of work.
process Process Process.sequential Execution mode.
verbose bool | int False Logging verbosity.
memory bool True Enable shared memory.
embedder dict | None None Embedder config dict.
manager_agent Agent | None None Custom manager in hierarchical mode.
manager_llm Any | None None LLM used by the default manager.
knowledge_sources list[BaseKnowledgeSource] | None None Crew-level knowledge.
output_log_file str | None None Optional log file path.
task_callback Callable | None None Post-task callback.
step_callback Callable | None None Per-step callback.
max_rpm int | None None Global rate limit.
function_calling_llm Any | None None Tool-call LLM override.
share_crew_state bool True Propagate state to agents.
planning bool False Run AgentPlanner before each iteration.
planning_llm Any | None None LLM used by the planner.
security_config SecurityConfig | None SecurityConfig() Fingerprints & security.

Code Examples

Sequential crew with verbose tracing

python
from crewai import Agent, Task, Crew, Process

researcher = Agent(role='Researcher', goal='Summarize {topic}', backstory='You cite sources.')
writer = Agent(role='Writer', goal='Draft a brief', backstory='You are concise.')

t1 = Task(description='Bullet findings on {topic}', expected_output='Bullets', agent=researcher)
t2 = Task(description='Turn bullets into a 150-word brief', expected_output='Markdown', agent=writer, context=[t1])

crew = Crew(agents=[researcher, writer], tasks=[t1, t2], process=Process.sequential, verbose=True)
out = crew.kickoff(inputs={'topic': 'CrewAI planning'})
print(out.raw)

Hierarchical process with manager LLM

python
from crewai import Agent, Task, Crew, Process

worker = Agent(role='Analyst', goal='Answer', backstory='You use tools sparingly.')
reviewer = Agent(role='Reviewer', goal='Validate', backstory='You reject vague answers.')

t_do = Task(description='Analyze {case}', expected_output='Analysis', agent=worker)
t_check = Task(description='Check analysis for gaps', expected_output='Pass/fail notes', agent=reviewer, context=[t_do])

crew = Crew(
    agents=[worker, reviewer],
    tasks=[t_do, t_check],
    process=Process.hierarchical,
    manager_llm='openai/gpt-4o-mini',
    memory=False,
)
print(crew.kickoff(inputs={'case': 'Q2 churn'}).raw)

Crew-level knowledge + planning

python
from crewai import Crew, Agent, Task, Process
from crewai.knowledge.source.string_knowledge_source import StringKnowledgeSource

policy = StringKnowledgeSource(content='Refund window is 14 days for EU customers.')
agent = Agent(role='Support', goal='Answer policy questions', backstory='You only use the knowledge source.')
task = Task(description='Does this order qualify for a refund?', expected_output='Yes/no with citation', agent=agent)

crew = Crew(
    agents=[agent],
    tasks=[task],
    process=Process.sequential,
    knowledge_sources=[policy],
    planning=True,
    planning_llm='openai/gpt-4o-mini',
)
print(crew.kickoff().raw)

Common Mistakes

❌ Mixing agent-specific tools and crew-wide tools randomly

✅ Put generally useful tools on agents; task-specific tools on the Task.

❌ Setting hierarchical without tuning max_rpm

✅ Managers fan out extra calls — lower max_rpm or add per-agent caps before production.

Crew FAQ

What is Crew in CrewAI?

The orchestrator: binds agents + tasks + process + shared services (memory, knowledge, embedder, manager). Crew is the object you wire once and then execute: it owns the ordered list of agents, the task graph, the Process (sequential vs hierarchical), and cross-cutting services such as embedder configuration, crew-level knowledge_sources, shared memory toggles, and optional planning via AgentPlanner. kickoff() runs the full loop and returns a CrewOutput with per-task outputs and token_usage; train(), test(), and replay() support the training-and-evaluation workflow without rewriti…

Which package defines the CrewAI class Crew?

DevShelfHub maps Crew to Python module crewai (package path crewai in this reference). Pin your installed crewai version and match imports to the snippet on this page.

When should I use Crew?

The default container for multi-agent work.

When should I avoid using Crew?

Single-step utilities — LiteAgent suffices.

How do I import Crew in Python?

from crewai import Crew

Where can I explore more CrewAI API reference pages?

Open the CrewAI API reference index on DevShelfHub to search 58 classes, 30 methods, and 16 decorators, each with runnable examples, parameters, common mistakes, and cross-links.