feat: integrate turbopuffer as vector database provider#4428
Merged
whysosaket merged 6 commits intomainfrom Mar 21, 2026
Merged
feat: integrate turbopuffer as vector database provider#4428whysosaket merged 6 commits intomainfrom
whysosaket merged 6 commits intomainfrom
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ollisions - region defaults to 'gcp-us-central1' (turbopuffer SDK requires it) - insert/update now set id/vector after payload to prevent key collisions - added tests for key collision protection and default region Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
14 tasks
kartik-mem0
previously requested changes
Mar 19, 2026
Contributor
kartik-mem0
left a comment
There was a problem hiding this comment.
please address the ci errors.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
Author
ci errors addressed @kartik-mem0 |
…espaces Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
whysosaket
approved these changes
Mar 21, 2026
lukaj99
added a commit
to lukaj99/mem0
that referenced
this pull request
Mar 21, 2026
jamebobob
pushed a commit
to jamebobob/mem0-vigil-recall
that referenced
this pull request
Mar 29, 2026
Co-authored-by: utkarsh240799 <utkarsh240799@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Description
Integrates Turbopuffer as a vector database provider for mem0.
TurbopufferDBvector store implementation using the officialturbopufferPython SDK (v1.19+)TurbopufferConfigPydantic config classVectorStoreFactoryandVectorStoreConfigFixes #2543
Type of change
Implementation Details
Turbopufferclient API (not the legacytpuf.api_keyglobal pattern)insert()uses row-basednamespace.write(upsert_rows=...)with batchingupdate()withvector=Noneusespatch_rowsfor payload-only updates (avoids corrupting existing vectors)delete()usesnamespace.write(deletes=[id])delete_col()usesnamespace.delete_all()search()usesnamespace.query(rank_by=("vector", "ANN", ...))with native filter supportget()uses ANN query with ID filter (turbopuffer applies filters before ranking, guaranteeing correctness)list()returns wrapped[results]format for compatibility withmain.py's_get_all_from_vector_storeanddelete_allcount()usesnamespace.metadata().approx_row_countinstead of querying withtop_k=10000col_info()usesnamespace.metadata()for real namespace stats_parse_output()correctly extracts$distand attributes from turbopufferRowobjects viamodel_dump()1 - cosine_distance = cosine_similarity(mathematically correct for[0, 2]range)id/vectorare set afterpayload.update()to prevent overwritesregiondefaults togcp-us-central1(required by the turbopuffer SDK)list_cols(),list(),delete_col(),col_info(),get(), andcount()when namespace doesn't exist or permissions are limitedTesting
Testing Methodology
The integration was validated through two layers of testing:
1. Unit Tests (64 tests) — mocked SDK
All turbopuffer SDK calls are mocked, testing every method in isolation with edge cases. Tests use real
turbopuffer.types.Rowobjects (viamodel_validate) to ensure_parse_outputhandles the actual SDK data model correctly. Tests are skipped viapytest.importorskipwhen the SDK is not installed (CI compatibility).2. End-to-End Tests (12 tests) — real turbopuffer API
Ran against the live turbopuffer API to validate real behavior. This caught two issues that unit tests could not:
list_cols()returns 403 when the API key lacks namespace listing permissions → added graceful error handlinglist()afterreset()returns 404 because the namespace no longer exists → added try/exceptpatch_rows(payload-only update) truly preserves the original vector by searching with the old vector after patchingUnit Test Coverage
_get_allcompat,delete_allcompatE2E Test Results (against real turbopuffer API)
Regression Testing
No regressions in existing tests:
Checklist
Maintainer Checklist
turbopufferas a vector database #2543🤖 Generated with Claude Code