Home/Agentic AI/CrewAI Basics/Tasks & Processes

CrewAI Basics

Master CrewAI framework for orchestrating role-playing autonomous AI agents

Tasks & Execution Processes

Tasks are the specific jobs you want agents to do. Each task has a description (what to do) and an expected_output (what the result should look like). Tasks are assigned to specific agents, and the Process determines how tasks are executed across the crew.

📋 Creating Tasks

from crewai import Task

research_task = Task(
    description="""Conduct a comprehensive analysis of the latest
    advancements in AI for 2024. Identify key trends, breakthrough
    technologies, and potential industry impacts.""",
    expected_output="A 3-paragraph report on 2024 AI trends",
    agent=researcher  # Assign to specific agent
)

writing_task = Task(
    description="""Using the insights from the research, develop an
    engaging blog post that highlights the most significant AI
    advancements. Make it accessible to a general audience.""",
    expected_output="A 4-paragraph blog post in markdown format",
    agent=writer
)

Note: Tasks run in the order defined. The second task can reference outputs from the first task.

Interactive: Sequential vs Hierarchical Process

Sequential Process

Tasks are executed one at a time, in the order you define. Each agent completes their task before the next one starts. Simple, predictable, and easy to debug.

1
Researcher
Researches AI trends → Output: Research report
2
Writer
Uses research to write blog post → Output: Blog post
3
Analyst
Reviews blog post for quality → Output: Final approved post
Best for:
  • • Clear linear workflows (step 1 → step 2 → step 3)
  • • When output of one task is input for next
  • • Most common process type for content creation

🔧 Task Configuration Options

context (list of tasks)

Reference outputs from previous tasks. Useful when task B needs information from task A.

context=[research_task] # Writer task can access researcher's output

async_execution (boolean)

Whether the task can run in parallel with others. Set True for independent tasks.

async_execution=True # Run this task concurrently

output_file (string)

Save task output to a file automatically. Great for generating reports, code, or documents.

output_file='report.md' # Save output to file

💡 Task Design Tips

  • Be specific: Clear task descriptions get better results than vague instructions
  • Define output format: "Write 3 paragraphs" vs "Write something about AI"
  • Chain tasks logically: Ensure task order makes sense (research before writing)
  • Start with sequential: It's simpler and cheaper than hierarchical
Prev