AI systems
When an AI task belongs in a background job
Long-running agent work needs a lifecycle that survives a browser tab, a request timeout, and a temporary provider failure.
Aryan (@istmX)3 min read
Start with a clear boundary
When work outlasts an ordinary HTTP request, accept it quickly and return an identifier. The client can follow progress without holding a connection open.
Handle failure deliberately
Define queued, running, completed, failed, and cancelled states explicitly. Retries need limits and idempotency so timeouts do not duplicate side effects.
Make the result understandable
Persist enough state to recover after a worker restarts. Report real milestones rather than invented percentages, and make finished artifacts retrievable.