Skip to main content
Multi-Agent Execution config controls how many times each task can iterate and how many retries are allowed when tasks fail.
from praisonaiagents import Agent, Task, PraisonAIAgents, MultiAgentExecutionConfig

agent = Agent(name="Researcher", instructions="Research topics thoroughly.")
task = Task(description="Research the history of artificial intelligence", agent=agent)

workflow = PraisonAIAgents(
    agents=[agent],
    tasks=[task],
    execution=MultiAgentExecutionConfig(max_iter=20, max_retries=3),
)
workflow.start()
The user sets iteration and retry limits; the workflow stops or retries tasks within those bounds.

Quick Start

1

Simple Usage

from praisonaiagents import Agent, Task, PraisonAIAgents, MultiAgentExecutionConfig

agent = Agent(name="Helper", instructions="Complete tasks efficiently.")
task = Task(description="Write a marketing email for our new product", agent=agent)

workflow = PraisonAIAgents(
    agents=[agent],
    tasks=[task],
    execution=MultiAgentExecutionConfig(max_iter=10),
)
workflow.start()
2

With Custom Retry Settings

from praisonaiagents import Agent, Task, PraisonAIAgents, MultiAgentExecutionConfig

agent1 = Agent(name="Researcher", instructions="Research topics in depth.")
agent2 = Agent(name="Writer", instructions="Write clear reports.")

task1 = Task(description="Research quantum computing applications", agent=agent1)
task2 = Task(description="Write a report based on the research", agent=agent2)

workflow = PraisonAIAgents(
    agents=[agent1, agent2],
    tasks=[task1, task2],
    execution=MultiAgentExecutionConfig(max_iter=15, max_retries=5),
)
workflow.start()

How It Works

SettingControlsDefault
max_iterMax iterations per task10
max_retriesMax retries on failure5

Configuration Options

Full list of options, types, and defaults — MultiAgentExecutionConfig
OptionTypeDefaultDescription
max_iterint10Maximum iterations per task
max_retriesint5Maximum retries on task failure

Common Patterns

Pattern 1 — Long-running research workflow

from praisonaiagents import Agent, Task, PraisonAIAgents, MultiAgentExecutionConfig

researcher = Agent(name="Researcher", instructions="Do thorough multi-step research.")
writer = Agent(name="Writer", instructions="Write clear, comprehensive reports.")

tasks = [
    Task(description="Research AI trends in 2025", agent=researcher),
    Task(description="Compile findings into a structured report", agent=writer),
]

response = PraisonAIAgents(
    agents=[researcher, writer],
    tasks=tasks,
    execution=MultiAgentExecutionConfig(max_iter=25, max_retries=3),
).start()
print(response)

Pattern 2 — Conservative limits for cost control

from praisonaiagents import Agent, Task, PraisonAIAgents, MultiAgentExecutionConfig

agent = Agent(name="Classifier", instructions="Classify text into categories.")
task = Task(description="Classify 50 customer support tickets", agent=agent)

workflow = PraisonAIAgents(
    agents=[agent],
    tasks=[task],
    execution=MultiAgentExecutionConfig(max_iter=5, max_retries=2),
)
workflow.start()

Best Practices

Simple tasks (classification, extraction) need max_iter=5–10. Complex research or multi-step synthesis tasks may need max_iter=20–30. Start low and increase if tasks don’t complete.
Set max_retries=3–5 for workflows calling external services that may fail intermittently. For offline or deterministic tasks, max_retries=1–2 is usually enough.
Pair MultiAgentExecutionConfig with MultiAgentHooksConfig to log when retries happen. This helps diagnose why tasks hit their retry limit in production.

Multi-Agent Hooks

Intercept task lifecycle events

Multi-Agent Planning

Plan tasks before executing them

Execution Systems

Single-agent execution configuration

Agent Retry

Single-agent retry behavior