Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

AI agents in Laravel with Laragents

Description and use

Laragents simplifies AI agent integration in Laravel by providing a tool‑call loop, context compression, memory persistence, and rule handling.

Problem

Integrating AI agents into Laravel applications requires handling tool loops, context management, memory, and rules beyond simple model calls.

Outcome

Laragents streamlines AI agent integration in Laravel, reducing boilerplate, preventing infinite loops, managing context efficiently, and persisting memory and rules across sessions.

Workflow

  • Install Laragents via Composer and publish config/migrations
  • Define domain tools by extending the Tool class and implementing name, description, schema, and execute
  • Configure the loop with model, session, context, and tool registry
  • Run the loop to handle tool calls and generate responses
  • Implement context compression to keep conversation within token limits
  • Persist memory in a queued job after compression or on scheduled sweep
  • Read memory and rules into the prompt before each model call
  • Handle empty‑streaks and iteration caps to avoid infinite loops

Evidence

I wrote all of that twice, in two applications, and the second time I extracted it. It is called laragents.

Source

Two things in there are not obvious until they cost you something.

The third one reads like access control and is not.

  • Record date: 2026-09-05T16:33:02.907Z