Skip to main content

Create Agent

Create an autonomous AI agent with custom tools and capabilities.

Constructor

Parameters

AgentConfig
required
Configuration object for the agent
string
required
Name of the agent
string
required
Description of the agent’s purpose and capabilities
string
System prompt that defines the agent’s behavior and personality
AgentTool[]
default:"[]"
Array of tools available to the agent
Memory
Memory instance for persistent storage
Chat
Chat instance for AI interactions
number
default:"10"
Maximum number of iterations for task execution
number
default:"300000"
Timeout for agent execution in milliseconds

Response

Returns an Agent instance that can execute tasks autonomously.

Examples

Tool Definition

AgentTool Interface

string
required
Unique name for the tool
string
required
Description of what the tool does (used by AI to decide when to use it)
JSONSchema
JSON Schema defining the tool’s parameters
function
required
Function that executes the tool’s functionality

Built-in Tool Examples

File System Tools

API Integration Tools

Database Tools

Agent Specializations

Code Assistant Agent

Research Agent

Error Handling

Best Practices

Tool Design

  1. Clear descriptions: Make tool descriptions specific and actionable
  2. Proper parameters: Use JSON Schema to define clear parameter requirements
  3. Error handling: Implement proper error handling in tool execution
  4. Async operations: Use async/await for tools that perform I/O operations

Agent Configuration

  1. Focused purpose: Give agents specific, well-defined roles
  2. Appropriate limits: Set reasonable maxIterations and timeout values
  3. Memory integration: Use memory for persistent state and learning
  4. Tool selection: Only include tools relevant to the agent’s purpose