Skip to main content
Do not block a chat turn on work that can run in the background. Capsule tasks and schedules keep that work inside the same app definition. Use tasks for work triggered by a user action. Use schedules for recurring work.

1. Define a task

Tasks are normal Python functions registered with the app.

2. Submit from chat

show_task(...) renders a task card in chat so the user can see that work is running.

3. Show tasks on a page

Use this for operator visibility instead of hiding long-running work in logs.

4. Add a schedule

Schedules use cron strings and run inside the same app runtime model.

5. Add control

Task options help make background work production-shaped:
  • retries handles transient failures.
  • timeout prevents runaway work.
  • lock avoids duplicate work for the same key.
  • process=True isolates CPU-heavy or crash-prone work.

Next steps