Redis

Use Redis as the storage adapter for memory, runs, and streams.

Install

npm install @better-agent/redis redis

Setup

Pass a connected Redis client to redisStorage.

import { betterAgent } from "@better-agent/core";
import { redisStorage } from "@better-agent/redis";
import { createClient } from "redis";

const client = await createClient({
  url: process.env.REDIS_URL,
}).connect();

export const app = betterAgent({
  storage: redisStorage({
    client,
  }),
  agents: [supportAgent],
});

Options

OptionDescription
clientConnected Redis client.
baseBase key namespace.
prefixesPer-model key prefixes.
transformsPer-field encode and decode hooks for stored data.

Notes

Redis works well for run resume and stream replay when Redis durability is enabled.

The adapter can use redis or @upstash/redis.

For Upstash, install @upstash/redis instead of redis.

See Storage for what Better Agent stores.

Powered by Farming Labs ORM.