The Agent SDK provides a framework for building AI agents that can interact with various services and APIs. It implements the ReAct (Reasoning, Acting, Observing) prompting technique to enable LLM-powered agents to solve complex tasks through iterative reasoning and action.
The BaseAgent class is the foundation of the agent architecture, providing a CLI interface and core functionality for all agent implementations. It handles common tasks like command registration, logging, and context management.
- CLI interface with standard commands:
skills
: Lists agent capabilities and available skillsabout
: Provides information about what the agent doesterms
: Shows domain-specific terminology the agent understandsask
: Executes the agent with a user message and streams responses
- Logging system using Pino
- Version tracking from package.json
- Context management for maintaining state between invocations
ask()
: Main method that processes user input and returns responsesskills()
: Returns available skills/capabilitiesterms()
: Returns domain-specific terminologyabout()
: Returns agent purpose description
The ReactBaseAgent extends BaseAgent to implement the ReAct (Reasoning, Acting, Observing) prompting technique. This approach enables an LLM-powered agent to reason through multi-step tasks by iteratively:
- Thinking about how to approach a problem
- Deciding on an action to take
- Observing the result
- Repeating until the task is complete
The SDK provides base classes for implementing agent capabilities:
BaseSkills
: Abstract class for defining agent skillsAPIBaseSkills
: Extension of BaseSkills specifically for API-based integrations
You can create custom integrations by extending the ReactBaseAgent class. Here's a simplified example:
import { ReactBaseAgent } from "@tegonhq/agent-sdk";
import { GithubSkills } from "./github-skills";
import { JARGON } from "./jargon";
export class GithubAgent extends ReactBaseAgent {
skills(): Array<any> {
const githubSkills = new GithubSkills({});
const skills = githubSkills.skills();
return Object.keys(skills).map((key) => ({ ...skills[key], name: key }));
}
// Provide domain-specific terminology
terms(): string {
return JARGON;
}
// Implementation of the runSkill method that executes actions
async runSkill(
skillName: string,
parameters: any,
integrationConfig: Record<string, string>
): Promise<string> {
const githuSkills = new GithubSkills(integrationConfig);
return githuSkills.runSkill(skillName, parameters);
}
}
The BaseSkills class provides an abstraction for implementing skill capabilities that agents can use. It separates skill definitions from the agent implementation.
- Constructor that takes integration configuration
- Abstract methods for defining and executing skills
skills()
: Returns a map of available skills with their definitionsrunSkill()
: Executes a specific skill with provided parameters
The APIBaseSkills class extends BaseSkills to provide a foundation for API-based integrations. It handles common API concerns like headers and base URLs.
- Constructor that initializes headers and base URL
- Abstract methods for API configuration
getBaseURL()
: Determines the base URL for API requestsgetHeaders()
: Generates headers for API requests using integration configuration