Skip to main content

Redis

Key-value storage, caching, and counters via Redis. Natural pairing with the @radaros/queue package (BullMQ/Redis).
Requires the ioredis peer dependency.

Quick Start

import { Agent, openai, RedisToolkit } from "@radaros/core";

const redis = new RedisToolkit({
  url: "redis://localhost:6379",
  keyPrefix: "myapp:",
});

const agent = new Agent({
  name: "cache-agent",
  model: openai("gpt-4o"),
  instructions: "Manage application cache and counters in Redis.",
  tools: [...redis.getTools()],
});

const result = await agent.run("Set key 'user:123:name' to 'Alice' with a 1 hour TTL.");

Config

url
string
default:"redis://localhost:6379"
Redis connection URL. Falls back to REDIS_URL env var.
keyPrefix
string
Namespace prefix prepended to all keys (e.g. myapp: makes key foo into myapp:foo).
maxKeys
number
default:"100"
Max keys to return in list operations.

Tools

ToolDescription
redis_getGet the value of a key.
redis_setSet a key-value pair with optional TTL (seconds).
redis_deleteDelete one or more keys.
redis_list_keysList keys matching a glob pattern (uses SCAN).
redis_incrementIncrement a numeric key by a given amount.

Peer Dependency

npm install ioredis

Environment Variables

VariableDescription
REDIS_URLRedis connection URL (e.g. redis://localhost:6379)