Background Tasks
The backend offloads long-running work (test execution, generation, Architect chat) to Celery. The
API enqueues a task and returns immediately with a task ID; the worker runs it. This page covers the
backend/API side — enqueuing from a route and polling status. For worker internals (Celery config,
BaseTask, tenant-context decorator, running and monitoring workers), see
Worker Background Tasks.
Enqueuing from a route
Launch tasks with task_launcher, which pulls organization_id and user_id off current_user
so they don’t have to be passed explicitly, then returns the Celery AsyncResult:
The task inherits tenant context from the launch call, so downstream database work runs scoped to the right organization without threading IDs through by hand.
Polling status
Clients poll GET /jobs/\{task_id\}, which reads the result backend:
Callers submit, receive a task_id, then poll until status is SUCCESS or FAILURE. Some
endpoints (e.g. test-set generation, endpoint exploration) also emit progress over WebSocket — see
Architect Chat System.
Related pages
- Worker Background Tasks — Celery config,
BaseTask,@with_tenant_context, running and monitoring workers, error handling - Test execution and Worker troubleshooting — stuck tasks, revoking, time limits
- Email Notifications — completion emails from tasks