Skip to main content

Part 2: Deep Dive into Actions, Providers, and Evaluators

In this second session of the AI Agent Dev School series, we take a deep dive into the key abstractions in the Eliza framework that enable developers to create powerful AI agents:

  • Actions: The tasks and responses that agents can perform.
  • Providers: Modules that provide information and state to the agent's context.
  • Evaluators: Modules that analyze situations and agent actions, often triggering further actions or modifications.

We explore each of these in detail, walking through code examples and common use cases. We also cover how to package up actions, providers and evaluators into reusable plugins.

Key Sections

Working with Actions

Actions represent the core capabilities of an AI agent - the things it can actually do. In Eliza, an action is defined by:

  • Name: The unique name used to reference the action
  • Description: Used to inform the agent when this action should be invoked
  • Handler: The code that actually executes the action logic
  • Validator: Determines if the action is valid to be called given the current context

Some key points about actions in Eliza:

  • The agent decides which action to call based on the name and description. It does not have insight into the actual action code.
  • The handler receives the agent runtime, the triggering message, the current state, and a callback function to send messages back to the user.
  • The validate function allows for complex logic to determine action availability based on context and state.

Providers: Injecting State and Context

Providers allow developers to dynamically inject relevant information into the agent's context. This could be real-time data, user information, results of previous conversations, or any other state the agent may need.

Key aspects of providers:

  • Defined by a single get function that returns relevant state
  • Called before each agent execution to hydrate the context
  • Can conditionally provide state based on the current context

Common provider examples include current time, user preferences, conversation history, and external API data.

Evaluators: Reflection and Analysis

Evaluators run after each agent action, allowing the agent to reflect on what happened and potentially trigger additional actions. They are a key component in creating agents that can learn and adapt.

Some common use cases for evaluators:

  • Extracting and storing facts from a conversation for future reference
  • Analyzing user sentiment to measure trust and relationship
  • Identifying key intents and entities to inform future actions
  • Implementing feedback loops for agent improvement

Evaluators work in close conjunction with providers - often an evaluator will extract some insight that a provider will then inject into future context.

Packaging Plugins

The plugin system in Eliza allows developers to package up related actions, providers and evaluators into reusable modules. A plugin is defined by:

  • package.json: Metadata about the plugin
  • tsconfig.json: TypeScript configuration
  • index.ts: Registers the plugin's actions, providers and evaluators
  • src directory: Contains the actual action, provider and evaluator code

Plugins can be published to npm and then easily imported into any Eliza agent. This enables a powerful ecosystem of reusable agent capabilities.

Examples

The session walks through several code examples to illustrate these concepts:

  1. Defining a simple "Hello World" action
  2. Creating a "Current News" action that retrieves news headlines
  3. Implementing a provider that injects a random emotion into the context
  4. Registering actions and providers in a plugin

Key Takeaways

  • Actions, providers and evaluators are the core building blocks of agent behavior in Eliza
  • Actions define what agents can do, providers manage context and state, and evaluators allow for reflection and adaptation
  • The plugin system enables reusable packaging of agent capabilities
  • Effective prompt engineering around the composition of the agent context is a key area for optimization

With a solid understanding of these abstractions, developers have immense power and flexibility to create agent behaviors in Eliza. The next session will dive into an end-to-end example.