---
title: "Building AI Agents That Remember with Mastra and Turso Vector"
description: "Mastra, a TypeScript AI agent framework, can use Turso's libSQL (a SQLite fork with native vector search) as a single database for agent memory, telemetry and vector embeddings."
url: "https://swe.quest/articles/building-ai-agents-that-remember-with-mastra-and-turso-vector-cf9403520a15ae02"
canonical: "https://turso.tech/blog/building-ai-agents-that-remember-with-mastra-and-turso-vector"
source: "Turso"
published: "2025-06-11"
difficulty: "medium"
kind: "How-to"
reading_minutes: 12
tags: ["ai-agents","rag","vector-search","sqlite","typescript"]
---

# Building AI Agents That Remember with Mastra and Turso Vector

A post on [Turso](https://swe.quest/sources/turso.md), published 2025-06-11, 12 min read, How-to. Original: [https://turso.tech/blog/building-ai-agents-that-remember-with-mastra-and-turso-vector](https://turso.tech/blog/building-ai-agents-that-remember-with-mastra-and-turso-vector)

## Summary

Mastra, a TypeScript AI agent framework, can use Turso's libSQL (a SQLite fork with native vector search) as a single database for agent memory, telemetry and vector embeddings. The walkthrough configures LibSQLStore and LibSQLVector, enables Mastra's semanticRecall with OpenAI embeddings, registers multiple named vector stores, and builds a RAG ingestion workflow (recursive chunking at 512 tokens with 50 overlap, embedMany, upsert) plus a vector query tool for a weather agent. Turso's vector support covers six types from FLOAT32 down to 1-bit, giving up to 32x compression, and vectors of up to 65,536 dimensions, with no extensions required.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [AI agents](https://swe.quest/tags/ai-agents.md) (AI & ML)
- [RAG & retrieval](https://swe.quest/tags/rag.md) (AI & ML)
- [Vector search](https://swe.quest/tags/vector-search.md) (Data & databases)
- [SQLite](https://swe.quest/tags/sqlite.md) (Data & databases)
- [TypeScript](https://swe.quest/tags/typescript.md) (Languages)

## Prerequisites

- TypeScript ([easy posts on TypeScript](https://swe.quest/tags/typescript.md?difficulty=easy))
- LLM APIs ([easy posts on LLMs](https://swe.quest/tags/llms.md?difficulty=easy))
- embeddings basics ([easy posts on RAG & retrieval](https://swe.quest/tags/rag.md?difficulty=easy))

## Keywords

Mastra, Turso, libSQL, LibSQLVector, OpenAI, text-embedding-3-small

## Related posts

- [Building a Retrieval Pipeline with Turso and Voyage AI](https://swe.quest/articles/building-a-retrieval-pipeline-with-turso-and-voyage-ai-d56063c4fe3f313b.md): Turso · 2026-07-15 · Medium · 10 min read · RAG & retrieval, Vector search, SQLite, AI agents, LLMs
  Turso's SQLite-compatible engine with native vector columns, paired with Voyage AI embedding and reranking models, replaces a multi-service RAG stack with a single embeddable database for agent retrieval and memory.
- [Local RAG with Ollama, Mistral, and Turso](https://swe.quest/articles/local-rag-with-ollama-mistral-and-turso-c9414cc4e6a29ef6.md): Turso · 2025-01-08 · Medium · 8 min read · RAG & retrieval, Vector search, SQLite, Local-first & sync, TypeScript
  A local retrieval-augmented generation pipeline can be built in TypeScript using Ollama's Mistral model for both embeddings and generation, with libSQL storing documents and 4096-dimension F32\_BLOB vectors in a single SQLite file indexed via libsql\_vector\_idx.
- [How to Generate & Store OpenAI Vector Embeddings with Turso](https://swe.quest/articles/how-to-generate-store-openai-vector-embeddings-with-turso-1144f075a7bcad32.md): Turso · 2024-07-01 · Medium · 5 min read · Vector search, SQLite, LLMs, JavaScript
  Turso's beta vector support stores OpenAI text-embedding-ada-002 embeddings in a libSQL F32\_BLOB(1536) column, whose size matches the model's 1536 dimensions.
- [How to build a retrieval system for agents](https://swe.quest/articles/how-to-build-a-retrieval-system-for-agents-08b9b297721895b1.md): Turso · 2026-02-20 · Medium · 5 min read · AI agents, Vector search, SQLite, AI for coding, RAG & retrieval
  Memelord is a fully local memory system for coding agents that keeps a per-project SQLite database (via Turso) of corrections, insights and user-requested memories, embedded with all-MiniLM-L6-v2 and retrieved by cosine vector search at task start.
- [Build a custom RAG AI agent in TypeScript and Jupyter](https://swe.quest/articles/build-a-custom-rag-ai-agent-in-typescript-and-jupyter-fc00c37173b8b56a.md): Deno · 2025-03-18 · Medium · 11 min read · RAG & retrieval, AI agents, TypeScript, LLMs
  A local agentic RAG pipeline built in TypeScript inside a Deno Jupyter notebook, using LangChain and LangGraph with Ollama models.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
