Skip to main content

Background Tasks Deployment

Deploy background task execution for running agents and recipes asynchronously in production environments.

Overview

Background tasks allow you to:
  • Run recipes and agents without blocking
  • Track progress and status
  • Cancel running tasks
  • Manage concurrent execution

Quick Start

Python Deployment

Async callers (FastAPI / Jupyter)

From within a running event loop, use arun_background. The sync run_background raises RuntimeError in that context instead of deadlocking:
Never call recipe.run_background() from a running event loop — it raises RuntimeError and points you to arun_background.

CLI Deployment

Configuration

Safe Defaults

TEMPLATE.yaml Runtime Block

Configure background task defaults in your recipe’s TEMPLATE.yaml:

Docker Deployment

Production Considerations

Concurrency Limits

Set appropriate concurrency limits based on your infrastructure:

Monitoring

Monitor background tasks using the CLI:

Error Handling

See Also