mem0ai/mem0

mem0-oss-to-platform

Plan, then execute, a migration of a project from the mem0 open-source / self-hosted SDK (local Memory class) to the mem0 Platform / hosted SDK (MemoryClient).

Zobacz źródło

Zobacz w działaniu

Przykład autora

OSS to Platform: complete migration-plan template

Complete original review template for inventory, per-file changes, configuration, unresolved decisions, verification and rollback. Placeholder paths and ellipses are deliberately preserved. It plans code migration; existing stored memories require a separate data-migration decision. A real plan must be filled from the project and approved before execution.

Przykładowy wynik

# mem0 OSS → Platform Migration Plan

## Summary
- One paragraph: what's moving (self-hosted `Memory` → hosted `MemoryClient`) and why.
- Detected language(s) and the installed `mem0ai` version.
- Counts: N files touched, M call sites, plus config/deps/env changes.

## Prerequisites
- `MEM0_API_KEY` must be set in the environment before execution/verification (https://app.mem0.ai).
- Note where it should live (`.env`, secrets manager, CI, deploy config).

## Inventory
A table of every mem0 touchpoint found, so the developer can see the full footprint:

| File:line | Current (OSS) usage | Category | Maps to |
|-----------|--------------------|----------|---------|
| path:LN   | `Memory.from_config({...})` | client init | `MemoryClient()` |
| path:LN   | `memory.search(q, user_id=...)` | call site | `search(q, filters={...}, top_k=...)` |
| ...       | ...                | config / dep / env / infra | ... |

## Change set
Grouped by file. For each, a short before → after with the actual surrounding code, so the edits are
unambiguous. Example:

### `path/to/file.py`
- Replace import `from mem0 import Memory` → `from mem0 import MemoryClient`.
- Replace the `Memory.from_config({...})` block with `MemoryClient()` (drops local vector_store/
  llm/embedder/history config).
- `search(...)`: move `user_id` into `filters={"user_id": ...}`; keep `top_k`.
  ```
  # before
  ...
  # after
  ...
  ```

## Dependencies & config
- `requirements.txt` / `pyproject.toml` / `package.json`: keep `mem0ai`; remove now-unused local-
  infra deps (list them, with the reason each is safe to remove).
- Env: add `MEM0_API_KEY`; remove env vars only used by the old local embedder/LLM if now unused.
- Infrastructure: local services that existed only for mem0 (e.g. a Qdrant docker-compose service)
  can be retired — listed for the developer's confirmation, not auto-deleted.

## Concerns & decisions needed
The non-1:1 items from the gotchas that apply here, each phrased as a decision for the developer.
Cover, where relevant: data not migrating, self-hosting/data-residency, local models moving server-
side, graph memory, custom prompts (now project-level `custom_instructions`), network/latency/cost on
hot paths, return-shape changes (`add` is async and returns an `event_id` (`eventId` on TS), `get_all` pagination,
default `top_k` 20 vs 10), metadata filters that need rewriting, and any `reset()` usage. Be specific
about which file/line each concern affects.

## Out of scope
- Existing memory **data** is not migrated (code only). If wanted, it's a separate opt-in task
  (for hosted Qdrant + Python OSS, `scripts/oss-to-platform-migrate.sh`; otherwise export from the
  OSS store and re-add to the hosted client).
- No unrelated refactors, renames, or behavior changes.

## Verification plan
How execution will be confirmed end-to-end:
- Imports / type-checks / byte-compiles cleanly.
- Smoke test against the hosted API with a real `MEM0_API_KEY`: `add` a fact → `search`/`get_all`
  returns it → `delete_all` clears it. Plus: the app's own entry point still runs.
- Confirm no local OSS storage is created anymore (e.g. `~/.mem0/history.db`, a local Qdrant path).
  The client still creates `~/.mem0/config.json`, so the bare `.mem0/` directory is not the check.

## Rollback
- All changes are in version control; revert with git if needed. Note the branch/commit strategy.
Licencja

Original source text retained; four-space Markdown code indentation normalized only for copyability where applicable. Full source license retained. Author recipes, placeholders and illustrative scorecard are not independently reproduced site results. No source instructions, provider requests, integration, installation, account creation, branch workflow or upstream subagents were executed.

                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but not
      limited to compiled object code, generated documentation, and
      conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work.

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to the Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by the Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding any notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   Copyright 2024 Mem0.ai

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

Jak używać

  1. Skopiuj polecenie instalacji i sprawdź źródła przed instalacją we własnym środowisku agenta.
  2. W oryginale sprawdź wymagane narzędzia, dane dostępowe i obsługiwane środowiska.
  3. Opisz dane wejściowe i oczekiwany rezultat; porównaj wynik ze źródłami.
npx skills add https://github.com/mem0ai/mem0 --skill mem0-oss-to-platform

Przed rozpoczęciem

  • Instalacja nie obejmuje subskrypcji modelu, limitu API ani uprawnień do plików.
  • Gwiazdki i instalacje pokazują aktywność, a nie niezależny test jakości lub bezpieczeństwa.
Oryginalny dokument Skill

Treść z repozytorium z zachowaniem nagłówków, przykładów, kodu, tabel, linków i obrazów.

Migrate mem0 OSS → mem0 Platform (hosted)

This skill migrates a project's memory layer from the self-hosted mem0 OSS SDK to the hosted mem0 Platform SDK, working for any project shape — an agent, a RAG pipeline, an API service, a chatbot, a background worker. You discover where mem0 is actually used, write a plan the developer reviews, and then execute it on approval.

The mental model (read this first — it's why the migration is shaped the way it is)

OSS mem0 means the developer runs the whole memory stack themselves: a vector store (Qdrant/pgvector/Chroma/…), an embedder, an LLM for fact extraction, and a local history DB. All of that is wired up in a config object passed to Memory.

The Platform means mem0 runs that stack for them. The developer just holds an API key. So the migration is mostly subtraction: the local infrastructure config collapses into a single MemoryClient(api_key=...). The method calls stay recognizable (add/search/get_all/…), but a few parameter conventions tighten up and the return values are server responses.

So the core of every migration is:

  1. Memory / Memory.from_config({...}) → MemoryClient() (reads the API key from the env).
  2. Delete the local vector_store / llm / embedder / reranker / history_db_path config (and any

leftover graph_store).

  1. Fix up each call site to the hosted call convention (entity IDs into filters, pagination, etc.).
  2. Flag everything that isn't a clean 1:1 so the developer can decide (see references/gotchas.md).

Scope discipline: touch only mem0-related code, config, dependencies, and env. Preserve the project's existing behavior, structure, and style. Do not rename things, "tidy" nearby code, or change the app's logic. The developer asked to swap a backend, not to refactor their project.

Workflow

Work through these phases in order. Phases 1–4 produce the plan; phase 5 runs only after approval.

Phase 0 — Prerequisite check

The hosted SDK needs a mem0 API key (MEM0_API_KEY, obtainable at https://app.mem0.ai). Confirm the developer has one. You don't need the key value to write the plan, but flag in the plan that it must be set (in .env / secrets manager, never hardcoded) before execution and verification.

Phase 1 — Discover the mem0 footprint

Do not assume the layout. Find every place mem0 appears. Detect the language and the installed version first, then sweep for usage. Concretely, search for:

  • Imports / instantiation: from mem0 import Memory, AsyncMemory, Memory.from_config,

Memory(, import ... from "mem0ai", from "mem0ai/oss", new Memory(.

  • Config blocks: keys like vector_store/vectorStore, embedder, llm, reranker,

graph_store/graphStore, history_db_path/historyDbPath, historyStore, custom_instructions/customInstructions, custom_fact_extraction_prompt/customPrompt, custom_update_memory_prompt, enable_graph.

  • Every call site: .add(, .search(, .get_all(/.getAll(, .delete_all(/.deleteAll(,

.get(, .update(, .delete(, .reset(, .history(.

  • Dependencies & env: requirements.txt/pyproject.toml/package.json for mem0ai and any

local-infra deps that exist only for mem0 (e.g. qdrant-client, chromadb); .env/config for things like OPENAI_API_KEY used by the local embedder/LLM; any docker-compose service (e.g. a Qdrant container) that exists only to back mem0.

Use Grep/Glob broadly; a single missed call site is a runtime break later. Record file:line for each finding — the plan's inventory is built from this.

Phase 2 — Verify the API against the installed SDK (don't guess)

Versions drift, and the OSS and hosted classes have subtly different signatures. Before mapping, confirm the real signatures of the installed package rather than trusting memory:

  • Python: python -c "import inspect; from mem0 import MemoryClient; print(inspect.signature(MemoryClient.search))"

for each method you'll touch, and read the installed source under site-packages/mem0/client/main.py if anything is ambiguous (e.g. whether a method rejects top-level entity params). Also check the OSS side the project currently uses.

  • TypeScript: read the installed types/dist under node_modules/mem0ai/ to confirm option names

(limit vs topK, userId vs a nested filters: { user_id }) and the default vs mem0ai/oss export.

This verification step is the single most important habit — it's what keeps the plan correct across mem0 versions. Then consult references/api-mapping.md for the OSS→hosted translation of each method (Python and TypeScript). The docs guide is https://docs.mem0.ai/migration/oss-to-platform (verify its code samples against the installed SDK); OSS upgrade changes are at https://docs.mem0.ai/migration/oss-v2-to-v3.

Phase 3 — Map each site and flag the gaps

For every call site and config block from Phase 1, determine the hosted equivalent using the mapping. Most calls map cleanly. Some don't — and those matter more than the mechanical edits. Read references/gotchas.md and flag anything that needs a human decision: self-hosted/data- residency setups, local model choices moving server-side, graph-memory usage, custom prompts, hot- path calls that now make network round-trips, and existing locally-stored memories not carrying over (data migration is out of scope unless the developer asks: note it, don't silently attempt it; if they do ask, see references/gotchas.md #1, which covers the hosted-Qdrant migration script).

Phase 4 — Write the plan and stop

Write the full plan to MEM0_MIGRATION_PLAN.md at the repo root, following the structure in references/plan-template.md. It must be concrete enough to execute from and honest about the gaps. Then stop and present it for review. Do not start editing code in the same turn — the whole point is that the developer reads and approves the plan first.

Phase 5 — Execute on approval (guided)

Once the developer approves (they may ask for changes first — incorporate them), execute the plan:

  • Make the edits file by file, staying strictly within mem0 scope.
  • Update dependencies and env (MEM0_API_KEY; remove now-dead local-infra deps/services only if

they exist solely for mem0 and you're confident).

  • Verify, mirroring how you'd confirm any backend swap:
  • It imports / type-checks / byte-compiles.
  • A smoke test exercises add → search/get_all → delete_all against the hosted API with a

real MEM0_API_KEY, and the app's own entry point still runs. Hosted add is asynchronous, so allow a short wait before expecting the fact to show up in search/get_all.

  • No local OSS storage gets created anymore (e.g. ~/.mem0/history.db, a local Qdrant path). The

client itself still creates ~/.mem0/config.json, so don't use the bare .mem0/ directory as the check.

  • Report what changed, what was verified, and any flagged concerns the developer still needs to act

on (e.g. re-applying custom instructions with project.update, migrating old data).

Reference files

  • references/api-mapping.md — exact OSS→hosted method/param/return mapping for Python and

TypeScript, plus dependency and env changes. Read during Phase 2–3.

  • references/gotchas.md — the things that aren't a clean 1:1 and need a human decision. Read

during Phase 3 so the plan's "Concerns" section is complete.

  • references/plan-template.md — the exact structure for MEM0_MIGRATION_PLAN.md. Use in Phase 4.

Powiązane zadania

z tego samego repozytorium

Więcej Skills

Wszystkie Skills
mem0ai
Społeczność

mem0-integrate

Integrate Mem0 into an existing repository using a goal-driven, TDD pipeline. Detects the repo's language automatically and asks the user to pick between Mem0 Platform (managed) and Mem0 Open Source (self-hosted). Writes failing tests before any implementation. Produces a local feature branch plus .mem0-integration/ artifacts consumed by the paired verification skill. TRIGGER when: user says "integrate mem0", "add mem0 to this repo", "wire mem0 into ", or asks how to add memory to an existing pr

instalacje
0
GitHub Stars
67,8 tys.
Aktualizacja
23 paź
mem0ai
Społeczność

mem0-test-integration

Verify a Mem0 integration produced by /mem0-integrate. Runs in the same workspace on the same branch (loose coupling) — installs dependencies, runs the repo's native test suite, then exercises a real end-to-end smoke flow against the user's API key. Produces a scorecard. TRIGGER when: user has just run /mem0-integrate and says "verify", "test the integration", "run /mem0-test-integration", or when a .mem0-integration/ directory exists and tests have not been run yet on the current branch. DO NOT

instalacje
0
GitHub Stars
67,8 tys.
Aktualizacja
23 paź
mem0ai
Społeczność

mem0-vercel-ai-sdk

Mem0 provider for Vercel AI SDK (@mem0/vercel-ai-provider). TRIGGER when: user mentions "vercel ai sdk", "@mem0/vercel-ai-provider", "createMem0", "retrieveMemories", "addMemories", "getMemories", "searchMemories", "mem0 vercel", "AI SDK provider", "AI SDK memory", or is using generateText/streamText with mem0. Also triggers for Next.js apps needing memory-augmented AI. DO NOT TRIGGER when: user asks about direct Python/TS SDK calls without Vercel (use mem0 skill), or CLI terminal commands (use

instalacje
0
GitHub Stars
67,8 tys.
Aktualizacja
23 paź
mem0ai
Społeczność

mem0

Mem0 Platform SDK for adding persistent memory to AI applications. TRIGGER when: user mentions "mem0", "MemoryClient", "memory layer", "remember user preferences", "persistent context", "personalization", or needs to add long-term memory to chatbots, agents, or AI apps. Covers Python SDK (mem0ai), TypeScript SDK (mem0ai), and framework integrations (LangChain, CrewAI, OpenAI Agents SDK, Pipecat, LlamaIndex, AutoGen, LangGraph). Also covers the open-source self-hosted Memory class. This is the DE

instalacje
1
GitHub Stars
67,5 tys.
Aktualizacja
20 paź