AgentTeam Task Validation

What AgentTeam accepts for tasks= and the exact errors you'll see

AgentTeam only accepts tasks=None (auto-generate one per agent) or a list / tuple of Task instances — anything else raises a clear TypeError at construct time.

Diagram

AgentTeam(tasks=…)

None

list / tuple of Task

str / bytes / int / mixed

📝 tasks= value

🔍 type?

🧠 auto-generate

✅ accepted

⛔ TypeError

Quick Start

  1. Let the team auto-generate tasks
    python
    from praisonaiagents import Agent, AgentTeam
    
    writer = Agent(name="Writer", instructions="Write a short bio")
    team = AgentTeam(agents=[writer])  # tasks=None by default
    team.start("Write one sentence about rain")

    tasks=None generates one task per agent — the shortest working run.

  2. Pass explicit Task instances
    python
    from praisonaiagents import Agent, AgentTeam, Task
    
    writer = Agent(name="Writer", instructions="Write a short bio")
    task = Task(
        description="Write one sentence about rain",
        expected_output="One sentence",
        agent=writer,
    )
    
    team = AgentTeam(agents=[writer], tasks=[task])
    team.start()

    Use a list of Task instances when you need per-task control.


Common Mistake

tasks= is not a prompt string — passing one raises a TypeError.

python
# ❌ Wrong — tasks is not a prompt string
team = AgentTeam(agents=[writer], tasks="Write one sentence")
# TypeError: tasks must be a sequence of Task instances, not str.
# Pass tasks=None to auto-generate from agents, or tasks=[Task(...)].

Fix it by passing the prompt to start(), or wrapping it in a Task.

Option A — prompt goes to start()
from praisonaiagents import Agent, AgentTeam

writer = Agent(name="Writer", instructions="Write a short bio")
team = AgentTeam(agents=[writer])
team.start("Write one sentence")
Option B — wrap as Task
from praisonaiagents import Agent, AgentTeam, Task

writer = Agent(name="Writer", instructions="Write a short bio")
task = Task(
    description="Write one sentence",
    expected_output="One sentence",
    agent=writer,
)
team = AgentTeam(agents=[writer], tasks=[task])

Accepted and Rejected Inputs

Every tasks= value resolves to one of these outcomes.

tasks= valueResult
NoneAuto-generates one task per agent
[Task(...), Task(...)]Accepted
(Task(...),)Accepted (tuple works)
[]ValueError("If tasks are provided, at least one task must be present")
"Write ..."TypeError naming Task and the valid shapes
b"..."TypeError
123TypeError("tasks must be a sequence of Task instances, got int")
[task, "x"]TypeError("tasks[1] must be a Task instance, got str")

Error Reference

Grep these exact messages when you hit a failure.

InputExceptionMessage
str / bytesTypeErrortasks must be a sequence of Task instances, not str. Pass tasks=None to auto-generate from agents, or tasks=[Task(...)].
Non-sequence (e.g. int)TypeErrortasks must be a sequence of Task instances, got int
Sequence with a non-Task itemTypeErrortasks[1] must be a Task instance, got str
Empty list / tupleValueErrorIf tasks are provided, at least one task must be present

Best Practices

Prefer tasks=None for simple runs

Pass the prompt to start() and let the team auto-generate one task per agent — often all you need.

Use Task(…) when you need per-task control

Task(description=..., expected_output=..., agent=...) gives you templating with {{placeholder}}, custom expected_output, and a specific agent=.

A tuple of Task works too

tasks=(t1, t2) is accepted — the sequence is coerced to a list internally, useful when the task list is static.

Empty list is a ValueError, not a TypeError

tasks=[] has always raised ValueError — that check pre-dates the strict type validation.


Related