Skip to main content
Vizra ADK is in maintenance mode. It continues to work and receives compatibility fixes, but no new features are planned. For evaluating AI agents — now built on the official Laravel AI SDK — check out Vizra Evals, its successor for the evaluation use-case. Coming from ADK? See the migration guide.

What is Agent Queuing?

Agent Queuing allows you to execute AI agents asynchronously using Laravel’s queue system. This is useful for long-running tasks, background processing, and scenarios where you don’t need immediate responses.

Background Processing

Run LLM agents and media generation in the background without blocking requests

Laravel Integration

Uses Laravel’s native queue system - works with any queue driver (Redis, SQS, database, etc.)

Retry & Timeout

Built-in retry logic and configurable timeouts for reliable execution

Event-Driven

Dispatches events on completion and failure for easy integration

Quick Start

LLM Agent Queuing

Media Agent Queuing

When you specify a queue with onQueue(), async mode is automatically enabled - no need to call async() separately.

LLM Agent Queuing

LLM agents can be queued using the fluent executor API. This is useful for tasks that may take a while to complete, such as complex analysis or multi-step reasoning.

Enabling Async Execution

Queue Configuration Options

Complete LLM Agent Example

Media Agent Queuing

Media agents (ImageAgent, AudioAgent) support the same queuing options plus additional features like post-generation callbacks and auto-storage.

Queue Configuration Options

Post-Generation Callbacks

Use the then() method to execute code after generation completes:
The then() callback must be serializable for queue processing. Avoid using $this or non-serializable objects inside the closure.

Auto-Storage Options

Configure automatic storage directly in the fluent chain:

Complete Media Agent Example

Job Response & Tracking

When you dispatch an agent to a queue, you receive an immediate response with job information:

LLM Agent Response

Media Agent Response

Retrieving Results from Cache

Job results are automatically cached for retrieval:

Cache Key Reference

Events

The queuing system dispatches events on job completion and failure, allowing you to react to agent execution status.

LLM Agent Events

Media Agent Events

Event Listener Examples

Event payloads include the job_id, agent_class, session_id, and the full result or response object. Use these to update your database, send notifications, or trigger follow-up actions.

Job Tagging

Jobs are automatically tagged for easy filtering and monitoring with tools like Laravel Horizon.

LLM Agent Tags

Media Agent Tags

Viewing Tags in Horizon

If you’re using Laravel Horizon, you can filter jobs by these tags:

Configuration & Prerequisites

Queue Driver Configuration

Agent queuing uses Laravel’s standard queue system. Configure your preferred driver in .env:
Supported drivers include redis, database, sqs, beanstalkd, and others.

Running Queue Workers

Process queued jobs with Laravel’s queue worker:

Supervisor Configuration

For production, use Supervisor to keep queue workers running:

Horizon Configuration

For advanced monitoring and management, use Laravel Horizon:
config/horizon.php

Best Practices

Use Dedicated Queues

Separate agent and media jobs from other application jobs using dedicated queues

Set Appropriate Timeouts

LLM tasks may need longer timeouts (5-10 min), while media generation is typically faster (2 min)

Monitor with Horizon

Use Laravel Horizon for real-time monitoring, metrics, and job management

Handle Failures

Always listen for failure events and implement appropriate error handling

Timeout Guidelines

Complete Examples

Background Report Generation

Batch Image Generation

Image Agent

Learn about ImageAgent and its queuing features

Audio Agent

Learn about AudioAgent and speech generation