PHPackages                             funkyoz/mulagent - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. funkyoz/mulagent

ActiveLibrary

funkyoz/mulagent
================

LLM multi agent library

1.1.0(1y ago)86MITPHPPHP ^8.1.0

Since Jan 28Pushed 1y ago3 watchersCompare

[ Source](https://github.com/FunkyOz/mulagent)[ Packagist](https://packagist.org/packages/funkyoz/mulagent)[ Fund](https://www.buymeacoffee.com/funkyoz)[ GitHub Sponsors](https://github.com/FunkyOz)[ RSS](/packages/funkyoz-mulagent/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (10)Versions (4)Used By (0)

MulAgent Documentation
======================

[](#mulagent-documentation)

 [![MulAgent](mulagent-screen.jpg)](mulagent-screen.jpg)

 [ ![GitHub Tests](https://camo.githubusercontent.com/0bce217dfcf6be975f4bd7cceb58e611e7a71a9271b11ed72d79959acef4a7ec/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f66756e6b796f7a2f6d756c6167656e742f74657374732e796d6c3f6272616e63683d6d61696e) ](https://github.com/FunkyOz/mulagent/actions) [ ![Packagist Downloads](https://camo.githubusercontent.com/2bc6d1b76a36b3ca9c4acd8281cbe545cd093a418dee55e607b940477f7ad971/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f66756e6b796f7a2f6d756c6167656e74) ](https://packagist.org/packages/funkyoz/mulagent) [ ![Latest Version](https://camo.githubusercontent.com/c867286e2a9f380eb25837f54c3b66c4e6dda5466192a81ec32373115f244ed4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f66756e6b796f7a2f6d756c6167656e74) ](https://packagist.org/packages/funkyoz/mulagent) [ ![License](https://camo.githubusercontent.com/23db9a3fe08a42573261d5cd89ec8f11cf26e56b5960acc1f85166068d538443/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f66756e6b796f7a2f6d756c6167656e74) ](https://packagist.org/packages/funkyoz/mulagent)

MulAgent is a PHP package that provides a simple Multi-Agent implementation for LLM applications. It allows you to create and orchestrate multiple AI agents that can work together, each with their own specific tools and capabilities. The package currently supports OpenAI's API.

Inspired by [OpenAI Swarm](https://github.com/openai/swarm).

Key Features
------------

[](#key-features)

- Multi-agent orchestration with routines and handoffs
- Simple tool-based architecture using PHP functors
- Simple integration with OpenAI's API
- Support for PHP 8.1+
- Type-safe implementation

Quick Examples
--------------

[](#quick-examples)

### 1. Basic Agent Without Tools

[](#1-basic-agent-without-tools)

```
use MulAgent\Agent\Agent;
use MulAgent\LLM\OpenAI\OpenAIConfig;
use MulAgent\LLM\OpenAI\OpenAILLM;
use MulAgent\Message\Message;
use MulAgent\MulAgent;

// Configure OpenAI
$config = OpenAIConfig::create([
    'model' => 'gpt-4',
    'temperature' => 1,
    'api_key' => getenv('OPENAI_API_KEY'),
]);

// Create LLM instance
$llm = new OpenAILLM($config);

// Create an agent
$agent = new Agent(
    name: 'Assistant',
    llm: $llm,
    instruction: 'You are a helpful assistant.'
);

// Initialize MulAgent
$mulAgent = new MulAgent($agent);

// Run a conversation
$messages = [Message::user('What is the capital of France?')];
$response = $mulAgent->run($messages);
```

### 2. Agent with Custom Tools

[](#2-agent-with-custom-tools)

```
// Create calculator tools using PHP functors
$addTool = new class () {
    public string $name = 'add';

    public function __invoke(float $first, float $second): string
    {
        return (string)($first + $second);
    }
};

$multiplyTool = new class () {
    public string $name = 'multiply';

    public function __invoke(float $first, float $second): string
    {
        return (string)($first * $second);
    }
};

$divideTool = new class () {
    public string $name = 'divide';

    public function __invoke(float $first, float $second): string
    {
        if (.0 === $second) {
            return 'Cannot divide by zero';
        }
        return (string)($first / $second);
    }
};

// Create and use the agent with calculator tools
$agent = new Agent(
    name: 'Calculator',
    llm: $llm,
    instruction: 'You are a math assistant.',
    tools: [$addTool, $multiplyTool, $divideTool]
);

$mulAgent = new MulAgent($agent);
```

### 3. Agent with Handoff Capability

[](#3-agent-with-handoff-capability)

```
use MulAgent\Tool\AgentTool;

// Create two specialized agents
$mathAgent = new Agent(
    name: 'Math Expert',
    llm: $llm,
    instruction: 'You are a mathematics expert.'
);

$scienceAgent = new Agent(
    name: 'Science Expert',
    llm: $llm,
    instruction: 'You are a science expert.',
    tools: [new AgentTool($mathAgent)] // Science agent can hand off to math agent
);

$mulAgent = new MulAgent($scienceAgent);
```

For more detailed examples and advanced usage, check out the [examples](./examples) directory.

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance42

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~5 days

Total

3

Last Release

464d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e514715cf91f6a708bd30e650da5d073973adf1855b0762ec40f39659956c6d6?d=identicon)[FunkyOz](/maintainers/FunkyOz)

---

Top Contributors

[![FunkyOz](https://avatars.githubusercontent.com/u/26649880?v=4)](https://github.com/FunkyOz "FunkyOz (23 commits)")

---

Tags

phpaiopenaiAgentllmanthropicMulti-agent

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/funkyoz-mulagent/health.svg)

```
[![Health](https://phpackages.com/badges/funkyoz-mulagent/health.svg)](https://phpackages.com/packages/funkyoz-mulagent)
```

###  Alternatives

[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.5k311.5k5](/packages/theodo-group-llphant)[deepseek-php/deepseek-php-client

deepseek PHP client is a robust and community-driven PHP client library for seamless integration with the Deepseek API, offering efficient access to advanced AI and data processing capabilities.

47073.9k5](/packages/deepseek-php-deepseek-php-client)[llm-agents/agents

LLM Agents PHP SDK - Autonomous Language Model Agents for PHP

16410.9k9](/packages/llm-agents-agents)[sbsaga/toon

🧠 TOON for Laravel — a compact, human-readable, and token-efficient data format for AI prompts &amp; LLM contexts. Perfect for ChatGPT, Gemini, Claude, Mistral, and OpenAI integrations (JSON ⇄ TOON).

6115.6k](/packages/sbsaga-toon)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
