Base agent
Base Agent
The BaseAgent
class is the foundation for all PilottAI agents. It provides the core functionality for task execution, tool management, and memory integration.
Overview
The BaseAgent
is responsible for:
- Executing tasks using LLMs
- Managing specialized tools
- Maintaining task context
- Tracking execution status
- Storing and retrieving memory
Class Definition
Configuration
The BaseAgent
is configured using the AgentConfig
class:
Key Methods
Task Execution
The task execution process involves:
- Planning execution steps using LLM
- Executing each step with proper error handling
- Monitoring execution status and timeout
- Recording execution in memory
- Returning structured results
Task Suitability Evaluation
This method determines how well an agent can handle a specific task by:
- Checking required capabilities
- Matching task type with agent specializations
- Considering current agent load
- Analyzing task complexity
Lifecycle Management
These methods handle the agent’s lifecycle, including:
- Initializing components
- Setting up connections
- Updating status
- Cleaning up resources
Task Execution Pipeline
The BaseAgent
follows a structured approach to task execution:
- Task Formatting: Prepare task with context
- Execution Planning: Generate a plan using LLM
- Step Execution: Execute each step in the plan
- Tool Invocation: Use tools as required
- Result Summarization: Summarize and format results
System Prompts
The BaseAgent
uses system prompts to guide LLM behavior. The base system prompt follows this template:
Error Handling
The BaseAgent
implements robust error handling:
- Task timeouts
- LLM errors
- Tool execution failures
- Context validation
Memory Integration
Agents maintain their own memory instance for:
- Task history tracking
- Context preservation
- Knowledge storage
- Pattern recognition
Extending BaseAgent
To create a specialized agent, extend the BaseAgent
class:
Examples
Creating a Basic Agent
Executing a Task
API Reference
For a complete reference of all BaseAgent
methods and attributes, see the Agent API documentation.