Back to Agno

README

cookbook/03_teams/14_run_control/README.md

3.0.12.2 KB
Original Source

Run Control

Controlling a team run: cancelling one mid-flight, running one in the background and polling it, retrying transient errors, inheriting a model across members, and calling a team hosted on another AgentOS.

Seven of these drive the team object in process; remote_team.py is the one that goes over HTTP. Pausing a team for a human decision lives in ../20_human_in_the_loop/, and the same run control driven through AgentOS routes lives in cookbook/05_agent_os/04_run_lifecycle.

Prerequisites

  • Load environment variables (for example, OPENAI_API_KEY) via direnv allow.
  • Use .venvs/demo/bin/python to run cookbook examples.
  • Some examples require additional services (for example PostgreSQL, LanceDB, or Infinity server) as noted in file docstrings.

Examples

ExampleWhat it showsNeeds
cancel_run.pyCancel an in-flight team run from a separate thread.
cancel_run_persistence.pyCancel mid-stream and verify partial content and messages are preserved in the database.PostgreSQL
team_cancel_while_member_runs.pyCancel a team run while a member agent is actively streaming; the cancellation propagates and both runs persist as cancelled.PostgreSQL
background_execution.pyStart a run that returns immediately as PENDING, then poll for completion or cancel it.PostgreSQL
background_execution_metrics.pyMetrics are tracked for team background runs and read back off the stored run.PostgreSQL
model_inheritance.pyMember models inherit from the parent team's model.
remote_team.pyCall and stream a team hosted on a remote AgentOS instance.AgentOS on :7778
retries.pyTeam retry configuration for transient run errors.

Running

bash
.venvs/demo/bin/python cookbook/03_teams/14_run_control/cancel_run.py
.venvs/demo/bin/python cookbook/03_teams/14_run_control/model_inheritance.py
.venvs/demo/bin/python cookbook/03_teams/14_run_control/retries.py