Skip to main content
Sonamu allows you to create custom AI agents by extending BaseAgentClass. By defining tools using the @tools decorator, the LLM can select and execute appropriate tools based on the context.

BaseAgentClass

This is the base class for AI agents.

Basic Structure

@tools Decorator

A decorator for defining tools.

Basic Usage

Options

Tool Description (required)
Important: The LLM reads this description to decide whether to use the tool.

Practical Examples

1. Hotel Booking Agent

2. Data Analysis Agent

3. Email Automation Agent

Using Agents

use() Method

This method executes the agent.

Usage in API

Store (State Management)

Manages the agent’s state.

Definition

Usage

Precautions

Important considerations when writing agents:
  1. Tool Description Clarity: Write detailed descriptions that the LLM can understand
  2. Detailed Input Schema: Use describe()
  3. Require Approval for Dangerous Operations: needsApproval
  4. Error Handling: Clear error messages
  5. Check for Undefined When Accessing Store
  6. Avoid Tool Name Conflicts: Use clear names

Next Steps

Agent Configuration

Configure agent basics

Using the AI SDK

Leverage the Vercel AI SDK