maestroerror/laragent
LarAgent is an open-source AI agent framework for Laravel. Build and maintain agents with an Eloquent-style API, pluggable tools (incl. MCP server support), memory/context management, multi-agent workflows, queues, and structured output for reliable integrations.
LarAgent is a highly Laravel-native package, leveraging Laravel’s core patterns (Eloquent-like syntax, Artisan commands, service providers, and event-driven architecture). This makes it an excellent fit for Laravel applications, particularly those requiring AI agent integration with minimal boilerplate. Key alignment points:
LarAgent\Agent, mirroring Laravel’s Eloquent model structure. This reduces cognitive load for Laravel developers.AgentMessageSent, ToolExecution) allows for deep customization and observability.Potential Misalignment:
sendMessageStreamed() method exists). For real-time apps, additional infrastructure (e.g., Laravel Echo + Pusher) would be needed.| Integration Vector | Feasibility | Notes |
|---|---|---|
| New Laravel Projects | ⭐⭐⭐⭐⭐ | Zero-config setup for greenfield apps with Laravel 10+. |
| Legacy Laravel Apps | ⭐⭐⭐⭐ | Requires PHP 8.3+ and Laravel 10+. Migration path exists but may need deprecation handling. |
| Monolithic Apps | ⭐⭐⭐⭐ | Tight coupling with Laravel’s service container; may need refactoring for microservices. |
| Microservices | ⭐⭐⭐ | Possible but requires API exposure (LarAgent’s OpenAI-compatible schema) and externalizing chat history (e.g., Redis/DB). |
| Headless/CLI Apps | ⭐⭐⭐⭐⭐ | Ideal for automated workflows (e.g., internal tools, data processing). |
Key Dependencies:
laravel-queue is configured (e.g., Redis, database).| Risk Area | Severity | Mitigation |
|---|---|---|
| Vendor Lock-in | Medium | LarAgent abstracts LLM providers, but custom drivers require maintenance. Use provider fallbacks (e.g., ['default', 'gemini']). |
| Cost Overruns | High | Monitor token usage (LarAgent tracks max_completion_tokens). Implement budget alerts. |
| Performance Bottlenecks | Medium | Parallel tool calls improve throughput, but complex workflows may hit LLM rate limits. Use parallelToolCalls: false for critical paths. |
| State Management | High | Per-user chat history scales poorly without distributed storage. Use Redis for shared sessions. |
| Tool Reliability | Medium | Structured output reduces errors, but custom tools may fail silently. Add retries with Tool::retry() or events. |
| Event System Complexity | Low | Extensive events enable customization but may require deep Laravel knowledge. Document event hooks in code. |
Critical Questions for TPM:
LarAgent is optimized for Laravel-centric stacks and integrates seamlessly with:
Non-Laravel Compatibility:
| Phase | Steps | Tools/Commands |
|---|---|---|
| Preparation | 1. Upgrade to Laravel 10+ and PHP 8.3+. | composer update |
| 2. Review existing AI workflows (if any) for compatibility. | Manual audit | |
3. Set up LLM provider API keys in .env. |
env('OPENAI_API_KEY') |
|
| Installation | 4. Install LarAgent via Composer. | composer require maestroerror/laragent |
| 5. Publish config and migrate providers. | php artisan vendor:publish --tag=laragent-config |
|
| Agent Development | 6. Create first agent using Artisan. | php artisan make:agent CustomerSupportAgent |
| 7. Define tools, instructions, and history storage. | Custom agent class | |
| Integration | 8. Integrate agent into routes/controllers. | Laravel routes |
| 9. Set up queue workers for async tasks. | php artisan queue:work |
|
| Testing | 10. Write unit tests for agents/tools. | Pest/Laravel Testing |
| 11. Test with manual API keys (if needed). | testsManual/ |
|
| Deployment | 12. Deploy with monitoring for token usage and failures. | New Relic/Sentry |
| 13. Set up provider fallbacks (if multi-provider). | config/laragent.php |
Rollback Plan:
| Component
How can I help you explore Laravel packages today?