Background Module
The background module provides the ability to run agents in the background, allowing long-running tasks without blocking the main thread.Installation
Features
- Long-running tasks without blocking
- Task queuing and management
- Progress monitoring and notifications
- Graceful cancellation
Quick Start
Classes
BackgroundRunner
Main class for managing background tasks.Constructor
Methods
BackgroundTask
Represents a background task.Attributes
Methods
TaskStatus
Enumeration of task statuses.BackgroundConfig
Configuration for background runner.Usage Examples
Basic Background Task
With Callback
Multiple Tasks
Task Cancellation
Progress Monitoring
Best Practices
- Set appropriate timeouts - Prevent tasks from running indefinitely
- Handle failures - Always provide error callbacks
- Limit concurrency - Don’t overwhelm resources with too many workers
- Clean up - Call
shutdown()when done with the runner - Monitor progress - Track long-running tasks

