PHPackages                             laragentic/agents - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. laragentic/agents

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

laragentic/agents
=================

Agentic loops and AI agent capabilities for the Laravel AI SDK

v0.8.1(2mo ago)4150↑116.7%[1 PRs](https://github.com/laragentic/agents/pulls)MITPHPPHP ^8.2

Since Feb 15Pushed 2mo agoCompare

[ Source](https://github.com/laragentic/agents)[ Packagist](https://packagist.org/packages/laragentic/agents)[ RSS](/packages/laragentic-agents/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (12)Versions (22)Used By (0)

Laragentic Agents
=================

[](#laragentic-agents)

**Add one trait. Get autonomous AI agents.**

Laragentic extends the [Laravel AI SDK](https://laravel.com/docs/12.x/ai-sdk) with agentic loops — letting your agents autonomously reason, call tools, and iterate until they reach an answer.

```
class ChatAgent implements Agent, HasTools
{
    use Promptable, ReActLoop; // ← add this trait

    // ... your existing agent code
}

$result = (new ChatAgent)->reactLoop('What is the weather in Tokyo?');

echo $result->text(); // "It's 22°C and partly cloudy in Tokyo."
```

Your agent now thinks, calls tools on its own, reads the results, and keeps going until it has a complete answer — all in one method call.

---

See It In Action
----------------

[](#see-it-in-action)

### ReAct Loop: Autonomous Reasoning + Acting

[](#react-loop-autonomous-reasoning--acting)

The agent thinks, searches, calculates, and synthesizes — all on its own.

[![ReAct Loop Demo](tutorial/images/react-loop.png)](tutorial/images/react-loop.png)

### Plan-Execute Loop: Multi-Step Planning &amp; Synthesis

[](#plan-execute-loop-multi-step-planning--synthesis)

Watch the agent create a plan, execute each step, and synthesize the final answer.

[![Plan-Execute Loop](tutorial/images/plan-execute-loop.png)](tutorial/images/plan-execute-loop.png)

### Complete Chat Agent with Tools

[](#complete-chat-agent-with-tools)

A full conversational agent with weather lookup and calculator capabilities.

[![Complete Chat Example](tutorial/images/complete-chat-example.png)](tutorial/images/complete-chat-example.png)

> **Want to try these examples?** Clone the **[laragentic-app-examples](https://github.com/laragentic/laragentic-app-examples)** repository — a complete Laravel app with all demos ready to run.

---

Why Laragentic?
---------------

[](#why-laragentic)

The Laravel AI SDK gives you agents, tools, streaming, and conversations. But when you call `prompt()`, the agent responds once — if it wants to call a tool, inspect the result, and reason further, you have to write that loop yourself.

Laragentic adds that missing piece:

What you getWhat it does**ReAct Loop**Think → call tools → observe results → repeat until done**Plan-Execute Loop**Create a plan → execute each step → synthesize a final answer**Chain-of-Thought Loop**Reason iteratively → evaluate understanding → continue until confident**Agent Skills System**Dynamic skill loading with progressive disclosure and auto-discovery**Lifecycle Callbacks**Hook into every phase to stream progress, log, or broadcast**Configurable Limits**Set max iterations/steps to control cost and prevent runaway loops**Adaptive Replanning**The Plan-Execute loop revises its plan mid-execution if a step fails**Zero configuration required.** Add `use ReActLoop` to your agent, call `->reactLoop()`, and it works.

---

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 12.x
- [Laravel AI SDK](https://github.com/laravel/ai) (`laravel/ai`)

Installation
------------

[](#installation)

```
composer require laragentic/agents
```

Optionally publish the configuration:

```
php artisan vendor:publish --tag=agentic-config
```

---

Quick Start
-----------

[](#quick-start)

This guide assumes you have a Laravel 12 app with [Inertia](https://inertiajs.com/), React, and the [Laravel AI SDK](https://laravel.com/docs/12.x/ai-sdk) already installed.

You'll create three files to get a working agent that calls tools autonomously and streams real-time progress to a frontend:

FileWhat it does`app/Tools/WeatherTool.php`A tool the agent can call`app/Agents/ChatAgent.php`An agent with the ReAct loop`resources/js/pages/chat.tsx`A React frontend that streams progress### Step 1: Create a Tool

[](#step-1-create-a-tool)

Tools implement `Laravel\Ai\Contracts\Tool`. They have a name, a description (so the LLM knows when to use them), a JSON schema for parameters, and a `handle()` method that does the work.

Create `app/Tools/WeatherTool.php`:

```
