Open source August 2026 /18 pages
Laragents

Laragents

Laragents

Laragents is the part of an AI feature that is not the model call: the loop that runs your tools and knows when to stop, conversations that survive their own context window, memory that outlives a session, rules that outrank what the model feels like doing, and agents that fire on your events instead of waiting to be typed at.

The model call itself is four lines of Guzzle. Everything around it is the work, and it is the same work in every product that ships one.

Written against version 1.0.

Why it exists

Ask a model a question and you get an answer. Ask it to do something and you have built a distributed system, which is the part nobody quotes for.

The first thing you write is a loop, because a model that can call tools does not answer in one go: it asks for a tool, you run it, you hand back the result, it asks for another. That loop needs a ceiling, and you find out why the first time a model reformulates the same failing search eleven times and you read the bill.

The second thing is history. Every turn replays the whole conversation, so a chat that goes well gets more expensive per turn until it hits the context limit and stops working entirely. The fix is to summarise the old turns, once, and reuse the summary, and the trap is summarising the recent ones too, which is exactly where the thread of the exchange lives.

The third thing is memory, and this is the one that gets skipped. A conversation ends and everything it established goes with it. The user explained their situation on Tuesday and explains it again on Thursday, and the product feels like a stranger every time.

Laragents is those three, plus the parts that come after them: which tools a given run may reach for, redaction on the way out to the provider, who gets billed for the tokens, and agents that run without anybody in the chair.

What it is not

It is not a provider wrapper. There are two clients in here, OpenAI and Anthropic, and they exist because the loop needs something to call. If you want fifteen providers behind one interface, laravel/ai is the framework's own answer and it is better at that than this will be.

It does not bring your tools. A tool talks about your domain, so it is yours to write. The package brings the abstract class, the registry, the tag filter, the schema builder and the loop that runs them, and ships exactly two of its own, both about its own memory.

It does not meter anything by default. There is a contract for recording what a run spends and an adapter for larameter, and out of the box it records nothing, because a package should not start refusing calls because you have not wired your billing yet.

Three decisions worth knowing up front

A session has a tenant and a subject, and they are not the same axis. The tenant is who pays and whose data the conversation may see. The subject is what it is about, and it is often absent: a chat that ranges over many properties has no subject, because a property is data the tools fetch, not a frame the conversation lives inside. Conflating the two is what makes a chat impossible to move to the next app.

Everything polymorphic is your morph alias, never the package's word. A scope you call matter is addressed as "matter", including in the prompt the distiller sends the model. Nothing has to be translated into our vocabulary, and nothing gets dropped for failing to translate.

The loop is one loop. The chat and the autonomous agents run the same AgentLoop. In the application this came from they were two executors, one a copy of the other, and the copy had quietly missed out on the redaction the original gained six months later. Nobody noticed, because nothing failed.

What is in it

AgentLoop            call, run tools, feed back, repeat, stop
HistoryCompressor    a stored session becomes a message array that fits
MemoryDistiller      what was said becomes what is remembered
AgentRunner          one run of an autonomous agent
AgentTrigger         what makes one fire: your events, or the clock

Tools\Tool           extend it, write two methods
Tools\ToolRegistry   the catalogue, filtered by tags
Tools\ToolContext    what your tools need, carried without the loop opening it

Skills\BaseSkill     a procedure: instructions plus a whitelist plus one turn
Models\Memory        three axes: whose, what about, who it applies to
Models\Rule          the same three, but obeyed rather than known
Capabilities\*       things the provider does on its own side
Privacy\*            keep personal data out of what leaves
Usage\*              record what it spends

Where to go next

Installation is two commands. Quick start is a working chat turn in about thirty lines. If you already know what you are looking for, the reference lists every class, config key and column.