sdk-memory
Use Mem0 SDKs for hosted Platform clients and local OSS memory in Python and TypeScript, including CRUD, search, async clients, entity filters, metadata, categories, export, feedback, and migration-sensitive API differences.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- sdk-memory
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Use Mem0 SDKs for hosted Platform clients and local OSS memory in Python and TypeScript, including CRUD, search, async clients, entity filters, metadata, categories, export, feedback, and migration-sensitive API differences.
- disable-model-invocation
- true
02 资源文件 6
- 参考文档references/memory-operations.md9.4 KB
- 参考文档references/python-sdk.md8.8 KB
- 参考文档references/troubleshooting.md8.3 KB
- 参考文档references/typescript-sdk.md7.6 KB
- 脚本scripts/inspect_mem0_sdk.py4.1 KB
- 脚本scripts/mem0_sdk_smoke.py6.1 KB
03 SKILL.md 正文
Mem0 SDK Memory
Use this sub-skill when the task asks for Mem0, mem0ai, a memory layer, memory CRUD/search, Platform SDK calls, OSS Memory() usage, TypeScript MemoryClient, mem0ai/oss, async memory calls, retrieve-generate-store flows, filters, metadata, categories, exports, feedback, or SDK migration debugging.
Route First
- Use this sub-skill for Python
MemoryClient,AsyncMemoryClient,Memory,AsyncMemory, TypeScript hostedMemoryClient, and TypeScript OSSMemoryfrommem0ai/oss. - Use Python SDK for imports, live signatures, sync/async Python examples, and Platform-vs-OSS differences.
- Use TypeScript SDK for hosted
MemoryClient, OSSMemory, camelCase/snake_case option differences, exports, and feedback. - Use Memory Operations for add/search/update/delete patterns, retrieve-generate-store workflows, filters, metadata, categories, export, feedback, and migration notes.
- Use Troubleshooting for empty search results, import/install failures, API keys, optional backends, validation errors, and SDK misuse.
Sibling Boundaries
- Route provider, vector store, embedder, LLM, reranker, graph-memory, and optional dependency selection to
provider-configuration. - Route terminal commands, CLI config, JSON output, stdin/file workflows, import/export through commands, and
mem0 init/add/searchbehavior tocli-memory. - Route REST server deployment, Docker Compose, OpenMemory, MCP server hosting, API keys for self-hosted services, migrations, and operational backups to
self-hosted-openmemory. - Route editor/agent plugins, framework cookbooks, Vercel AI SDK provider wrapping, MCP plugin config, hooks, OpenClaw, and Pi Agent plugin tasks to
integrations-plugins.
Fast Decision Tree
- Hosted Platform SDK? Use
MemoryClient/AsyncMemoryClientin Python orMemoryClientin TypeScript; it needs a Mem0 API key and talks tohttps://api.mem0.aiby default. - Local OSS memory? Use Python
Memory/AsyncMemoryor TypeScriptMemoryfrommem0ai/oss; it needs provider/backend configuration, often OpenAI credentials by default. - Search or list memories? Put entity scope in
filters, for examplefilters={"user_id": "alice"}in Python and{ filters: { user_id: "alice" } }in TypeScript. - Add or bulk delete by entity? Follow the SDK-specific options in Memory Operations; current SDKs keep top-level entity options for add/delete-all, while search/get-all require
filters. - Debug before changing code? Run
python scripts/inspect_mem0_sdk.py --jsonto inspect installed Python exports/signatures without credentials, thenpython scripts/mem0_sdk_smoke.py --mode plan --language bothto generate safe smoke snippets.
Minimal Patterns
Python hosted Platform:
from mem0 import MemoryClient
client = MemoryClient(api_key=os.environ["MEM0_API_KEY"])
client.add("User prefers vegetarian meals", user_id="alice", metadata={"source": "chat"})
results = client.search("dietary preferences", filters={"user_id": "alice"}, top_k=5)
Python OSS:
from mem0 import Memory
memory = Memory()
memory.add("User prefers vegetarian meals", user_id="alice", metadata={"source": "chat"})
results = memory.search("dietary preferences", filters={"user_id": "alice"}, top_k=5)
TypeScript hosted Platform:
import { MemoryClient } from "mem0ai";
const client = new MemoryClient({ apiKey: process.env.MEM0_API_KEY! });
await client.add([{ role: "user", content: "User prefers vegetarian meals" }], { userId: "alice" });
const results = await client.search("dietary preferences", { filters: { user_id: "alice" }, topK: 5 });
TypeScript OSS:
import { Memory } from "mem0ai/oss";
const memory = new Memory();
await memory.add("User prefers vegetarian meals", { userId: "alice", metadata: { source: "chat" } });
const results = await memory.search("dietary preferences", { filters: { user_id: "alice" }, topK: 5 });
Safety Notes
- Do not print API keys, provider keys, memory contents from production users, or full environment dumps.
- Prefer read-only inspection before live API calls. The bundled scripts default to help/plan/inspection modes and do not require credentials unless explicitly requested.
- Never instruct future agents to run source-repository tests or examples; use the bundled references and scripts here.
- Treat
reset, wildcard deletes, and scopeddelete_all/deleteAllas destructive. Confirm scope and tenant before running them.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).