Skip to content

Events

Namespace Fomvasss\AiTasks\Events.

EventWhenProperties
AiTaskQueuedTask dispatched to the queuetask, run
AiTaskStartedProvider call begins (per driver attempt)task, context, run
AiTaskCompletedFinal result ready — postprocess done, retries settledtask, response, run, attemptsExhausted
AiTaskFailedOne driver attempt failed; the chain may still succeedtask, error, run
AiTaskFailedFinallyThe task ended without a result; fired together with AiTask::onFailed()task, reason, run (null if nothing started)
AiTaskCompletedHandlerFailedAiTask::onCompleted() threwtask, exception, run
AiRunFinishedLow-level: a run row finished okrun
AiRunFailedLow-level: a run row failed — for a queued run once, after its retries are exhaustedrun
use Fomvasss\AiTasks\Events\AiTaskCompleted;
use Illuminate\Support\Facades\Event;
Event::listen(AiTaskCompleted::class, function (AiTaskCompleted $event) {
// $event->task, $event->response, $event->run, $event->attemptsExhausted
});

For a task with a single consumer, the onCompleted() and onFailed() hooks are simpler than listeners.

Closing a run with the dashboard Dead button or AiRun::abandon() fires no event.