Commit Graph

2151 Commits

Author SHA1 Message Date
chaithanyak42 98ed2e9202 fix(ts-oss): isolate entity store from memory store when dbPath unset
Symptom: TS OSS `memory.search()` returns entity rows (fragment text
like "a fan of", "recommending thriller movies and") mixed in with
real memories. The broken rows have `hash: undefined` and
`createdAt: undefined` because they came from the entity store, not
the memory pipeline.

Root cause: `MemoryVectorStore` uses a single `vectors` SQLite table
and ignores `collectionName` internally. The entity store is created
as a parallel instance with `collectionName: "${name}_entities"` in
`memory/index.ts:193`, but both default to the same `dbPath`
(`~/.mem0/vector_store.db`) when the caller doesn't set one. Both
writers append to the same `vectors` table, so a search that reads
that table returns rows from both collections.

The existing mitigation at `memory/index.ts:199` (dbPath.replace) only
fires when `dbPath` is set explicitly. The default (unset) case fell
through with no isolation.

Fix: `getDefaultVectorStoreDbPath(collectionName?)` now derives the
default filename from the collection name
(`vector_store_${name}.db`). `MemoryVectorStore` passes
`config.collectionName` into the helper. Memory vs entity stores now
land in separate files automatically, even when the caller doesn't set
`dbPath`. Explicit `dbPath` users are unaffected — the existing
suffix-swap in `memory/index.ts` still handles them.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 18:36:46 +05:30
kartik-mem0 5e941e24c2 refactor: update search tests to use AND filter syntax and drop version param 2026-04-14 17:46:58 +05:30
kartik-mem0 c3f48d093e refactor: update MemoryClient to use entity options instead of filters 2026-04-14 17:13:52 +05:30
kartik-mem0 28cc8fcee4 refactor: update MemoryClient to use filters for entity parameters 2026-04-14 16:17:50 +05:30
kartik-mem0 133625bbc6 refactor: update MemoryClient to support snake_case filter keys and separate filters 2026-04-14 02:54:44 +05:30
Saket Aryan de6f9abc6c Update main.py 2026-04-14 02:49:22 +05:30
Soumil Rathi 920d648d88 Merge branch 'feat/v3-pipeline' of https://github.com/mem0ai/mem0 into feat/v3-pipeline 2026-04-13 14:05:31 -07:00
Soumil Rathi e93a81b6a0 fix: change integration test query from 'anything' to 'test search query'
The word 'anything' triggers a server-side 500 in the v3 search
endpoint's BM25/lemmatization pipeline.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 14:05:24 -07:00
chaithanyak42 60065f3792 fix(tests): fix remaining 6 failures — mock setup for v3 pipeline
- _get_all_from_vector_store: top_k -> limit (2 missed occurrences)
- test_empty_llm_response_fact_extraction (sync+async): add
  db.get_last_messages mock returning [], set custom_instructions=None,
  fix log assertion to use record.message not record.msg
- test_thinking_tags (sync+async): add embed_batch mock, db mock
  with get_last_messages=[], set custom_instructions=None

Root cause: v3 pipeline calls self.db.get_last_messages() and
self.embedding_model.embed_batch() which weren't mocked, causing
the pipeline to silently fail before reaching the LLM call.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 02:32:29 +05:30
chaithanyak42 ce38ab7840 fix(lint): remove unused asyncio import in test_telemetry
The async context manager tests that used asyncio were deleted in the
previous commit. The import is no longer needed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 02:24:50 +05:30
Soumil Rathi 5de9bae84e Merge branch 'feat/v3-pipeline' of https://github.com/mem0ai/mem0 into feat/v3-pipeline 2026-04-13 13:53:46 -07:00
Soumil Rathi 9c01c895c1 fix: use camelCase eventId in crud integration test assertions
Client's snakeToCamelKeys converts the v3 response keys to camelCase.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 13:53:37 -07:00
chaithanyak42 41e51491dd fix: resolve merge conflicts with upstream TS changes
Take team's upstream changes for search return type
(Promise<{results: Array<Memory>}>) and test assertions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 02:20:07 +05:30
chaithanyak42 0b4bbcefff fix(tests): update 35 failing tests for v3 single-pass pipeline
Tests were written for the old two-pass extraction pipeline (extract
facts + merge with ADD/UPDATE/DELETE). V3 uses single-pass ADD-only
extraction with one LLM call returning {"memory": [...]}.

Changes by category:

Old pipeline tests (13 failures):
- Delete TestHallucinatedIdGuard entirely (tests UPDATE/DELETE ID
  resolution that no longer exists)
- Update error log assertions to match v3 log messages
- Change LLM mock from 2-call side_effect to 1-call return_value
- Update vllm thinking tag tests for single-call format

ensure_json_instruction removed (3):
- Delete source-inspection tests (function still exists in utils
  but is no longer called from _add_to_vector_store)

UTC timestamp normalization removed (2):
- Update expected timestamps to stored-as-is (no UTC conversion)
- Remove _normalize_iso_timestamp_to_utc import

_search_vector_store signature: top_k -> limit (2):
- Update test calls to use limit= parameter

Context manager + close/db removed (6):
- Delete tests for __enter__/__exit__/close/db that were removed

Vector store BM25 config (3):
- Qdrant: add sparse_vectors_config to create_col assertion,
  named vector format {"": vector} in update assertion
- MongoDB: assert_any_call for both vector + text search indexes

Misc (6):
- test_search_handles_incomplete_payloads: expect 1 result (v3
  filters entries without 'data' key)
- Embedding cache tests: update for embed_batch (1 call) vs
  individual embed (was 2 calls)
- Graph reset tests: delete (graph support removed)
- use_azure_credential: update expected sensitivity to True

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 02:19:39 +05:30
Soumil Rathi 2a5ffd0976 fix: update integration tests for v3 API responses
- crud.test.ts: add() returns {event_id, status} not an array
- search.test.ts: use snake_case user_id in filters for v3 compatibility

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 13:45:12 -07:00
Soumil Rathi 271de8eabf revert: keep waitForSearchResults options as Record<string, any>
Matches main. The type tightening was an unsolicited change.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 13:33:16 -07:00
Soumil Rathi 015aa2c866 fix: type waitForSearchResults options as SearchMemoryOptions
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 13:32:00 -07:00
Soumil Rathi 2da2ded2d8 fix: restore v3 search response format — return {results: [...]} not bare array
The v3 API returns {results: [...]} and the client should pass that
through without unwrapping. Updated return type to Promise<{results: Array<Memory>}>,
removed the unwrap logic, and fixed integration tests to access .results.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 13:25:25 -07:00
Soumil Rathi 0aa0f44ac4 fix: revert search return type to Array<Memory> (matches unwrap logic)
Someone else's changes unwrap the v3 envelope in the client,
so the return type should stay as Array<Memory> for consistency.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 13:20:25 -07:00
Soumil Rathi 7410d190fc Merge branch 'feat/v3-pipeline' of https://github.com/mem0ai/mem0 into feat/v3-pipeline 2026-04-13 13:19:34 -07:00
Soumil Rathi 7c313add10 fix: update search() return type to match v3 response format
Change TS client search() return type from Promise<Array<Memory>>
to Promise<{ results: Array<Memory> }> to match v3 API envelope.
Update unit test mocks to return {results: []} and fix assertions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 13:19:26 -07:00
chaithanyak42 e51df348ce fix(ts-sdk): unwrap v1.1 search response in client, fix TS2339 type errors
search() now unwraps { results: [...] } -> [...] internally (same
pattern getAll() already uses), so callers always get Array<Memory>.

Removes redundant unwrap logic from integration test helpers and
search.test.ts that caused TS2339 'Property results does not exist
on type never' — the false branch of Array.isArray() was unreachable
since search() is typed as returning Array<Memory>.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 01:48:22 +05:30
Soumil Rathi 7f19c499ca fix: delete remaining graph test files
Remove test_neo4j_cypher_syntax.py and test_graph_delete_docker.py
which reference deleted graph_memory module.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 13:15:03 -07:00
Soumil Rathi c5e748b469 fix: remove all graph references from tests/test_main.py
Strip graph_memory patches, GraphStoreFactory mocks, graph_store config,
enable_graph parametrize, _add_to_graph assertions, and "relations"
assertions from all test fixtures and test functions. Graph store has
been removed from the codebase.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 13:14:40 -07:00
Soumil Rathi b9d7ae5fa7 fix: update integration tests for v3 search response format
v3 search returns {results: [...]} instead of a bare array.
Updated waitForSearchResults helper and search edge case tests
to unwrap the v3 envelope.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 13:10:17 -07:00
Soumil Rathi 78cc11ef1f fix: restore lmstudio/deepseek providers in TS factory, add langchain to extras
- Restore LMStudioEmbedder, LMStudioLLM, DeepSeekLLM in TS factory.ts
  (accidentally removed during graph store cleanup — unrelated to graphs)
- Add langchain>=0.1.0 to Python extras dep group (was transitively
  provided by langchain-neo4j in the removed graph group, still needed
  by mem0/llms/langchain.py and mem0/embeddings/langchain.py)
- Add pytest.importorskip("langchain") to test_langchain.py for graceful
  skip when langchain isn't installed

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 12:55:36 -07:00
Soumil Rathi 1a2edf739d fix: delete graph test files that import removed graph modules
These test files import mem0.memory.graph_memory, kuzu_memory,
memgraph_memory, apache_age_memory, and mem0.graphs.neptune which
were deleted in the graph store removal commit.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 12:17:35 -07:00
Soumil Rathi 66446bd118 fix: address reviewer bugs — metadata mutation, test args, embedding dict, output_format
1. Fix _create_procedural_memory metadata mutation: use spread operator
   instead of in-place dict assignment (sync + async)
2. Fix test_add assertion: remove trailing None arg that doesn't match
   _add_to_vector_store(messages, metadata, filters, infer) signature
3. Restore output_format: "v1.1" in TS client search payload as fallback
4. Fix infer=False path: pass {text: embedding} dict to _create_memory
   instead of raw embedding list to avoid redundant embed() calls (sync + async)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 11:50:56 -07:00
Soumil Rathi 163444e33b fix: update TS client tests for v3 API endpoints
Update mock URLs in memoryClient.crud.test.ts and
memoryClient.search.test.ts to match v3 endpoints:
- add: /v1/memories/ -> /v3/memories/
- search: /v2/memories/search/ -> /v3/memories/search/
- deleteAll: stays on /v1/memories/ (no v3 equivalent)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 11:34:52 -07:00
Soumil Rathi e1e033daef style: run prettier on TS SDK files
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 11:29:06 -07:00
Soumil Rathi 3ae22be8a2 fix: resolve CI failures — lint errors, pytz in redis, lockfile mismatch
- Remove unused imports: get_update_memory_messages, get_fact_retrieval_messages
- Fix pytz.timezone("US/Pacific") → timezone.utc in redis vector store
- Remove unused entity_types variable in test_entity_extraction
- Regenerate pnpm-lock.yaml after neo4j-driver removal

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 11:24:14 -07:00
Soumil Rathi 730b2ff422 fix: restore complete _SENSITIVE_FIELDS_EXACT list from original commit
Was missing 13 entries (credentials, token, access_token, refresh_token,
auth_token, session_token, client_secret, auth_client_secret,
azure_client_secret, service_account_json, aws_session_token, credential,
secret). Now matches the original list from commit 46b4b2e9.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 11:03:49 -07:00
Soumil Rathi 573ca54637 fix: restore _is_sensitive_field and sensitive field redaction in _safe_deepcopy_config
The function and associated constants (_SENSITIVE_FIELDS_EXACT,
_SENSITIVE_SUFFIXES) were accidentally dropped during the merge.
Restores telemetry-safe config cloning that redacts API keys,
passwords, and other secrets while preserving runtime auth objects.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 10:53:56 -07:00
Soumil Rathi 59880a6f8f feat: TS SDK v3 port, graph store removal, client v3 API migration
TypeScript SDK v3 pipeline (full parity with Python):
- Single-pass additive extraction with ADDITIVE_EXTRACTION_PROMPT
- Hybrid search (semantic + BM25 + entity boost) with additive scoring
- 8-phase batch pipeline (batch embed, persist, entity linking)
- New utils: scoring.ts, lemmatization.ts (natural), entity_extraction.ts (compromise)
- keywordSearch() on 8 vector stores (3 full: PGVector, Memory, Azure AI Search)
- Message persistence in SQLiteManager (rolling window of 10)
- Entity store as second vector collection
- MAX_BATCH=100 chunking guard on OpenAI/Azure embedBatch
- Updated default LLM model to gpt-4.1-nano-2025-04-14
- compromise + natural added as peer dependencies

Graph store removal (Python + TypeScript):
- Removed Neo4j, Memgraph, Kuzu, Neptune, Apache AGE integrations
- Deleted 18 graph-related files across both SDKs
- Removed GraphStoreFactory, GraphStoreConfig, graph_store config field
- Removed "relations" key from all API responses
- Removed graph optional dependency group from pyproject.toml
- Removed neo4j-driver from TS peerDependencies
- Simplified add/search/delete/reset (no more parallel graph operations)

Client SDK v3 API migration:
- add() endpoint: /v1/memories/ -> /v3/memories/ (async response)
- search() endpoint: /v2/memories/search/ -> /v3/memories/search/
- Removed output_format injection and v1.1 unwrapping logic
- Applied to both Python (sync + async) and TypeScript clients

Review feedback fixes:
- Removed deprecated custom_update_memory_prompt from MemoryConfig
- Added MAX_BATCH=100 chunking to Python + TS embed_batch
- Moved all inline imports to top level in main.py
- Cleaned up GraphStoreError dead code from exceptions.py

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 10:45:40 -07:00
Soumil Rathi 3402c67805 fix: address PR review feedback
- Remove deprecated custom_update_memory_prompt from MemoryConfig entirely
- Add MAX_BATCH=100 chunking guard to embed_batch in openai.py and azure_openai.py
- Move all inline imports (mem0.utils.*) to top-level in main.py
- Remove custom_update_memory_prompt from test fixture

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 09:01:07 -07:00
Soumil Rathi c0343aec1b Merge remote-tracking branch 'origin/feat/v3-pipeline' into feat/v3-pipeline
# Conflicts:
#	mem0-ts/src/oss/src/utils/factory.ts
#	mem0/vector_stores/milvus.py
#	mem0/vector_stores/qdrant.py
2026-04-12 16:30:05 -07:00
Soumil Rathi b9e26acf4d merge: integrate main into feat/v3-pipeline + port AsyncMemory to v3
Merge 190 commits from main including:
- limit→top_k rename across all vector store APIs
- custom_fact_extraction_prompt→custom_instructions rename
- enable_graph flag removal (use self.graph truthiness)
- US/Pacific→timezone.utc normalization
- 18 Category A bug fixes (partial updates, graph cleanup on delete,
  telemetry gating, metadata mutation prevention, filter operator
  merging, delete timestamps, actor_id preservation, etc.)

Conflict resolutions:
- openai.py: merged _pass_dimensions_to_api with embed_batch
- milvus.py: merged partial-update logic with BM25 text field
- qdrant.py: took main's enhanced _create_filter, merged BM25
  sparse vectors with partial-update endpoints
- test_main.py: adopted main's test structure, removed obsolete
  test_custom_prompts, kept hybrid search over-fetch assertion

AsyncMemory v3 port (full parity):
- Rewrote AsyncMemory._add_to_vector_store with the same 8-phase
  batch pipeline as sync Memory (single LLM call, batch embed,
  hash dedup, batch persist, batch entity linking, message saving)
- All blocking calls wrapped in await asyncio.to_thread()
- Moved _build_session_scope to module level for shared access

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 16:26:10 -07:00
Kartik 9d6b79a14e fix(sdk): removing the enable graph flag and switching from snake case to camel case for client ts sdk (#4776)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 02:40:54 +05:30
Kartik e44b46ef2e fix(sdk): removing deprecating param from our sdk and docs changes with it (#4740) 2026-04-12 00:34:58 +05:30
Saket Aryan 3882af7450 fix(cli): persistent anonymous telemetry ID + pass source=CLI in all API calls (#4789) cli-node-v0.2.3 cli-v0.2.3 2026-04-11 21:00:05 +05:30
Saket Aryan d39ebad09f fix(openclaw): persistent anonymous telemetry ID, flush fix, and email resolution (#4790)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
openclaw-v1.0.6
2026-04-11 20:57:14 +05:30
Gabriel Stein 9d82e2329d refactor(telemetry): sample OSS hot-path events at 10% to reduce PostHog volume (#4771) 2026-04-11 16:25:38 +05:30
Saket Aryan 398445c691 fix: filters did not support AND, OR and NOT in Qdant and other vector stores (#4780)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 23:43:12 +05:30
szinvas 789cc9d607 docs - replace session_id with run_id (#4742) 2026-04-10 20:06:59 +05:30
Jared Diaz e59e3d5f0c Add deepseek.ts to src/llms with corresponding unit tests. Updates fa… (#4613)
Co-authored-by: kartik-mem0 <kartik.labhshetwar@mem0.ai>
2026-04-10 20:06:22 +05:30
Kartik d926f3697c fix(docs): eliminate ~222 SEO redirect chains on docs.mem0.ai (#4768) 2026-04-10 19:33:45 +05:30
Kartik c996b0e7fa docs: removing the changelog.mdx file adn replacing it with new changelog system (#4750) 2026-04-10 19:07:43 +05:30
Kartik 78ca85a260 refactor: update OpenClaw plugin config, hook logic, and documentation (#4764) openclaw-v1.0.5 2026-04-09 17:36:05 +05:30
Kartik 88f696a60a refactor: drop orgId, projectId, enableGraph config options, update CLI prompts, and clean up related code (#4734) 2026-04-09 14:57:33 +05:30
Ignazio De Santis 081eca6d8f fix: guard temp_uuid_mapping lookups against LLM-hallucinated IDs (fixes #3931) (#4674)
Co-authored-by: kartik-mem0 <kartik.labhshetwar@mem0.ai>
2026-04-08 21:55:52 +05:30