Skip to main content

Agents

Multi-agent orchestration with sequential, parallel, hierarchical, and workflow patterns.

Quick Start

from praisonaiagents import Agent, AgentTeam

researcher = Agent(name="Researcher", instructions="Research topics")
writer = Agent(name="Writer", instructions="Write content")

agents = AgentTeam(agents=[researcher, writer], memory=True)
result = agents.start()

Parameters Table

Core Parameters

ParameterTypeDefaultDescription
agentsList[Agent]requiredList of agents to orchestrate
tasksList[Task]NoneTasks to execute (auto-generated if None)
processstr"sequential"Execution pattern (see below)
namestrNoneName for this agent collection
variablesDictNoneGlobal variables for substitution
manager_llmstrNoneLLM for manager agent (hierarchical)

Process Types

ProcessDescription
"sequential"Execute tasks in order
"parallel"Execute independent tasks concurrently
"hierarchical"Manager agent delegates to workers
"workflow"Follow task dependencies

Consolidated Feature Params

ParameterTypeDefaultDescription
memorybool | MultiAgentMemoryConfigFalseShared memory
planningbool | MultiAgentPlanningConfigFalsePlanning mode
contextbool | ContextConfigFalseContext management
outputstr | MultiAgentOutputConfigNoneOutput config
executionstr | MultiAgentExecutionConfigNoneExecution config
hooksMultiAgentHooksConfigNoneEvent hooks
autonomybool | AutonomyConfigNoneAutonomy settings
knowledgebool | List[str] | KnowledgeConfigNoneKnowledge/RAG
guardrailsbool | Callable | GuardrailConfigNoneValidation
webbool | WebConfigNoneWeb search/fetch
reflectionbool | ReflectionConfigNoneSelf-reflection

Precedence Ladder

Resolution Order: Instance > Config > Array > Dict > String > Bool > DefaultSame precedence as Agent. Consolidated params propagate to underlying agents.

Usage Forms Table

FormExampleWhen to Use
Boolmemory=TrueEnable with defaults
String presetoutput="verbose"Use predefined config
Dictmemory={"backend": "redis"}Custom config
Array + overridesoutput=["verbose", {"stream": False}]Preset + customization
Config instancememory=MultiAgentMemoryConfig(...)Full control

Presets & Options

Output Presets (Multi-Agent)

PresetDescription
"silent"Zero output (default)
"status"Tool calls + response, no timestamps
"trace"Full trace with timestamps
"debug"trace + metrics (no boxes)
"verbose"Rich panels with Markdown

Execution Presets (Multi-Agent)

Presetmax_itermax_retries
"fast"52
"balanced"105
"thorough"205
"unlimited"10010

Methods

MethodDescription
start()Start synchronous execution
astart()Async execution
run_all_tasks()Execute all tasks
add_task(task)Add task dynamically
get_task_status(task_id)Get task status
set_state(key, value)Set shared state
get_state(key, default)Get shared state

Common Recipes

Sequential (Default)

Tasks execute one after another in order:
agents = AgentTeam(
    agents=[agent1, agent2],
    tasks=[task1, task2, task3],
    process="sequential"
)

Parallel

Independent tasks execute concurrently:
agents = AgentTeam(
    agents=[agent1, agent2, agent3],
    tasks=[independent_task1, independent_task2, independent_task3],
    process="parallel"
)

Hierarchical

Manager agent delegates to worker agents:
agents = AgentTeam(
    agents=[worker1, worker2, worker3],
    tasks=[complex_task],
    process="hierarchical",
    manager_llm="gpt-4o-mini"
)

Workflow

Tasks follow explicit dependencies via context:
task1 = Task(description="Step 1", agent=agent1)
task2 = Task(description="Step 2", agent=agent2, context=[task1])
task3 = Task(description="Step 3", agent=agent3, context=[task1, task2])

agents = AgentTeam(
    agents=[agent1, agent2, agent3],
    tasks=[task1, task2, task3],
    process="workflow"
)

Async Support

Full async/await support for non-blocking execution:
import asyncio
from praisonaiagents import Agent, Task, AgentTeam

async def main():
    agents = AgentTeam(
        agents=[agent1, agent2],
        tasks=[task1, task2],
        process="workflow"
    )
    
    result = await agents.astart()
    print(result["task_results"])

asyncio.run(main())

Shared State

Agents can share state during execution:
agents = AgentTeam(agents=[agent1, agent2], tasks=[task1, task2])

# Set shared state
agents.set_state("api_key", "xxx")
agents.set_state("config", {"mode": "production"})

# Access in tasks via context
result = agents.start()

# Read state after execution
final_data = agents.get_state("collected_data")

Advanced Examples

With Memory

agents = AgentTeam(
    agents=[agent1, agent2],
    tasks=[task1, task2],
    memory=True,  # Enable shared memory
    user_id="user123"
)

With Custom Completion Checker

def my_checker(task, output):
    """Custom validation for task completion."""
    if "error" in output.lower():
        return False, "Output contains errors"
    return True, output

agents = AgentTeam(
    agents=[agent1],
    tasks=[task1],
    completion_checker=my_checker
)

With Verbose Logging

agents = AgentTeam(
    agents=[agent1, agent2],
    tasks=[task1, task2],
    verbose=2  # Debug level
)

See Also