What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Build persistent memory for a TypeScript AI agent by separating raw interaction history from distilled facts and reusable procedures. Store ordinary content and metadata in SQLite, keep embeddings in a sqlite-vec vec0 virtual table, and retrieve with a mix of vector similarity and full-text search when your queries need both. The design is an architecture, not a measured performance result: validate the driver, extension, model dimensions, and retrieval quality in your own deployment.
What the three memory tiers do
Do not treat every past message as an interchangeable memory. Recent events, durable facts, and learned procedures answer different questions and need different retention and retrieval rules.
| Tier | What it stores | Typical use | Important design choice |
|---|---|---|---|
| Episodic | Interaction turns or events, with session identity and time/order | “What happened in the last session?” | Which episodes remain available, and when they become eligible for compaction |
| Semantic | Distilled facts or observations, with metadata, source episode references, and embeddings | “What does this agent know about the user or project?” | How facts are corrected, expired, and traced to their source |
| Procedural | Structured condition/action rules, with confidence and provenance | “When this situation occurs, what action has worked before?” | How rules are reviewed and updated rather than treated as unquestionable truth |
A distilled fact or procedure should retain a stable reference to the episode or episodes that support it. That provenance lets the agent explain where a memory came from and gives your application a path to revisit or correct derived records.
How SQLite, sqlite-vec, and TypeScript fit together
Keep readable memory content and relational metadata in ordinary SQLite tables. Store embeddings in the vector extension’s index, joined to the content records through stable identifiers. This keeps the searchable text and its metadata accessible as normal application data while enabling vector-neighbor retrieval.
#1 Best Overall
The SitePoint Team’s September 25, 2026 tutorial describes this arrangement with a vec0 virtual table. Its implementation outline uses TypeScript, better-sqlite3, runtime extension loading, and SQLite write-ahead logging (WAL). Those names describe the proposed stack; they do not establish that every current Node.js, driver, operating-system, and extension combination is compatible. Verify the combination you intend to ship before relying on it.
Keep identifiers, dimensions, and writes consistent
- Assign each semantic memory a stable ID and use that ID to associate its content row with its vector row.
- Configure the vector column for the actual output dimension of the selected embedding model. SitePoint’s tutorial gives 384 dimensions for
all-MiniLM-L6-v2and 1536 as the default output dimension fortext-embedding-3-small; those are figures reported by that tutorial, not independently checked here. Confirm the current model documentation and the configuration you use before setting a dimension. - Version the embedding model and relevant configuration in your application metadata. If you change models or dimensions, plan how to regenerate vectors and replace the associated index entries.
- Make writes and deletions atomic across every affected record or index. A failure must not leave content without a vector, a vector pointing to a missing memory, or an outdated lexical entry.
Use transactions for related database changes. The separate sqlite-memory project documents SAVEPOINT-wrapped synchronization as one implementation pattern; that is an example, not proof that a particular driver and extension combination will handle every failure mode as intended. Exercise rollback and recovery behavior in your selected stack.
How to record episodes and compact them
Record interaction events with enough information to retrieve them by session and time or order. The episodic tier is the evidence trail and the short-term context source; it is not automatically a permanent transcript or an unlimited prompt buffer.
Rank #2
Choose an explicit retention and compaction policy
- Decide how many recent episodes, or what time window, are eligible for recall.
- Define when an episode can be compacted into a semantic fact or procedural rule. The exact trigger is a product decision, not a value established by the tutorial.
- Preserve source references when creating derived records. If your retention policy allows it, keep the original episodes or an auditable archive so a fact can be checked against its origin.
- Specify what happens when a user corrects or deletes an episode: update or remove derived memories and rules that depend on it, or mark them for review.
Compaction should produce a smaller, useful representation of experience, not silently convert uncertain language into certainty. Keep enough provenance and confidence information to distinguish an observed fact from an inference or a tentative rule.
How to retrieve useful memories
Use the query type to choose the retrieval path. Vector similarity can find related meaning when the wording differs; full-text search is useful when the literal wording matters. The SQLite FTS5 documentation describes FTS5 as a full-text search virtual-table module. A hybrid search can combine these capabilities, but its ranking and weighting must be tested against the queries your agent actually receives.
Match retrieval to the request
- Recent event or session context: fetch relevant, uncompacted episodes by session and time/order.
- Paraphrased question or related concept: search semantic memories by vector similarity.
- Exact name, identifier, or phrase: use FTS5 lexical matching where literal terms need to be dependable.
- Known situation with a learned response: find procedural records through their structured conditions or metadata, then present matching rules as suggestions.
For a hybrid path, retrieve candidates from the relevant sources, combine and deduplicate them, then rank and fit them to a context budget. Do not assume that adding two retrieval methods automatically improves results: test how they behave together, including which source wins when rankings disagree.
Rank #3
Keep FTS5 synchronized
When an FTS5 table uses external content, SQLite’s documentation puts synchronization responsibility on the application. Triggers are one documented way to keep the full-text index aligned with the content table. Handle updates and deletions as well as inserts; an index that contains stale text can return plausible but incorrect results. FTS5’s internal segment merging is index behavior, not evidence of a particular application response time.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteHow to apply procedures without over-trusting them
Store a procedure as an explicit condition/action record rather than burying it in a paragraph. Attach confidence and episode provenance, then let the agent consider the rule when the current situation matches. A retrieved rule is a candidate for the agent’s reasoning, not an instruction that should override current user input or application policy.
Set application-level rules for how a procedure changes when its source is corrected, when new episodes contradict it, or when it becomes stale. The tutorial outlines condition/action rules with confidence and provenance; specific expiry thresholds and contradiction policies are design recommendations, not experimentally validated outcomes.
Rank #4
How to connect memory to the agent loop
- Recall: collect relevant recent episodes, semantic memories, and procedural candidates for the current request.
- Apply: filter or qualify retrieved material using provenance, confidence, recency, and the request’s needs.
- Respond: pass a bounded, deduplicated set of useful memories into the model context.
- Record: append the new interaction as an episode with its session and ordering metadata.
- Compact: when your policy permits, derive candidate facts or procedures from eligible episodes and retain links back to their sources.
This separation makes it easier to change a retrieval rule without rewriting interaction history, or to revise a derived fact without losing the episode that produced it.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Which storage and search approach should you choose?
These options are not interchangeable packages. The right choice depends on what you need to retrieve, how your application is deployed, and what you have validated in your own workload.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →| Approach | What the cited documentation describes | Consider it when | What to validate |
|---|---|---|---|
sqlite-vec |
The SitePoint tutorial uses a vec0 virtual table alongside ordinary SQLite records. |
You want the tutorial’s vector-table architecture for a local TypeScript agent. | Extension loading, packaging, model dimensions, transactions, and retrieval quality in your deployed environment. |
| SQLite-Vector | A distinct project whose documentation describes vectors in BLOB columns in ordinary SQLite tables and its own scanning and quantization approaches. | You are evaluating a different vector-storage API and want to compare its fit with your application. | Its API and behavior independently; it is not a drop-in name for sqlite-vec. |
| FTS5 alongside vector search | SQLite’s full-text search module, with application responsibility for synchronizing an external-content index. | Queries include exact terms such as names, identifiers, or phrases. | Index maintenance for inserts, updates, and deletes, plus ranking on representative searches. |
The separate sqlite-memory project documents chunking, embeddings, hybrid vector-plus-FTS5 search, content-hash change detection, and SAVEPOINT-wrapped synchronization. Treat it as an adjacent implementation example, not a required dependency or validation of the sqlite-vec tutorial.
Best Value
What to test before deployment
No independent performance measurements for this exact architecture are established by the cited material. Measure it on representative data rather than assuming a design choice guarantees speed or recall.
- Test exact names and identifiers, paraphrases, recent events, and stale or contradictory facts.
- Compare vector-only, lexical-only, and hybrid retrieval on the same query set; inspect both whether the right item appears and how it is ranked.
- Measure query latency, recall quality, storage footprint, embedding generation cost, and the behavior of updates and deletions.
- Test transaction rollback when a write fails partway through changes to content, vectors, or lexical indexes.
- Record the Node.js version, SQLite driver and version,
sqlite-vecrelease, operating system and architecture, extension-loading configuration, and distribution format used for each deployment.
Project-reported benchmarks, where available, are specific to their reported hardware and methodology; they are not independent evidence for your workload. Choose rank weights, retention thresholds, and context budgets from your own evaluation.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →

