Skip to content

Mastra

Give a Mastra agent long-term memory: memory tools it can call, plus recall you can fold into its instructions.

Install

bash
npm install @suprflo/mastra @mastra/core zod

@mastra/core and zod are peer dependencies — you bring your own versions.

What you get

Built on the JavaScript SDK client:

  • suprfloMemoryTools(client, options)saveMemory and searchMemory built with Mastra's createTool, for an agent's tools.
  • recallMemories(client, query, options) — search Suprflo directly.
  • memoryInstructions(client, query, options) — recalled memories rendered as an instructions string, for agents whose instructions you build per request.

Memory tools on an agent

ts
import { Agent } from '@mastra/core/agent'
import { MemoryClient } from '@suprflo/sdk'
import { suprfloMemoryTools } from '@suprflo/mastra'

const client = new MemoryClient({ apiKey: process.env.SUPRFLO_API_KEY })

const agent = new Agent({
  name: 'assistant',
  instructions: 'You are a helpful assistant.',
  model: openai('gpt-4o'),
  tools: suprfloMemoryTools(client, { userId: 'alice' }),
})

Recall into instructions

ts
import { memoryInstructions } from '@suprflo/mastra'

const instructions = await memoryInstructions(client, userQuery, {
  userId: 'alice',
  topK: 5,
})

Notes

npx tsc --noEmit passes against the real @mastra/core package: the tool input infers as { content: string } and the output is checked against outputSchema, so the createTool contract is verified against actual types rather than assumed.

The memory layer for AI agents.