Think of
BaseLlmAgent as the DNA of your AI agents. Every intelligent behavior, every smart response, every amazing capability starts here.The Agent Family Tree
Understanding the class hierarchy is like knowing your agent’s family tree. Here’s how everything connects:Agent Class Hierarchy
Agent Properties - Your Agent’s DNA
These properties are like your agent’s personality traits. Set them right, and your agent will be amazing.Required Properties
$name
Type:
string (required)Your agent’s unique identifier. Like a superhero name, it should be memorable and descriptive. No two agents can share the same name.$description
Type:
string (required)Tell everyone what your agent does. This human-readable description helps you and your team understand the agent’s purpose at a glance.Optional Properties
Static Method - The Universal Entry Point
All agents use a single, powerful entry point - therun() method. This unified approach keeps things simple and consistent across all your agents.
run()
Method Signature
run() method creates a fluent agent executor that you can configure with various options before executing. It’s your Swiss Army knife for all agent interactions.
Common Usage Patterns
Conversational Interactions
Perfect for chat-like interactions where you need natural language responses.Event Processing
Handle events, webhooks, or triggers from your application.Data Analysis
Analyze data, detect patterns, or generate insights.Batch Processing
Process large datasets or perform batch operations asynchronously.Monitoring & Alerts
Monitor systems, metrics, or conditions continuously.Report Generation
Generate reports, summaries, or formatted outputs.Instance Methods (BaseLlmAgent)
Core Methods
Configuration Methods
Dynamic Prompts (via VersionablePrompts trait)
Tool Management
Sub-Agent Management
Protected Methods (Override in Your Agent)
Sub-Agent Registration
Lifecycle Hooks
Sub-Agent Delegation Hooks
AgentExecutor Methods
TheAgentExecutor provides a fluent API for configuring agent execution:
Complete Example
CustomerSupportAgent.php
Complete Usage Examples
Let’s see how the unifiedrun() method handles all your agent needs. From simple queries to complex multimodal interactions, it’s all here.
Real-World Examples
Agent Best Practices:
- Keep agent instructions focused and clear
- Override lifecycle hooks for custom behavior
- Use appropriate temperature settings for your use case
- Implement error handling for robustness
- Test agents thoroughly with evaluations
- Monitor token usage and costs
Next Steps
Tool Class
Tool class reference
Agent Concepts
Learn more about agents