Background agents run tasks outside the main request/response cycle. They watch for triggers (a schedule, an event, a queue), then do focused work without blocking the user.

Use them when:

  • You need reliability and retries (e.g., send emails, process uploads)
  • Work is slower than a page load (e.g., fetch from external APIs)
  • You want to decouple UX from infrastructure spikes

Keep them simple: one job, idempotent steps, clear logs, dead-letter on failure, and metrics you actually look at.