Background Tasks (TypeScript)
Run recipes and agents asynchronously in the background with progress tracking, cancellation support, and result retrieval.Installation
Basic Usage
Running a Recipe in Background
BackgroundTaskHandle Interface
Using with Agents
Configuration
Safe Defaults
| Setting | Default | Description |
|---|---|---|
timeoutSec | 300 | Maximum execution time (5 minutes) |
maxConcurrent | 5 | Maximum concurrent tasks |
cleanupDelaySec | 3600 | Time before completed tasks are cleaned up |
Runtime Configuration
Configure in your recipe’sTEMPLATE.yaml:
Error Handling
Best Practices
- Always set timeouts - Prevent tasks from running indefinitely
- Use session IDs - Track related tasks across executions
- Handle cancellation - Clean up resources when tasks are cancelled
- Monitor progress - Use status checks for long-running tasks
- Limit concurrency - Don’t overwhelm system resources
See Also
- Background Tasks CLI - CLI commands
- Async Jobs - Server-based job execution
- Scheduler - Periodic task scheduling

