Base Agent
The Base Agent is the foundational component that provides core functionality for all specialized agents, including language model integration, error handling, and web search capabilities.

Base Agent interface and configuration options
Configuration Parameters
Required Parameters
- Template: Message template
- Handle Parse Errors: Error handling
- Max Tokens: Token limit
- Model Name: Language model
- JSON Mode: JSON output mode
- OpenAI API Key: API authentication
- OpenAI API Base: API endpoint
- Temperature: Response randomness
- Seed: Random seed
- Max Retries: Retry attempts
- Agent Instructions: Behavior guidelines
- Web Search: Search capability
- Agent Description: Role description
- Language Model: Model configuration
Output Format
{ "response": { "content": string, "metadata": { "model": string, "tokens": { "prompt": number, "completion": number, "total": number }, "processingTime": string } } }
Example Usage
const baseAgent = new BaseAgent({ template: "{role}: {content}", handleParseErrors: true, maxTokens: 2048, modelName: "gpt-4", jsonMode: false, openaiApiKey: "YOUR_API_KEY", openaiApiBase: "https://api.openai.com/v1", temperature: 0.7, seed: 42, maxRetries: 3, agentInstructions: "You are a helpful assistant...", webSearch: { enabled: true, maxResults: 5 }, agentDescription: "A versatile AI assistant", languageModel: { type: "openai", version: "latest" } }); const result = await baseAgent.process({ input: "Tell me about artificial intelligence" });
Additional Resources
Best Practices
- Secure API key management
- Implement proper error handling
- Monitor token usage
- Optimize response settings
- Regular performance monitoring