Skip to content

Memory ​

The memory service provides semantic memory stores for AI agents — enabling them to remember context across conversations using vector-based storage and retrieval. Operators manage stores under Data → Agent Memory.

Agent Memory ​

A memory store is the unit that binds an embedding model to a vector index — it's where individual memory items live, scoped to a project. The list view shows total stores, total memories across all stores, and how many stores are currently active.

Agent Memory list

Creating the first store requires two prerequisites: a vector provider configured in Knowledge Index and an embedding model deployed in Model Hub. The Create First Store flow walks you through both — it'll halt and point to the missing piece if either isn't ready.

Once a store exists, every memory item carries content, free-form tags, an importance score, and an optional scope. Agents read from the store via the search() and recall() APIs documented below — recall() is the chat-optimised variant that respects a max-tokens budget.

Using a memory store from an agent ​

An agent's Memory section picks one store from this module and one scope. The agent reads and writes facts in that store, in that scope:

  • session: this conversation only.
  • user: follows the caller across conversations.
  • workspace: this agent only. This is the default.
  • tenant: shared by every agent that uses the store.

Sharing across agents. To let several agents share memory, give them the same store with tenant scope.

Agents saved with several stores. For a short time, agents could mount up to five stores. Such an agent now uses only its first store, with that store's access and scope. The other stores are no longer read or written, and their facts stay in this module. The Memory section names those stores in a warning. These agents also keep the project-wide workspace namespace they wrote to. The next save from the Memory section keeps the first store as the agent's only store.

Concepts ​

ConceptDescription
Memory StoreConfiguration container linking an embedding model and vector index
Memory ItemA single memory entry with content, tags, scope, and importance
SearchSemantic similarity search across stored memories
RecallChat-optimized retrieval with token limit awareness

Service Functions ​

FunctionDescription
createMemoryStore()Create store with vector index + embedding model
listMemoryStores()List stores for project
getMemoryStore()Get store by key
updateMemoryStore()Update config/status
deleteMemoryStore()Delete store + vector index
addMemory()Add single item (embed → store)
addMemoryBatch()Batch add items
listMemoryItems()List items in store
getMemoryItem()Get single item
updateMemoryItem()Update content (re-embed if changed)
deleteMemoryItem()Delete single item
deleteMemoryItemsBulk()Bulk delete
searchMemories()Semantic search
recallForChat()Chat-optimized recall with token limit

Create Store Request ​

json
{
  "name": "Agent Working Memory",
  "vectorProviderKey": "pinecone-prod",
  "embeddingModelKey": "text-embedding-ada-002"
}

The store key is generated automatically, and creating a store provisions the backing vector index.

Store settings ​

A store also takes an optional config object when it is created or updated through the API:

SettingMeaning
deduplicationDefault true. A memory with the same content as an existing one is not added twice.
maxMemoriesWhen the store holds this many memories, adding another is refused with 409. Expired memories do not count.
ttlDaysA memory expires this many days after it is written or its content changes. Expired memories are not returned by search or recall and do not take a place in maxMemories. Adding the same content again after it expired gives it a fresh expiry.

ttlDays and maxMemories are API-only: the console has no field for them, so set them in the request body ("config": { "ttlDays": 90, "maxMemories": 5000 }).

Behavior notes ​

  • Everything is scoped to the project of the token or session. A store key from another project answers not found, and item reads, listings, bulk deletes and search touch only the memories of the addressed store in that project.
  • A batch add reports { added, duplicates, failed }. A failed item no longer passes silently: it is counted in failed, and when nothing was added and nothing was a duplicate, the call answers with the error instead. When the store is full, the rest of the batch is counted as failed.
  • Search and recall skip archived and expired memories.
  • Deleting memories in bulk also removes their vectors, so later search and recall stay aligned with what is left.
  • A request body that is not a JSON object answers 400.

Client API ​

Create Memory Store ​

POST /api/client/v1/memory/stores
Authorization: Bearer <token>

Add Memory ​

POST /api/client/v1/memory/stores/:storeKey/memories
Authorization: Bearer <token>
json
{
  "content": "User prefers dark mode and concise responses",
  "scope": "user",
  "tags": ["preferences", "ui"],
  "importance": 0.8,
  "metadata": { "userId": "user-123" }
}

Search Memories ​

POST /api/client/v1/memory/stores/:storeKey/search
Authorization: Bearer <token>
json
{
  "query": "What are the user's UI preferences?",
  "topK": 5,
  "scope": "user",
  "scopeId": "user-123",
  "tags": ["preferences"],
  "minScore": 0.7
}

Response:

json
{
  "memories": [
    {
      "id": "mem_123",
      "content": "User prefers dark mode and concise responses",
      "score": 0.94,
      "scope": "user",
      "scopeId": "user-123",
      "tags": ["preferences", "ui"],
      "metadata": { "userId": "user-123" },
      "importance": 0.8
    }
  ],
  "query": "What are the user's UI preferences?",
  "storeKey": "mem-agent-working-memory"
}

Recall for Chat ​

POST /api/client/v1/memory/stores/:storeKey/recall
Authorization: Bearer <token>
json
{
  "query": "What does this user like?",
  "scope": "user",
  "scopeId": "user-123",
  "topK": 5,
  "maxTokens": 500
}

The recall function is optimized for chat contexts. It returns a compact context string together with the matched memories, trimmed to fit the requested token budget.

Memory Properties ​

FieldDescription
contentThe memory text
scopeCategorization (e.g., user, session, global)
sourceOrigin identifier
tagsArray of string tags for filtering
importanceFloat 0-1, stored and returned with each memory (default 0.5). It does not change search or recall ranking; results are ordered by similarity score only
metadataArbitrary key-value pairs

Pipeline ​

Adding a memory:

Content → Embed (via inference service) → Vector Upsert → Store metadata

Searching memories:

Query → Embed → Vector Search → Drop archived and expired items → Return (ordered by score)

Dependencies ​

  • Inference Service — For generating embeddings
  • Vector Service — For storing and querying vectors

Studio · Pulse · Console · Agent SDK and more — the Cognipeer documentation hub