AI task execution lifecycle
The Lifecycle
Transitions Explained
The wrapper creates running work and supplies a context that carries its task identity. It closes on return or exception, while process interruption leaves recovery to record abandonment. Late request settlements can continue to change totals for completed, failed or abandoned tasks.
What Cannot Happen
A closed task is never reopened by the wrapper. Replaying an existing key does not rerun its work. Nesting task wrappers is rejected, and task status is independent of whether its underlying domain work was persisted.
Concurrency and Timing
Task creation commits before work begins. A successful body followed by a failed close still returns an error; an unsuccessful body preserves its original error even if closing fails. Recovery abandonment records detection time, not the unknown instant the process stopped.