Agent classes are the foundation of everything in LarAgent. They define how your AI assistants behave, what capabilities they have, and how they process information.
Other LarAgent features like Tools, Storage, Prompts, etc all revolve around agents.
What are Agents?
In LarAgent, an Agent is a PHP class that represents an AI-powered assistant. Each agent encapsulates:- Instructions — The system prompt that defines the agent’s personality, role, and behavior
- Model configuration — Which LLM to use and how it should respond
- Tools — Functions the agent can call to perform actions or retrieve information
- Context — How conversations (chat history) and other data models are stored and retrieved
CustomerSupportAgent for handling support tickets, a DataAnalysisAgent for processing reports, or a SchedulingAgent for managing appointments.
Or one agent that ochestrates all mentioned above!
Why Agents?
LarAgent’s agent-centric architecture provides several benefits:Reusability
Define an agent once and use it across your application with different chat sessions.
Encapsulation
Keep all AI-related configuration in one place — instructions, tools, and settings.
Testability
Test your agents in isolation with predictable inputs and outputs.
Flexibility
Override any configuration at runtime for specific use cases.
Agent Lifecycle
When you interact with an agent, here’s what happens:Message Processing
Your message passes through the
prompt() method, where you can add context or transform the input.Tool Execution
If the LLM requests tool calls, the agent executes them and continues the conversation.
Quick Example
Here’s what a simple agent looks like:Next Steps
Create & Configure
Learn how to create agent classes and configure their behavior.
Responses
Learn how to interact with agents and handle their responses.
Streaming
Stream responses in real-time for better user experience.
Tools
Extend your agents with custom tools and capabilities.

