[N15] Semantic recall: an embedding provider and a SQLite vector memory - #314
Merged
Merged
Conversation
…ry (#258) EmbeddingProvider and aiSdkEmbedder (embedMany from the installed ai, loaded on first use), inMemoryVectorMemory and sqliteVectorMemory ranking by cosine similarity with minScore and reindex(), a memory_vectors migration, MemoryProvider.ranking for the recall tool wording, hashEmbedder in /testing, and a rank mode for the provider contract. Docs: new "Semantic recall" section at the end of docs/memory.md. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
# Conflicts: # CHANGELOG.md
# Conflicts: # CHANGELOG.md
# Conflicts: # src/storage/sqlite/migrations.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Semantic recall for memory slots (N15). A slot can recall by meaning instead of by keyword.
EmbeddingProviderandaiSdkEmbedder(model, { id?, maxBatch? }): any AI SDK embedding model throughembedManyfrom the installedai, loaded lazily on first use (no new dependency; a missingairaisesMissingPeerDependencyError). Runs onai4, 6 and 7 (tests use the installedaiplus theai-v6/ai-v7aliases).inMemoryVectorMemory(options)(root) andsqliteVectorMemory(store, options)(/sqlite): cosine-similarity ranking,minScore,maxItems,reindex(scopeKey?), score inmetadata.score. Only items of the requested scope key and of the same embedder id are scored.memory_vectorstable (existing databases gain it on open;memory_items/sqliteMemoryuntouched).MemoryProvider.ranking?: 'newest' | 'relevance': therecall_<name>description says "by meaning, most relevant first" for vector providers; unchanged for others.hashEmbedder()in/testing: deterministic offline embedder.describeMemoryProviderContract(name, make, { query: 'filter' | 'rank' }).Implementation notes: writes to one scope key are serialized (an item removed during
reindex()is not resurrected);addembeds first and stores nothing when embedding fails;SqlValuein the SQLite driver types now allowsUint8Arrayfor the BLOB.Docs site (G9)
docs/memory.md: new heading## Semantic recall, appended at the end of the page (after## Limitations; no existing heading added, renamed or moved). Also edited without heading changes: two rows in the## Providerstable, the paragraph after it, one sentence in### SQLite, and one sentence before the custom-provider example. The Arabic page needs the new section appended and those lines updated. No new or restructured pages.Live test
Not run: the OpenRouter account is out of credit (
total_usage10.199 >=total_credits10). No live test file committed; a checklist line is on #260. Live test spend: none.Verification (after merging origin/main)
npx tsc --noEmit: oknpm run lint: zero warningsnpm run build,npm run build --workspace=packages/create-lousho-agent: oknpm run test:types: 68 passed, no type errorsnpm run docs:verify-snippets -- --skip-build: 223 type-check, 8 runnpm run docs:llms:check: oknpm run test:coverage: 248 files passed, 3618 tests passed, 7 skipped;npm run fallow: 0 above thresholdnpm run pack-smoke: all checks passedSubprocessSandbox/httptimeout,oteloptional-peer test,src/deploy(see brief).Note: a non-owner comment on #258 (aetherxeg-source) suggested provenance fields and a stale-vector test matrix; not part of the ticket's scope and not acted on. The cross-scope and embedder-generation cases it names are covered here by tests that exist anyway (scope isolation, other-embedder items skipped until
reindex()).Closes #258
🤖 Generated with Claude Code