Skip to main content
Tasks define what agents should do. In PraisonAI, you can give tasks directly to agents or use the Task class for complex workflows.

Quick Start

Simple Way - Direct Task

from praisonaiagents import Agent

agent = Agent(instructions="You are a research assistant")
agent.start("Research the latest AI trends")  # This is the task

Advanced Way - Task Class

from praisonaiagents import Agent, Task, AgentTeam

researcher = Agent(instructions="Research topics")
writer = Agent(instructions="Write summaries")

task1 = Task(description="Research AI trends", agent=researcher)
task2 = Task(description="Write a summary", agent=writer)

team = AgentTeam(agents=[researcher, writer], tasks=[task1, task2])
team.start()

Task Options

OptionDescriptionExample
descriptionWhat to do"Research AI trends"
agentWho does itresearcher
expected_outputWhat to produce"Summary report"
contextPrevious tasks to use[task1]
output_fileSave result to file"report.md"

Task Types

Research

Find, gather, and summarize information

Create

Write articles, reports, or content

Analyze

Process data and find insights

Interact

Answer questions and chat

Task Dependencies

Tasks can use results from previous tasks:
from praisonaiagents import Agent, Task, AgentTeam

researcher = Agent(instructions="Research topics")
analyst = Agent(instructions="Analyze data")
writer = Agent(instructions="Write reports")

# Task 1: Research
task1 = Task(
    description="Research renewable energy trends",
    agent=researcher
)

# Task 2: Uses Task 1's output
task2 = Task(
    description="Analyze the research findings",
    agent=analyst,
    context=[task1]  # Gets task1's result
)

# Task 3: Uses Task 2's output
task3 = Task(
    description="Write a summary report",
    agent=writer,
    context=[task2],
    output_file="report.md"  # Save to file
)

team = AgentTeam(agents=[researcher, analyst, writer], tasks=[task1, task2, task3])
team.start()

Complete Example

from praisonaiagents import Agent, Task, AgentTeam

# Create specialized agents
researcher = Agent(
    name="Researcher",
    instructions="Find accurate information on topics",
    web=True
)

writer = Agent(
    name="Writer",
    instructions="Write clear, engaging content"
)

# Define tasks
research_task = Task(
    description="Research the benefits of solar energy",
    expected_output="Key facts and statistics",
    agent=researcher
)

writing_task = Task(
    description="Write a blog post about solar energy benefits",
    expected_output="500-word blog post",
    agent=writer,
    context=[research_task],
    output_file="solar-blog.md"
)

# Run the workflow
team = AgentTeam(
    agents=[researcher, writer],
    tasks=[research_task, writing_task],
    process="sequential"
)

result = team.start()

Best Practices

“Research AI trends in healthcare” is better than “Research AI”
Split complex work into multiple focused tasks
Connect related tasks with context=[previous_task]
Tell the agent what format you want

Next: Creating Your First Agent

Build a complete agent application step by step.