Account for a multi-request AI task
What It Does
The wrapper creates a task before work and supplies the context needed to associate its requests. A replay key returns the original execution without rerunning its body.
The Flow
Each request settlement increments totals inside its own transaction. The wrapper closes after work returns or throws.
When Something Fails
Close failure can leave completed work marked running; the hourly sweep later abandons it. Failed-body close errors are logged without replacing the original exception.
Open Design Questions
Consumers must choose replay keys and avoid inferring domain completion from task status alone.