Home/Tools/@tpmjs/official-memory

searchMemoryTool

@tpmjs/official-memory

Search memories using natural language semantic search. Returns the most relevant memories ranked by similarity.

Official
agent
v0.1.3
MIT

Interactive Playground

Test @tpmjs/official-memory (searchMemoryTool) with AI-powered execution

0/2000 characters

Installation & Usage

Install this tool and use it with the AI SDK

1. Install the package

npm install @tpmjs/official-memory
pnpm add @tpmjs/official-memory
yarn add @tpmjs/official-memory
bun add @tpmjs/official-memory
deno add npm:@tpmjs/official-memory

2. Import the tool

import { searchMemoryTool } from '@tpmjs/official-memory';

3. Use with AI SDK

import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { searchMemoryTool } from '@tpmjs/official-memory';

const result = await generateText({
  model: openai('gpt-4o'),
  tools: { searchMemoryTool },
  prompt: 'Your prompt here...',
});

console.log(result.text);

Signature

(query: string, tags?: string[], limit?: number, namespace?: string, threshold?: number) => Promise<unknown>

Tags

agent
ai
embeddings
language
memories
memory
natural
official
ranked
relevant
search
semantic
semantic-search
similarity
tpmjs

Parameters

Available configuration options

Auto-extracted
query
Required
Type: string

Natural language search query. Use descriptive phrases for best results (e.g., "database decision for project X" not just "database").

namespace
Optional
Type: string

Filter results to a specific namespace

tags
Optional
Type: array

Filter results to memories with any of these tags

limit
Optional
Type: number

Maximum number of results (default: 10, max: 50)

threshold
Optional
Type: number

Minimum similarity threshold 0-1 (default: 0.4). Lower values return more results.

Schema extracted: 3/1/2026, 4:25:57 AM

README

@tpmjs/official-memory

Persistent, semantically-searchable memory tools for AI agents. Create and search memories across sessions using embedding-based semantic search.

Installation

npm install @tpmjs/official-memory

Setup

Set the TPMJS_API_KEY environment variable with a key that has memory:read and memory:write scopes.

Get a key at tpmjs.com/dashboard/settings/tpmjs-api-keys.

Optionally set TPMJS_BASE_URL (defaults to https://tpmjs.com).

Usage

import { createMemoryTool, searchMemoryTool } from '@tpmjs/official-memory';

// Store a memory
const memory = await createMemoryTool.execute({
  content: { decision: 'Use PostgreSQL', reason: 'Team expertise' },
  summary: 'Database decision: PostgreSQL chosen for team expertise',
  namespace: 'project-x',
  tags: ['architecture', 'database'],
});

// Search memories
const results = await searchMemoryTool.execute({
  query: 'What database did we choose?',
  namespace: 'project-x',
});

Tools

createMemoryTool

Store a persistent memory that can be retrieved later via semantic search.

Parameters

NameTypeRequiredDescription
contentobjectYesArbitrary JSON payload to store
summarystringNoHuman-readable summary (max 500 chars)
namespacestringNoGrouping namespace (e.g., 'project-x', 'personal')
tagsstring[]NoTags for categorization
expiresAtstringNoISO 8601 datetime for automatic expiration

Output

FieldTypeDescription
idstringUnique memory ID
contentobjectThe stored JSON payload
summarystringMemory summary
namespacestring/nullGrouping namespace
tagsstring[]Categorization tags
sourcestringCreation source ('createMemoryTool')
sourceAgentstring/nullAgent name
contentSizeBytesnumberSize of content in bytes
expiresAtstring/nullExpiration datetime
createdAtstringCreation timestamp
updatedAtstringLast update timestamp

searchMemoryTool

Search memories using natural language semantic search.

Parameters

NameTypeRequiredDescription
querystringYesNatural language search query
namespacestringNoFilter to a specific namespace
tagsstring[]NoFilter to memories with any of these tags
limitnumberNoMax results (default: 10, max: 50)
thresholdnumberNoMin similarity threshold 0-1 (default: 0.7)

Output

FieldTypeDescription
idstringMemory ID
contentobjectThe stored JSON payload
summarystringMemory summary
namespacestring/nullGrouping namespace
tagsstring[]Categorization tags
similaritynumberCosine similarity score 0-1
createdAtstringCreation timestamp

License

MIT

Statistics

Downloads/month

389

GitHub Stars

15

Quality Score

91%

Bundle Size

NPM Keywords

tpmjs
memory
ai
semantic-search
embeddings

Maintainers

thomasdavis(thomasalwyndavis@gmail.com)

Frameworks

vercel-ai
searchMemoryTool | TPMJS | TPMJS