---
title: "How to build a retrieval system for agents"
description: "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."
url: "https://swe.quest/articles/how-to-build-a-retrieval-system-for-agents-08b9b297721895b1"
canonical: "https://turso.tech/blog/how-to-build-a-retrieval-system-for-agents"
source: "Turso"
published: "2026-02-20"
difficulty: "medium"
kind: "How-to"
reading_minutes: 5
tags: ["ai-agents","vector-search","sqlite","ai-coding","rag"]
---

# How to build a retrieval system for agents

A post on [Turso](https://swe.quest/sources/turso.md), published 2026-02-20, 5 min read, How-to. Original: [https://turso.tech/blog/how-to-build-a-retrieval-system-for-agents](https://turso.tech/blog/how-to-build-a-retrieval-system-for-agents)

## Summary

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. Each memory carries a weight updated by exponential moving average from the agent's 0-3 usefulness ratings, plus time decay for unused memories, and memories flagged as wrong are deleted immediately. Integration with Claude Code uses an MCP server and lifecycle hooks, and a TypeScript SDK accepts a bring-your-own embedding function for custom agents. The argument is that retrieval beats dumping lessons into .md system prompts, which wastes the finite context window.

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)
- [Vector search](https://swe.quest/tags/vector-search.md) (Data & databases)
- [SQLite](https://swe.quest/tags/sqlite.md) (Data & databases)
- [AI for coding](https://swe.quest/tags/ai-coding.md) (AI & ML)
- [RAG & retrieval](https://swe.quest/tags/rag.md) (AI & ML)

## Prerequisites

- LLM coding agents ([easy posts on LLMs](https://swe.quest/tags/llms.md?difficulty=easy))
- vector embeddings ([easy posts on RAG & retrieval](https://swe.quest/tags/rag.md?difficulty=easy))
- SQLite basics ([easy posts on SQLite](https://swe.quest/tags/sqlite.md?difficulty=easy))

## Keywords

memelord, Turso, SQLite, all-MiniLM-L6-v2, MCP, Claude Code

## Related posts

- [Giving OpenClaw a memory that actually works](https://swe.quest/articles/giving-openclaw-a-memory-that-actually-works-f9bbbfa6dfaba92b.md): Turso · 2026-02-23 · Medium · 4 min read · AI agents, Vector search, SQLite, AI for coding
  Memelord, a per-project agent memory system built on Turso, plugs into OpenClaw through mcporter.
- [Give Your Coding Agents a Memory You Own](https://swe.quest/articles/give-your-coding-agents-a-memory-you-own-a4b8ff1b9b62d4a5.md): Hugging Face · 2026-09-03 · Medium · 9 min read · AI agents, AI for coding, RAG & retrieval, Search, Developer tools
  funes is an open-source, single-binary memory layer that indexes the session traces of coding agents (Claude Code, Codex, pi, Hermes) so any agent can recall past decisions and rationale with exact provenance.
- [Introducing Loom: agent memory that keeps up with your code](https://swe.quest/articles/introducing-loom-agent-memory-that-keeps-up-with-your-code-c33a0d0178bbd2de.md): ClickHouse · 2026-11-13 · Medium · 12 min read · AI agents, AI for coding, Vector search, Search, Open source
  Loom is an open-source agent memory system that stores memories alongside a code index (functions, classes, call graph) in a single ClickHouse database, so facts about code are linked to definitions and flagged when that code is renamed or rewritten.
- [Building AI Agents That Remember with Mastra and Turso Vector](https://swe.quest/articles/building-ai-agents-that-remember-with-mastra-and-turso-vector-cf9403520a15ae02.md): Turso · 2025-06-11 · Medium · 12 min read · AI agents, RAG & retrieval, Vector search, SQLite, TypeScript
  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.
- [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.

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)
