Agents
Learn about CAMEL’s agent types, with a focus on ChatAgent and advanced agent architectures for AI-powered automation.
Concept
Agents in CAMEL are autonomous entities capable of performing specific tasks through interaction with language models and other components. Each agent is designed with a particular role and capability, allowing them to work independently or collaboratively to achieve complex goals.
Think of an agent as an AI-powered teammate one that brings a defined role, memory, and tool-using abilities to every workflow. CAMEL’s agents are composable, robust, and can be extended with custom logic.
Base Agent Architecture
All CAMEL agents inherit from the BaseAgent
abstract class, which defines two essential methods:
Method | Purpose | Description |
---|---|---|
reset() | State Management | Resets the agent to its initial state |
step() | Task Execution | Performs a single step of the agent’s operation |
Types
ChatAgent
The ChatAgent
is the primary implementation that handles conversations with language models. It supports:
- System message configuration for role definition
- Memory management for conversation history
- Tool/function calling capabilities
- Response formatting and structured outputs
- Multiple model backend support with scheduling strategies
- Async operation support
Other Agent Types (When to Use)
Other Agent Types (When to Use)
CriticAgent
Specialized agent for evaluating and critiquing responses or solutions. Used in scenarios requiring quality assessment or validation.
DeductiveReasonerAgent
Focused on logical reasoning and deduction. Breaks down complex problems into smaller, manageable steps.
EmbodiedAgent
Designed for embodied AI scenarios, capable of understanding and responding to physical world contexts.
KnowledgeGraphAgent
Specialized in building and utilizing knowledge graphs for enhanced reasoning and information management.
MultiHopGeneratorAgent
Handles multi-hop reasoning tasks, generating intermediate steps to reach conclusions.
SearchAgent
Focused on information retrieval and search tasks across various data sources.
TaskAgent
Handles task decomposition and management, breaking down complex tasks into manageable subtasks.
Usage
Basic ChatAgent Usage
Simplified Agent Creation
The ChatAgent
supports multiple ways to specify the model:
Using Tools with Chat Agent
Structured Output
Best Practices
Memory Management
Memory Management
- Use appropriate window sizes to manage conversation history
- Consider token limits when dealing with long conversations
- Utilize the memory system for maintaining context
Tool Integration
Tool Integration
- Keep tool functions focused and well-documented
- Handle tool errors gracefully
- Use external tools for operations that should be handled by the user
Response Handling
Response Handling
- Implement appropriate response terminators for conversation control
- Use structured outputs when specific response formats are needed
- Handle async operations properly when dealing with long-running tasks
Model Specification
Model Specification
- Use the simplified model specification methods for cleaner code
- For default platform models, just specify the model name as a string
- For specific platforms, use the tuple format (platform, model)
- Use enums for better type safety and IDE support
Advanced Features
You can dynamically select which model an agent uses for each step by adding your own scheduling strategy.
You can dynamically select which model an agent uses for each step by adding your own scheduling strategy.
Agents can respond in any language. Set the output language on-the-fly during conversations.