Overview
Every AI agent runs on a loop: think, act, check, repeat. That loop decides how many AI calls a task costs, how long it takes and how good the answer is. Most agent packages pick the loop for you and hide it. laravel-agent-loops makes it a choice. It sits on top of the official Laravel AI SDK, so your agents, tools and providers stay the same. Only the thinking style changes. Three loops ship out of the box: - react: answers in one go. Cheap and fast. - plan-execute: makes a plan, then works through it step by step. - reflect-retry: reviews its own answer and retries with feedback until it's approved. You can pick a loop three ways: per call with using(), per agent with a #[UseLoop] attribute, or app-wide in config. One artisan command, agent-loops:compare, runs the same task through every loop and reports steps, tokens and time. It also has an optional AI judge and JSON output for CI. In a real test with Gemini, the cheapest loop returned a list of options when the task asked for one tweet, and the self-review loop approved it. I made the reviewer stricter, and on the rerun it rejected the list and returned a single tweet. That's the point of the package: measure which loop works for your app instead of guessing. Released as v0.1.0 on Packagist. PHP 8.4, Laravel 13, MIT licensed, 46 tests with CI.
Engineering
Challenges
Solutions
Tech Stack
Project Info
Links