repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | --- |
| #2 | title: Advanced Memory Operations |
| #3 | description: "Run richer add/search/update/delete flows on the managed platform with metadata, rerankers, and per-request controls." |
| #4 | --- |
| #5 | |
| #6 | # Make Platform Memory Operations Smarter |
| #7 | |
| #8 | <Info> |
| #9 | **Prerequisites** |
| #10 | - Platform workspace with API key |
| #11 | - Python 3.10+ and Node.js 18+ |
| #12 | - Async memories enabled in your dashboard (Settings → Memory Options) |
| #13 | </Info> |
| #14 | |
| #15 | <Tip> |
| #16 | Need a refresher on the core concepts first? Review the <Link href="/core-concepts/memory-operations/add">Add Memory</Link> overview, then come back for the advanced flow. |
| #17 | </Tip> |
| #18 | |
| #19 | ## Install and authenticate |
| #20 | |
| #21 | <Tabs> |
| #22 | <Tab title="Python"> |
| #23 | <Steps> |
| #24 | <Step title="Install the SDK with async extras"> |
| #25 | ```bash |
| #26 | pip install "mem0ai[async]" |
| #27 | ``` |
| #28 | </Step> |
| #29 | <Step title="Export your API key"> |
| #30 | ```bash |
| #31 | export MEM0_API_KEY="sk-platform-..." |
| #32 | ``` |
| #33 | </Step> |
| #34 | <Step title="Create an async client"> |
| #35 | ```python |
| #36 | import os |
| #37 | from mem0 import AsyncMemoryClient |
| #38 | |
| #39 | memory = AsyncMemoryClient(api_key=os.environ["MEM0_API_KEY"]) |
| #40 | ``` |
| #41 | </Step> |
| #42 | </Steps> |
| #43 | </Tab> |
| #44 | <Tab title="TypeScript"> |
| #45 | <Steps> |
| #46 | <Step title="Install the OSS SDK"> |
| #47 | ```bash |
| #48 | npm install mem0ai |
| #49 | ``` |
| #50 | </Step> |
| #51 | <Step title="Load your API key"> |
| #52 | ```bash |
| #53 | export MEM0_API_KEY="sk-platform-..." |
| #54 | ``` |
| #55 | </Step> |
| #56 | <Step title="Instantiate the client"> |
| #57 | ```typescript |
| #58 | import { Memory } from "mem0ai"; |
| #59 | |
| #60 | const memory = new Memory({ apiKey: process.env.MEM0_API_KEY!, async: true }); |
| #61 | ``` |
| #62 | </Step> |
| #63 | </Steps> |
| #64 | </Tab> |
| #65 | </Tabs> |
| #66 | |
| #67 | ## Add memories with metadata and graph context |
| #68 | |
| #69 | <Tabs> |
| #70 | <Tab title="Python"> |
| #71 | <Steps> |
| #72 | <Step title="Record conversations with metadata"> |
| #73 | ```python |
| #74 | conversation = [ |
| #75 | {"role": "user", "content": "I'm Morgan, planning a 3-week trip to Japan in May."}, |
| #76 | {"role": "assistant", "content": "Great! I'll track dietary notes and cities you mention."}, |
| #77 | {"role": "user", "content": "Please remember I avoid shellfish and prefer boutique hotels in Tokyo."}, |
| #78 | ] |
| #79 | |
| #80 | result = await memory.add( |
| #81 | conversation, |
| #82 | user_id="traveler-42", |
| #83 | metadata={"trip": "japan-2025", "preferences": ["boutique", "no-shellfish"]}, |
| #84 | enable_graph=True, |
| #85 | run_id="planning-call-1", |
| #86 | ) |
| #87 | ``` |
| #88 | </Step> |
| #89 | </Steps> |
| #90 | </Tab> |
| #91 | <Tab title="TypeScript"> |
| #92 | <Steps> |
| #93 | <Step title="Capture context-rich memories"> |
| #94 | ```typescript |
| #95 | const conversation = [ |
| #96 | { role: "user", content: "I'm Morgan, planning a 3-week trip to Japan in May." }, |
| #97 | { role: "assistant", content: "Great! I'll track dietary notes and cities you mention." }, |
| #98 | { role: "user", content: "Please remember I avoid shellfish and love boutique hotels in Tokyo." }, |
| #99 | ]; |
| #100 | |
| #101 | const result = await memory.add(conversation, { |
| #102 | userId: "traveler-42", |
| #103 | metadata: { trip: "japan-2025", preferences: ["boutique", "no-shellfish"] }, |
| #104 | enableGraph: true, |
| #105 | runId: "planning-call-1", |
| #106 | }); |
| #107 | ``` |
| #108 | </Step> |
| #109 | </Steps> |
| #110 | </Tab> |
| #111 | </Tabs> |
| #112 | |
| #113 | <Info icon="check"> |
| #114 | Successful calls return memories tagged with the metadata you passed. In the dashboard, confirm a graph edge between “Morgan” and “Tokyo” and verify the `trip=japan-2025` tag exists. |
| #115 | </Info> |
| #116 | |
| #117 | ## Retrieve and refine |
| #118 | |
| #119 | <Tabs> |
| #120 | <Tab title="Python"> |
| #121 | <Steps> |
| #122 | <Step title="Filter by metadata + reranker"> |
| #123 | ```python |
| #124 | matches = await memory.search( |
| #125 | "Any food alerts?", |
| #126 | user_id="traveler-42", |
| #127 | filters={"metadata.trip": "japan-2025"}, |
| #128 | rerank=True, |
| #129 | include_vectors=False, |
| #130 | ) |
| #131 | ``` |
| #132 | </Step> |
| #133 | <Step title="Update a memory inline"> |
| #134 | ```python |
| #135 | await memory.update( |
| #136 | memory_id=matches["results"][0]["id"], |
| #137 | content="Morgan avoids shellfish and prefers boutique hotels in central Tokyo.", |
| #138 | ) |
| #139 | ``` |
| #140 | </Step> |
| #141 | </Steps> |
| #142 | </Tab> |
| #143 | <Tab title="TypeScript"> |
| #144 | <Steps> |
| #145 | <Step title="Search with metadata filters"> |
| #146 | ```typescript |
| #147 | const matches = await memory.search("Any food alerts?", { |
| #148 | userId: "traveler-42", |
| #149 | filters: { "metadata.trip": "japan-2025" }, |
| #150 | rerank: true, |
| #151 | includeVectors: false, |
| #152 | }); |
| #153 | ``` |
| #154 | </Step> |
| #155 | <Step title="Apply an update"> |
| #156 | ```typescript |
| #157 | await memory.update(matches.results[0].id, { |
| #158 | content: "Morgan avoids shellfish and prefers boutique hotels in central Tokyo.", |
| #159 | }); |
| #160 | ``` |
| #161 | </Step> |
| #162 | </Steps> |
| #163 | </Tab> |
| #164 | </Tabs> |
| #165 | |
| #166 | <Tip> |
| #167 | Need to pause graph writes on a per-request basis? Pass `enableGraph: false` (TypeScript) or `enable_graph=False` (Python) when latency matters more than relationship building. |
| #168 | </Tip> |
| #169 | |
| #170 | ## Clean up |
| #171 | |
| #172 | <Tabs> |
| #173 | <Tab title="Python"> |
| #174 | <Steps> |
| #175 | <Step title="Delete scoped memories"> |
| #176 | ```python |
| #177 | await memory.delete_all(user_id="traveler-42", run_id="planning-call-1") |
| #178 | ``` |
| #179 | </Step> |
| #180 | </Steps> |
| #181 | </Tab> |
| #182 | <Tab title="TypeScript"> |
| #183 | <Steps> |
| #184 | <Step title="Remove the run"> |
| #185 | ```typescript |
| #186 | await memory.deleteAll({ userId: "traveler-42", runId: "planning-call-1" }); |
| #187 | ``` |
| #188 | </Step> |
| #189 | </Steps> |
| #190 | </Tab> |
| #191 | </Tabs> |
| #192 | |
| #193 | ## Quick recovery |
| #194 | |
| #195 | - `Missing required key enableGraph`: update the SDK to `mem0ai>=0.4.0`. |
| #196 | - `Graph backend unavailable`: retry with `enableGraph=False` and inspect your graph provider status. |
| #197 | - Empty results with filters: log `filters` values and confirm metadata keys match (case-sensitive). |
| #198 | |
| #199 | <Warning> |
| #200 | Metadata keys become part of your filtering schema. Stick to lowercase snake_case (`trip_id`, `preferences`) to avoid collisions down the road. |
| #201 | </Warning> |
| #202 | |
| #203 | <CardGroup cols={2}> |
| #204 | <Card |
| #205 | title="Tune Metadata Filtering" |
| #206 | description="Layer field-level filters on top of advanced operations." |
| #207 | icon="funnel" |
| #208 | href="/open-source/features/metadata-filtering" |
| #209 | /> |
| #210 | <Card |
| #211 | title="Explore Reranker Search" |
| #212 | description="See how rerankers boost accuracy after vector + graph retrieval." |
| #213 | icon="sparkles" |
| #214 | href="/open-source/features/reranker-search" |
| #215 | /> |
| #216 | </CardGroup> |
| #217 |