Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:CrewAIInc CrewAI Crew Constructor

From Leeroopedia
Knowledge Sources
Domains Multi_Agent_Systems, Orchestration
Last Updated 2026-02-11 00:00 GMT

Overview

Concrete class for assembling agents, tasks, and configuration into an executable crew provided by the CrewAI framework.

Description

The Crew class is the central orchestration container. It accepts lists of agents and tasks, a process type (sequential or hierarchical), and optional configuration for memory, caching, verbose logging, embedders, knowledge sources, callbacks, planning, and streaming. Pydantic validators ensure consistency (e.g., hierarchical process requires manager_agent or manager_llm).

Usage

Import and instantiate Crew after creating Agent and Task instances. Pass the agents, tasks, and desired process type. The resulting Crew instance is ready for kickoff().

Code Reference

Source Location

  • Repository: crewAI
  • File: lib/crewai/src/crewai/crew.py
  • Lines: L133-326

Signature

class Crew(FlowTrackable, BaseModel):
    """Represents a group of agents and their tasks."""

    name: str | None = Field(default="crew")
    agents: list[BaseAgent] = Field(default_factory=list)
    tasks: list[Task] = Field(default_factory=list)
    process: Process = Field(default=Process.sequential)
    verbose: bool = Field(default=False)
    memory: bool = Field(default=False)
    cache: bool = Field(default=True)
    max_rpm: int | None = Field(default=None)
    embedder: EmbedderConfig | None = Field(default=None)
    manager_llm: str | BaseLLM | Any | None = Field(default=None)
    manager_agent: BaseAgent | None = Field(default=None)
    function_calling_llm: str | LLM | Any | None = Field(default=None)
    planning: bool | None = Field(default=False)
    planning_llm: str | BaseLLM | Any | None = Field(default=None)
    knowledge_sources: list[BaseKnowledgeSource] | None = Field(default=None)
    stream: bool = Field(default=False)
    output_log_file: bool | str | None = Field(default=None)

Import

from crewai import Crew, Process

I/O Contract

Inputs

Name Type Required Description
agents list[BaseAgent] Yes List of agents in the crew
tasks list[Task] Yes Ordered list of tasks
process Process No Execution process type (default: Process.sequential)
verbose bool No Enable verbose logging (default: False)
memory bool No Enable memory subsystem (default: False)
cache bool No Enable tool result caching (default: True)
embedder None No Embedding configuration for knowledge/memory

Outputs

Name Type Description
Crew instance Crew Assembled crew ready for kickoff()

Usage Examples

Sequential Crew

from crewai import Crew, Agent, Task, Process

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

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment