Agent Orchestrator: A Laravel AI Agent Framework with Multi-Tenancy

Agent Orchestrator: A Laravel AI Agent Framework with Multi-Tenancy

The Laravel ecosystem has produced numerous packages for connecting to LLMs -- from LarAgent to Vizra ADK to Neuron AI. What has been missing is a framework that treats multi-tenancy as a core concept rather than an afterthought. This is exactly where Agent Orchestrator comes in.

Why Another AI Framework?

In SaaS applications, multiple teams or tenants operate on a shared platform. Existing Laravel AI packages treat multi-tenancy as an optional plugin at best. Agent Orchestrator reverses this relationship: team isolation, cost attribution, and tenant-specific agents are built in from the start.

Installation

composer require agenticorchestrator/agenticorchestrator
php artisan vendor:publish --provider="AgenticOrchestrator\AgenticOrchestratorServiceProvider"
php artisan migrate

Core Concepts

Creating Agents

A new agent is generated with an Artisan command:

php artisan agent:make CustomerSupportAgent
use AgenticOrchestrator\Agents\Agent;
use AgenticOrchestrator\Tools\Attributes\Tool;
 
class CustomerSupportAgent extends Agent
{
    protected string $name = 'Customer Support';
    protected string $description = 'Handles customer inquiries';
    protected string $model = 'gpt-4o';
 
    public function instructions(): string
    {
        return "You are a helpful support agent for {$this->team->name}.";
    }
 
    #[Tool('Look up customer order')]
    public function lookupOrder(string $orderId): array
    {
        return $this->team->orders()
            ->where('id', $orderId)
            ->firstOrFail()
            ->toArray();
    }
}

The #[Tool] attribute automatically registers methods as tools that the LLM can invoke via function calling. Schema generation is handled by the framework.

Multi-Tenancy

Agent Orchestrator supports six tenant resolvers out of the box:

  • Jetstream Teams -- for Laravel Jetstream
  • Stancl Tenancy -- for stancl/tenancy
  • Spatie Multitenancy -- for spatie/laravel-multitenancy
  • Filament -- for Filament panels
  • Generic Eloquent -- for custom team models
  • Null Resolver -- for single-tenant operation
// System agent (platform-wide, read-only)
class SystemHelpAgent extends Agent
{
    protected bool $isSystem = true;
}
 
// Team-owned agent
class TeamSalesAgent extends Agent
{
    protected bool $isSystem = false;
}
 
// Get available agents for a team
$agents = $team->availableAgents();

Workflow Engine

Complex processes are defined as workflows -- with sequential, parallel, conditional, and loop steps:

use AgenticOrchestrator\Workflows\Workflow;
use AgenticOrchestrator\Workflows\Patterns\ParallelPattern;
use AgenticOrchestrator\Workflows\Steps\{AgentStep, ConditionalStep};
 
class OnboardingWorkflow extends Workflow
{
    public function definition(): array
    {
        return [
            new AgentStep(WelcomeAgent::class, output: 'welcome'),
 
            ParallelPattern::make([
                new AgentStep(AccountSetupAgent::class, output: 'account'),
                new AgentStep(PreferencesAgent::class, output: 'prefs'),
            ]),
 
            new ConditionalStep(
                condition: fn ($ctx) => $ctx->get('customer.plan') === 'enterprise',
                then: new AgentStep(EnterpriseSetupAgent::class),
            ),
 
            new AgentStep(SummaryAgent::class, output: 'summary'),
        ];
    }
}

Beyond these basic patterns, Supervisor, MapReduce, Chain-of-Thought, and Human-in-the-Loop steps are available.

Memory System

Five memory drivers cover different requirements:

DriverUse Case
SessionWithin a single request
CacheRedis/cache-based persistence
DatabaseLong-term storage in the database
VectorSemantic search across 5 vector stores
RAGRetrieval-augmented generation with chunking and reranking
// Configure vector memory
protected array $memory = [
    'driver' => 'vector',
    'vector_store' => 'pinecone',
    'namespace' => 'support',
];
 
// Usage
$this->getMemory()->store('customer_123', $preferences);
$results = $this->getMemory()->search('return policy', limit: 5);

RAG Pipeline

The built-in RAG pipeline provides document loaders, chunking strategies, and retrieval with reranking:

use AgenticOrchestrator\Rag\RagPipeline;
 
$pipeline = RagPipeline::make()
    ->loadFrom('/docs/knowledge-base')
    ->chunkWith('recursive-character', chunkSize: 512)
    ->embedWith('openai')
    ->storeIn('qdrant')
    ->build();

Evaluation with LLM-as-Judge

Agents can be evaluated automatically -- with built-in metrics like relevance, accuracy, helpfulness, and safety:

php artisan agent:evaluate CustomerSupportAgent

Production Features

Agent Orchestrator ships with everything needed for production use:

  • Rate Limiting -- per user, team, agent, or token-based
  • Caching -- for responses, embeddings, and tool results
  • Circuit Breaker -- automatic interruption on provider failures
  • Fallback Chains -- automatic switching between LLM providers
  • Usage Tracking -- token consumption, costs, and latency per team/agent
  • Event System -- for observability and monitoring

LLM Providers

Over 10 providers are supported via Prism PHP:

OpenAI, Anthropic, Google Gemini, Mistral, Ollama, Groq, xAI, DeepSeek, and more.

Requirements

  • PHP 8.3+
  • Laravel 11.0+ or 12.0+

Links


Building AI-powered SaaS applications with Laravel? Contact me for a no-obligation consultation.