Use Case

Give your AI agents a brain that remembers

Your agents lose context between runs. Lux combines vector search for semantic recall with key-value storage for structured state, so agents remember past conversations, decisions, and user preferences across every session.

The problem

AI agents are stateless by default. Every conversation starts from scratch. The user tells your agent they prefer dark mode on Monday, and by Wednesday the agent asks again. It has no idea who it is talking to.

So you start stitching things together. Redis for session state and user preferences. Pinecone or Weaviate for semantic memory retrieval. An OpenAI or Cohere embedding pipeline to turn text into vectors. Maybe a Postgres table somewhere to log conversation history. Three services, three SDKs, three billing dashboards, three failure modes. Your "simple agent" now has more infrastructure than the product it powers.

And the worst part? It still forgets. Because keeping all of these systems in sync is its own engineering project. A memory gets embedded but the preference update fails. The vector store is up but Redis timed out. You are not building an agent anymore. You are building distributed systems glue.

Without Lux vs With Lux

Before

Redis

Session state & preferences

Pinecone / Weaviate

Memory retrieval

OpenAI Embeddings API

Embedding pipeline

Custom glue code

Sync & error handling

After

Just Lux

Vectors + KV + Embedding pipeline

One connection string. One SDK.

LUX_DIRECT_URL or lux://localhost:6379

Store a memory, recall it later

The basic pattern: embed a conversation turn, store it as a vector with metadata, and retrieve relevant memories on the next interaction.

import { Lux } from "@luxdb/sdk"

const db = new Lux(process.env.LUX_DIRECT_URL ?? "lux://localhost:6379")

const embedding = await embed("User prefers dark mode and concise answers")

await db.vset("memory:user123:1", embedding, {
  metadata: {
    role: "user",
    text: "User prefers dark mode and concise answers",
    session: "sess_abc",
    timestamp: Date.now()
  }
})

const queryVec = await embed("What display settings does this user like?")
const memories = await db.vsearch(queryVec, { k: 5, meta: true })

memories.forEach(m =>
  console.log(m.metadata.text, m.similarity)
)

How it works

Lux stores memories as high-dimensional vectors alongside arbitrary metadata. When your agent needs context, a single VSEARCH command finds the most semantically similar past interactions in under 2ms. No separate retrieval service. No network hop to a different database. The vectors live right next to your key-value data, in the same process, on the same connection.

For structured state, preferences like language, theme, timezone, or any JSON blob, Lux's key-value commands (SET, GET, HSET, HGET) work exactly like Redis. Over 200 commands are supported. If your agent already talks to Redis, switching to Lux is a connection string change. You keep your existing patterns and gain vectors for free.

The reason this matters for agents specifically is atomicity. When a conversation ends, your agent needs to store a new memory vector and update the user's preference state. With separate services, those are two independent writes that can partially fail. With Lux, both operations go through the same connection, backed by the same in-memory engine. If the connection is up, both writes land.

The Lux Cloud dashboard also includes a built-in embedding pipeline. You can upload knowledge base documents, FAQs, or product catalogs, and the pipeline will chunk the text, call your embedding provider (OpenRouter or OpenAI), and store everything as vectors with the original text as metadata. Your agent can start recalling from a knowledge base without you writing a single line of embedding code.

Full agent loop

A complete pattern: load preferences from KV, recall relevant memories from vectors, run the conversation, then update both stores afterward.

import { Lux } from "@luxdb/sdk"

const db = new Lux(process.env.LUX_DIRECT_URL ?? "lux://localhost:6379")

async function agentTurn(userId: string, userMessage: string) {
  const prefs = JSON.parse(
    await db.get(`agent:prefs:${{userId}{'}}`) || "{}"
  )

  const queryVec = await embed(userMessage)
  const memories = await db.vsearch(queryVec, { k: 10, meta: true })

  const context = memories
    .filter(m => m.similarity > 0.7)
    .map(m => m.metadata.text)
    .join("\n")

  const response = await llm.chat({
    system: `User preferences: ${{JSON.stringify(prefs)}{'}}\nRelevant memories:\n${{context}{'}}`,
    messages: [{ role: "user", content: userMessage }]
  })

  const memoryVec = await embed(`${{userMessage}{'}}\n${{response.text}{'}}`)
  await db.vset(`memory:${{userId}{'}}:${{Date.now()}{'}}`, memoryVec, {
    metadata: {
      text: `User: ${{userMessage}{'}}\nAgent: ${{response.text}{'}}`,
      session: prefs.currentSession,
      timestamp: Date.now()
    }
  })

  if (response.extractedPrefs) {
    await db.set(
      `agent:prefs:${{userId}{'}}`,
      JSON.stringify({ ...prefs, ...response.extractedPrefs })
    )
  }

  return response.text
}

Feature deep-dive

Semantic Recall

Vector search finds relevant past memories by meaning, not exact keywords. Ask "what does this user like?" and get back the conversation where they mentioned their preferences three weeks ago. Cosine similarity ranking ensures the most relevant memories surface first.

Structured State

Key-value storage for user preferences, session data, and agent configuration. Use SET/GET for simple values, HSET/HGET for structured objects. Over 200 Redis-compatible commands give you full control over your agent's working memory, all on the same connection as your vectors.

Dashboard Embedding Pipeline

Pre-load knowledge bases without writing embedding code. Upload documents through the Lux Cloud dashboard, and the built-in pipeline chunks, embeds (via OpenRouter or OpenAI), and stores everything as searchable vectors. Your agent gets a knowledge base before you deploy a single line of application code.

Performance

2ms

Vector search latency

@ 1K stored memories

200+

Redis commands supported

Full KV, lists, sets, hashes

0

Extra services needed

Vectors + KV in one database

Give your agents memory that persists. Start free on Lux Cloud.

Star on GitHub