ElizaOS is a modular AI framework designed to create, deploy, and manage autonomous AI agents. The framework is built around the concepts of Agents, Providers, and Actions, each serving a specific role in augmenting agent capabilities. This document provides an in-depth exploration of these components and how they work together within the ElizaOS ecosystem.
- Overview of Core Components
- Understanding Agents
- Understanding Providers
- Example: Time Context Provider
- Understanding Actions
- Example: Automated Twitter Reply Action
- Building a Plugin with ElizaOS
- Example: Blockchain-based Twitter Reply Listener
- General Examples
- Conclusion
ElizaOS's architecture is centered around three primary components:
- Agents: Core entities that handle autonomous interactions, managing state, memory, and behavior across various platforms.
- Providers: Modules that inject dynamic context and real-time information into agent interactions, serving as bridges between the agent and external systems.
- Actions: Define the tasks and responses that agents can perform, allowing interaction with external systems and modification of agent behavior.
Each component enhances the agent’s ability to process data, make decisions, and execute tasks efficiently.
ElizaOS provides a flexible plugin system that enables developers to extend its capabilities. A plugin typically consists of a Service that listens for external triggers and an Action that defines how the agent responds. Below, we demonstrate how to build a blockchain-integrated Twitter reply listener using ElizaOS.
This example showcases how an ElizaOS agent can monitor blockchain events and automatically respond to tweets based on specific triggers.
This service continuously monitors blockchain events and triggers an action when relevant data is detected.
import { IAgentRuntime, Service, ServiceType, elizaLogger } from "@elizaos/core";
import { fetchBlocksWithEvents, BlockFetcherConfig, TweetReplyEvent } from './block-fetcher';
let lastProcessedHeight = 7620233; // Starting block height
const POLLING_INTERVAL = 5000; // 5 seconds
export const tweetReplyListener: Service = {
serviceType: ServiceType.BROWSER,
initialize: async (runtime: IAgentRuntime) => {
while (true) {
try {
const events = await fetchBlocksWithEvents(lastProcessedHeight);
for (const event of events) {
if (event.status === "PENDING") {
await runtime.processActions(event, [event]);
}
}
lastProcessedHeight += 100;
await new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL));
} catch (error) {
elizaLogger.error('Error in event polling loop:', { error: error.message });
}
}
}
};
Once the event listener detects a new blockchain event, it triggers this action to reply to a tweet automatically.
import { Action, IAgentRuntime, Memory, elizaLogger } from "@elizaos/core";
import { Scraper } from "agent-twitter-client";
export const replyAction: Action = {
name: "TWEET_REPLY",
handler: async (runtime: IAgentRuntime, message: Memory) => {
try {
const { tweet_link, user } = message.content;
const scraper = new Scraper();
await scraper.login(runtime.getSetting("TWITTER_USERNAME"), runtime.getSetting("TWITTER_PASSWORD"));
await scraper.sendTweet(`Thanks @${user} for your request!`, tweet_link);
return true;
} catch (error) {
elizaLogger.error("Error in reply action:", error);
return false;
}
}
};
For a deeper understanding, consult the documentation.
In a fully integrated ElizaOS agent, these components interact as follows:
- The Agent manages autonomous interactions and maintains state and memory.
- Providers supply dynamic contextual information to the agent, enriching interactions with real-time data.
- Actions define the tasks and responses that the agent performs based on provided inputs.
- Plugins extend the agent's functionality, allowing it to interact with new systems such as blockchains and social media platforms.
With these building blocks, you can create highly interactive AI agents that automate workflows efficiently.