All guides

Your First Memory Store

Give Your Agents Persistent State

Novium Memory Cloud provides persistent key-value storage, sessions, and graph-based memory for your agents.


1. Basic Key-Value Storage

export default async function agent(input: { name: string }) {
  const visits = (await memory.get("visits")) ?? 0;
  await memory.save({ key: "visits", value: visits + 1 });

  return {
    message: `Hello, ${input.name}!`,
    visits: visits + 1,
  };
}

Concepts:

| Method | Description | | ------ | ----------- | | memory.get(key) | Retrieve a stored value. Returns null if not found. | | memory.save({ key, value }) | Persist a value. Overwrites if key exists. | | memory.delete(key) | Remove a stored value. |


2. Session Memory

Sessions group memory by user or conversation.

export default async function agent(input: { userId: string; message: string }) {
  const session = await memory.session(input.userId);
  const history = (await session.get("history")) ?? [];

  history.push({ role: "user", content: input.message });
  await session.save({ key: "history", value: history });

  return {
    reply: `You've sent ${history.length} messages so far.`,
  };
}

Session methods:

| Method | Description | | ------ | ----------- | | memory.session(id) | Get or create a session for a user/conversation | | session.get(key) | Get a value scoped to the session | | session.save({ key, value }) | Save a value scoped to the session |


3. Semantic Memory

Store and search embeddings for similarity-based retrieval.

export default async function agent(input: { query: string }) {
  const docs = await memory.search(input.query, {
    limit: 3,
    threshold: 0.7,
  });

  return {
    results: docs.map((d) => ({ content: d.content, score: d.score })),
  };
}

Store a document:

await memory.embed({
  id: "doc-1",
  content: "Novium Cloud is an Agent Control Plane.",
  metadata: { source: "docs", page: 1 },
});

4. Memory Graph

Connect memories with relationships.

await memory.graph.connect({
  from: "sales-agent",
  to: "crm-api",
  relationship: "DEPENDS_ON",
});

const neighbors = await memory.graph.neighbors("sales-agent");
// [{ id: "crm-api", relationship: "DEPENDS_ON" }]

5. Memory Isolation

Each agent gets its own memory namespace. Agent A cannot read Agent B's data.

// agents/support-agent/agent.ts
await memory.save({ key: "tickets", value: 512 });

// agents/sales-agent/agent.ts
const tickets = await memory.get("tickets"); // null — different namespace

6. Expiration

Set TTL on stored values:

await memory.save({
  key: "cache",
  value: "temporary data",
  ttl: 3600, // seconds (1 hour)
});

7. View Memory in Dashboard

Go to Dashboard → Memory to browse keys, sessions, and graph connections for each agent.


Next Steps