Download the PHP package twdnhfr/laravel-deepagents without Composer

On this page you can find all versions of the php package twdnhfr/laravel-deepagents. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-deepagents

Laravel Deep Agents

Latest Version on Packagist Tests

A deep-agent harness for the Laravel AI SDK — an owned, resumable agent loop with planning, sub-agents, human-in-the-loop approval, multi-turn conversations, memory and automatic context management, built on top of laravel/ai.

[!WARNING] Early work in progress. The runtime and core harness are built and tested — owned agent loop, human-in-the-loop, multi-turn, planning, sub-agents, memory and context management (summarization + tool-output offloading) over pluggable backends. Skills are planned; filesystem/shell tools and token streaming are out of scope for now (see docs/adr/). APIs may still change before 1.0.

[!NOTE] Not affiliated with or endorsed by LangChain. An independent reimplementation for Laravel, inspired by the deepagents project.

What is Laravel Deep Agents?

The Laravel AI SDK (laravel/ai) is an excellent engine: one unified, expressive API over many providers (OpenAI, Anthropic, Gemini, and more), with tool calling, structured output, streaming, embeddings and more. Point it at a model, hand it some tools, call prompt() — done.

But an engine is not an agent harness. The moment you ask an agent to do real, long-horizon work — research across many steps, read and write files, delegate subtasks to focused sub-agents, pause for your approval before doing something destructive, and later pick up exactly where it left off — you need a layer of opinionated machinery on top: planning, a virtual filesystem, sub-agents, automatic context management, human-in-the-loop, skills and memory.

In the Python/LangChain world that layer is deepagents"the batteries-included agent harness", itself an attempt to distill what makes Claude Code general-purpose. There was no equivalent for Laravel.

Laravel Deep Agents is that layer. It builds on top of laravel/ai and brings the deepagents feature set to PHP:

The SDK stays the engine. This package adds the harness.

Why a custom loop?

laravel/ai runs its model↔tool loop inside the provider — great for a one-shot prompt(), but it gives you no place to step in between the model choosing a tool and that tool running. That in-between is exactly where approval gates, permission checks and context compaction live.

So this package owns the loop: it drives one model turn at a time and decides for itself when to run a tool, when to pause for a human, and when it's done. The entire state of a run is a plain, serializable value object — so a run can pause, be stored in your database or a queued job, and resume in a completely different request.

The how-and-why is recorded as Architecture Decision Records in docs/adr/.

Requirements

Installation

The package auto-registers. Configure your provider and API key through the Laravel AI SDK as usual (e.g. ANTHROPIC_API_KEY in .env and the provider entry in config/ai.php).

Quickstart

Define a tool (the standard laravel/ai Tool contract), then build and run an agent:

By default the agent runs autonomously: it calls tools and loops until it has a final answer.

[!NOTE] One tool instance per agent. Built-in tools receive run-scoped state (the RunState, the storage backend) by injection right before execution — an instance shared between two agents (e.g. a parent and a sub-agent) would leak state between their runs. Construct tools fresh per agent, as in the example.

Planning with todos

Give the agent the built-in write_todos tool so it can keep a visible plan. The list lives on the run state:

Human-in-the-loop: approve before tools run

Opt into approval mode and the agent suspends before any tool call instead of executing it. The suspended run is fully serializable, so you can store it, show the pending action to a human, and resume later — in another request or a queued job:

The human does not have to wave everything through. Record a per-call decision on the state before resuming — approve as-is (the default), execute with corrected arguments, or reject with a reason the model gets back as the tool's result so it can adjust its plan:

Decisions are plain data on the RunState, so they survive toJson()/fromJson() — collect them in a controller, persist, and resume in a queued job. A rejected call is never executed; the model sees The user rejected this tool call: … and reacts. With edit(), the model's original arguments stay visible on the assistant message in the history, so the change is auditable.

Multi-turn conversations

run() starts a fresh run; continue() carries an existing run forward with the user's next message, so the agent keeps full prior context. The run state is serializable, so you can persist it between turns (session, DB, …):

A suspended run (pending tool approval) cannot be continue()d — it throws; resume() it first. Each continue() resets the maxTurns budget, which is otherwise tracked on the run state across suspend/resume.

Sub-agents: delegate to an isolated context

Register a sub-agent and the parent gets a task tool to delegate self-contained work to it. The sub-agent runs as its own DeepAgent to completion and hands back only its final text:

[!IMPORTANT] "Isolated" means the context, not the workspace. A sub-agent gets a fresh conversation — it never sees the parent's message history or todos, and only its final text returns to the parent. But it shares the parent's storage backend (artifacts/memory) by default, mirroring deepagents' shared virtual filesystem. So:

  • Artifacts a sub-agent writes are readable by the parent and its siblings — they all hit the same store. Two agents writing the same path overwrite each other; there is no per-sub-agent sandbox.
  • The exception is offloaded tool output (offloadLargeToolResults()): it is written under the run-scoped path runs/{runId}/tool/{callId}, so runs sharing a persistent backend never collide — and a host can clean up after a run via backend->list("runs/{$state->id}/").
  • To give a sub-agent its own private store, set ->backend(...) on it explicitly — an explicit backend is always kept, never replaced by the parent's.

How it works

Security model

The package's trust boundary sits in your application, not inside the library. What that means in practice:

Status & roadmap

Area State
Agent loop (autonomous + per-tool approval), serializable RunState, HITL resume ✅ built & tested
DeepAgent fluent builder + multi-turn (continue())
write_todos planning tool
Sub-agents (task)
Context management (summarization + tool-output offloading to artifacts)
Memory (AGENTS.md) + BASE prompt assembly
Safe tool execution + dangling-tool-call repair
Pluggable backends (state, filesystem, database, cache) + config-driven default
Filesystem & shell tools 🧊 deferred (see adoption)
Skills, harness profiles, MCP ⏳ planned
Token streaming through the loop ❌ by design — see ADR-0004

The full plan lives in TODO.md.

Demo

See every feature run offline (no API keys), via a scripted provider:

It walks through autonomous tool use, planning, human-in-the-loop approval, context summarization and sub-agents. See examples/.

Example app: deepagents-chat

twdnhfr/deepagents-chat is a small Laravel chat app built on this package — a live, end-to-end example. It shows the owned loop in a real request cycle: a tool-call trace, the human-in-the-loop approval flow, multi-turn conversations, a DatabaseBackend with tool-output offloading, and Markdown-rendered replies.

Testing

Credits & inspiration

License

The MIT License (MIT). See LICENSE.md.


All versions of laravel-deepagents with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
illuminate/contracts Version ^13.0
laravel/ai Version ^0.9.0
spatie/laravel-package-tools Version ^1.16
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package twdnhfr/laravel-deepagents contains the following files

Loading the files please wait ...