Hindsight
Learn how to use Hindsight persistent memory with the AI SDK.
Hindsight is a persistent memory service for AI agents. The @vectorize-io/hindsight-ai-sdk package provides five AI SDK-compatible tools that give your agents long-term memory across conversations.
Features include:
- Five memory tools:
retain,recall,reflect,getMentalModel, andgetDocument - Works with
generateText,streamText, andToolLoopAgent - Infrastructure options (budget, tags, async mode) configured at tool creation — semantic choices left to the model
- Multi-user memory isolation via
bankId - Full TypeScript support
Setup
Hindsight can be run locally with Docker or used as a cloud service.
Self-Hosted (Docker)
The API will be available at http://localhost:8888 and the UI at http://localhost:9999.
Cloud
Sign up and get your API URL from the Hindsight dashboard.
Installation
$ pnpm add @vectorize-io/hindsight-ai-sdk @vectorize-io/hindsight-client
$ npm install @vectorize-io/hindsight-ai-sdk @vectorize-io/hindsight-client
$ yarn add @vectorize-io/hindsight-ai-sdk @vectorize-io/hindsight-client
$ bun add @vectorize-io/hindsight-ai-sdk @vectorize-io/hindsight-client
Creating Tools
Initialize a HindsightClient and pass it to createHindsightTools along with a bankId that identifies the memory store (typically a user ID):
Basic Usage
generateText
ToolLoopAgent
Multi-User Memory
In multi-user applications, create tools inside your request handler so each request uses the correct bankId for the authenticated user:
The HindsightClient instance is shared (created once at module level), while createHindsightTools is called per-request with the current user's ID.
Configuration
Infrastructure options are configured at tool creation time, keeping the application in control of cost, tagging, and performance while leaving semantic choices (what to remember, what to search for) to the model.
retain options
| Parameter | Type | Default | Description |
|---|---|---|---|
async | boolean | false | Fire-and-forget ingestion mode |
tags | string[] | — | Tags applied to all retained memories |
metadata | Record<string, string> | — | Metadata applied to all retained memories |
description | string | built-in | Override the default tool description |
recall options
| Parameter | Type | Default | Description |
|---|---|---|---|
budget | 'low' | 'mid' | 'high' | 'mid' | Retrieval depth and latency tradeoff |
types | ('world' | 'experience' | 'observation')[] | all | Restrict results to specified fact types |
maxTokens | number | API default | Maximum total tokens returned |
includeEntities | boolean | false | Include entity observations in results |
includeChunks | boolean | false | Include raw source chunks in results |
description | string | built-in | Override the default tool description |
reflect options
| Parameter | Type | Default | Description |
|---|---|---|---|
budget | 'low' | 'mid' | 'high' | 'mid' | Synthesis depth and latency tradeoff |
maxTokens | number | API default | Maximum response tokens |
description | string | built-in | Override the default tool description |
Memory Tools
| Tool | Description |
|---|---|
retain | Stores information in the memory bank |
recall | Searches memories using a query |
reflect | Synthesizes insights from stored memories |
getMentalModel | Retrieves a structured knowledge model |
getDocument | Retrieves a stored document by identifier |
More Information
For full API documentation and configuration options, see the Hindsight documentation.