AgentTeam Re-runs

Call team.start() again on the same AgentTeam for a fresh run

Next

Build an AgentTeam once and call start() as many times as you like — each call is a fresh run.

Diagram

Resume

📥 team.start X

🧠 Run tasks

✅ Output #1

♻️ team.start Y

🧠 Run tasks fresh

✅ Output #2

💾 restore_session_state

▶️ team.start

⏭ Skip completed

Quick Start

  1. Run the same team twice
    python
    from praisonaiagents import Agent, AgentTeam, Task
    
    writer = Agent(name="Writer", instructions="Summarise the ticket")
    task = Task(description="Summarise the ticket", agent=writer)
    team = AgentTeam(agents=[writer], tasks=[task])
    
    team.start("Ticket A")   # runs the task against Ticket A
    team.start("Ticket B")   # runs it again against Ticket B — no stale output

    The second call re-executes every task, and task.context only holds the latest input (["Ticket B"]). Previously the second call returned the first run’s output.

  2. Keep your own task variables
    python
    task.description = "Summarise {{ticket}}"
    task.variables = {"ticket": "T-1"}
    
    team.start()
    team.start()  # task.variables is still {"ticket": "T-1"}
  3. Change team variables between runs
    python
    task.variables = {}  # let the team's variables flow into the task
    
    team.variables = {"ticket": "T-1"}
    team.start()                         # tasks receive {"ticket": "T-1"}
    team.variables = {"ticket": "T-2"}
    team.start()                         # tasks receive {"ticket": "T-2"} on this run

    The next start() after a start_for_each(...) batch also picks up the current team.variables.


How It Works

A start() after a finished run resets task state first; a start() after restore_session_state() resumes instead.

python
team.start("Ticket A")
team.save_session_state("ticket-run")

# ... later, in a new process, with the same team rebuilt ...
team.restore_session_state("ticket-run")
team.start()             # resume — nothing re-runs, task.status is still "completed"
team.start("Ticket B")   # the next fresh start reruns
StateOn a rerunOn a resume (restore_session_state() + start())
task.statusReset to "not started"Kept ("completed" tasks are skipped)
task.resultClearedKept
task.retry_countReset to 0Kept
Caller-defined Task.variablesKeptKept
Variables propagated from team.variablesCleared; current team.variables re-propagateKept
content appended to task.context by a previous start(content=...)RemovedKept until the next fresh rerun

astart() follows the same rules.


Best Practices

Reuse a team across requests

Build the AgentTeam once, then call team.start(request) per request. Each call is isolated — no stale output, no stale context.

Mutate team.variables between runs

Change team.variables and the next start() picks up the new values automatically; copies propagated to tasks on the previous run are dropped first. Tasks with their own variables keep them.

Use restore_session_state() only for resume

It continues an interrupted run, not a re-execution. The next fresh start() after a resume still reruns and clears the previous inputs.


Related