[{"data":1,"prerenderedAt":2336},["ShallowReactive",2],{"docs-page-en-/usecase/memmy_knowledge_base":3,"surround-en-/usecase/memmy_knowledge_base":2320},{"id":4,"title":5,"avatar":6,"banner":6,"body":7,"category":6,"desc":2313,"description":13,"extension":2314,"lead":6,"links":6,"meta":2315,"navigation":6,"path":2316,"seo":2317,"stem":2318,"__hash__":2319},"docs/en/usecase/memmy_knowledge_base.md","Integrating MemOS Knowledge Bases into Memmy",null,{"type":8,"value":9,"toc":2301},"minimark",[10,14,17,20,23,28,31,79,84,91,93,97,100,126,129,288,291,438,441,658,665,808,810,814,818,821,1024,1027,1029,1033,1036,1347,1352,1367,1370,1372,1376,1379,1492,1495,1498,1501,1504,1513,1516,1526,1920,1923,1937,1940,1946,1948,1951,1954,1965,1971,2044,2047,2049,2053,2056,2269,2285,2287,2291,2294,2297],[11,12,13],"p",{},"Memmy is a desktop agent application that helps users continue work across DeepSeek Harness, Claude Code, Codex, and other agents. Users want agents to consult their own product manuals, project documents, and research reports. Memmy's knowledge bases serve this need: users create libraries, upload files, and select which libraries participate in conversations. Before an agent answers, retrieval runs automatically, and the answer cites its sources.",[11,15,16],{},"This feature is built entirely on MemOS knowledge base APIs. Unlike a server that calls MemOS directly, Memmy runs on many end users' computers and lets users share materials with each other. These conditions shape its integration.",[11,18,19],{},"This article follows a product team's workflow through creation, upload, retrieval, sharing, and deletion, explaining what Memmy does at each step and why. Code snippets illustrate application-server calls to public MemOS APIs; they are not a directly runnable application.",[21,22],"br",{},[24,25,27],"h2",{"id":26},"usage-scenario","Usage scenario",[11,29,30],{},"A product team follows this workflow:",[32,33,34,51,57,67,73],"ol",{},[35,36,37,41,42,46,47,50],"li",{},[38,39,40],"strong",{},"Create."," A product manager creates a Memmy knowledge base and uploads ",[43,44,45],"em",{},"MemOS Product Overview.md"," and ",[43,48,49],{},"MemOS Open Source vs Commercial.md",". Both files move from Processing to Ready.",[35,52,53,56],{},[38,54,55],{},"Share."," The manager enters a sales colleague's phone number in Sharing to share the library.",[35,58,59,62,63,66],{},[38,60,61],{},"Ask."," The colleague asks “How do MemOS Open Source and commercial editions differ?” Before answering, the agent automatically retrieves information, then cites ",[43,64,65],{},"MemOS Open Source vs Commercial",".",[35,68,69,72],{},[38,70,71],{},"Update."," The manager uploads another document. The colleague's next question can retrieve it without extra action.",[35,74,75,78],{},[38,76,77],{},"Revoke."," After the colleague changes roles, the manager revokes sharing. Subsequent questions no longer search this library.",[11,80,81],{},[43,82,83],{},"The interface images in this guide are localized illustrations of the Chinese UI.",[11,85,86],{},[87,88],"img",{"alt":89,"src":90},"Memmy knowledge base page","https://cdn.memtensor.com.cn/img/memos-best-practices-memmy-list-en-20261028_compressed.png",[21,92],{},[24,94,96],{"id":95},"architecture","Architecture",[11,98,99],{},"Memmy consists of a desktop app and a cloud service. Integration has four constraints:",[32,101,102,108,114,120],{},[35,103,104,107],{},[38,105,106],{},"Keep the API key on the server."," Desktop packages and local settings are accessible on users' computers. The MemOS API key stays in Memmy's cloud service; the desktop app authenticates to that service using the user's Memmy credentials.",[35,109,110,113],{},[38,111,112],{},"Determine ownership in the application."," MemOS knowledge bases belong to a developer project and do not identify Memmy end users. Memmy uses one MemOS project for all users. Before each call, its cloud service determines which user owns or can access each library.",[35,115,116,119],{},[38,117,118],{},"Keep settings with the account."," A user may sign in on multiple computers. Each user's Include in Retrieval setting for each library is stored in the cloud service.",[35,121,122,125],{},[38,123,124],{},"Keep cloud credentials away from the agent."," Agents call tools and read local files. The knowledge base hook uses only a local-service access token; the retrieval path does not pass cloud credentials to the agent.",[11,127,128],{},"The result is three layers: the desktop communicates with Memmy's cloud service, which calls MemOS on the user's behalf.",[130,131,136],"pre",{"className":132,"code":133,"language":134,"meta":135,"style":135},"language-mermaid shiki shiki-themes material-theme-lighter github-light-high-contrast github-dark-default","flowchart LR\n    subgraph Desktop[\"Memmy Desktop\"]\n        direction TB\n        Page[\"Knowledge Base Page\"]\n        Hook[\"Knowledge Base Hook\"]\n        Local[\"Local Service\"]\n        Page --> Local\n        Hook --> Local\n    end\n    subgraph Service[\"Memmy Cloud Service\"]\n        direction TB\n        Auth[\"Identify Signed-In User\"]\n        Biz[\"Ownership · Sharing · Retrieval Settings\"]\n        Scope[\"Map Knowledge Base IDs\u003Cbr/>Calculate Retrieval Scope\"]\n        Auth --> Biz --> Scope\n    end\n    subgraph Cloud[\"MemOS\"]\n        direction TB\n        Store[\"Knowledge Bases and Files\"]\n        Index[\"Parse · Chunk · Index\"]\n        Search[\"Knowledge Retrieval\"]\n        Store --> Index --> Search\n    end\n    Desktop -->|Memmy Credentials| Service\n    Service -->|MemOS API Key| Cloud\n","mermaid","",[137,138,139,148,154,160,166,172,178,184,190,196,202,207,213,219,225,231,236,242,247,253,259,265,271,276,282],"code",{"__ignoreMap":135},[140,141,144],"span",{"class":142,"line":143},"line",1,[140,145,147],{"class":146},"s5ojA","flowchart LR\n",[140,149,151],{"class":142,"line":150},2,[140,152,153],{"class":146},"    subgraph Desktop[\"Memmy Desktop\"]\n",[140,155,157],{"class":142,"line":156},3,[140,158,159],{"class":146},"        direction TB\n",[140,161,163],{"class":142,"line":162},4,[140,164,165],{"class":146},"        Page[\"Knowledge Base Page\"]\n",[140,167,169],{"class":142,"line":168},5,[140,170,171],{"class":146},"        Hook[\"Knowledge Base Hook\"]\n",[140,173,175],{"class":142,"line":174},6,[140,176,177],{"class":146},"        Local[\"Local Service\"]\n",[140,179,181],{"class":142,"line":180},7,[140,182,183],{"class":146},"        Page --> Local\n",[140,185,187],{"class":142,"line":186},8,[140,188,189],{"class":146},"        Hook --> Local\n",[140,191,193],{"class":142,"line":192},9,[140,194,195],{"class":146},"    end\n",[140,197,199],{"class":142,"line":198},10,[140,200,201],{"class":146},"    subgraph Service[\"Memmy Cloud Service\"]\n",[140,203,205],{"class":142,"line":204},11,[140,206,159],{"class":146},[140,208,210],{"class":142,"line":209},12,[140,211,212],{"class":146},"        Auth[\"Identify Signed-In User\"]\n",[140,214,216],{"class":142,"line":215},13,[140,217,218],{"class":146},"        Biz[\"Ownership · Sharing · Retrieval Settings\"]\n",[140,220,222],{"class":142,"line":221},14,[140,223,224],{"class":146},"        Scope[\"Map Knowledge Base IDs\u003Cbr/>Calculate Retrieval Scope\"]\n",[140,226,228],{"class":142,"line":227},15,[140,229,230],{"class":146},"        Auth --> Biz --> Scope\n",[140,232,234],{"class":142,"line":233},16,[140,235,195],{"class":146},[140,237,239],{"class":142,"line":238},17,[140,240,241],{"class":146},"    subgraph Cloud[\"MemOS\"]\n",[140,243,245],{"class":142,"line":244},18,[140,246,159],{"class":146},[140,248,250],{"class":142,"line":249},19,[140,251,252],{"class":146},"        Store[\"Knowledge Bases and Files\"]\n",[140,254,256],{"class":142,"line":255},20,[140,257,258],{"class":146},"        Index[\"Parse · Chunk · Index\"]\n",[140,260,262],{"class":142,"line":261},21,[140,263,264],{"class":146},"        Search[\"Knowledge Retrieval\"]\n",[140,266,268],{"class":142,"line":267},22,[140,269,270],{"class":146},"        Store --> Index --> Search\n",[140,272,274],{"class":142,"line":273},23,[140,275,195],{"class":146},[140,277,279],{"class":142,"line":278},24,[140,280,281],{"class":146},"    Desktop -->|Memmy Credentials| Service\n",[140,283,285],{"class":142,"line":284},25,[140,286,287],{"class":146},"    Service -->|MemOS API Key| Cloud\n",[11,289,290],{},"The responsibilities for each feature are as follows. Features without a corresponding MemOS API are implemented entirely in Memmy's application layer.",[292,293,294,313],"table",{},[295,296,297],"thead",{},[298,299,300,304,307,310],"tr",{},[301,302,303],"th",{},"Memmy feature",[301,305,306],{},"Memmy cloud service",[301,308,309],{},"MemOS",[301,311,312],{},"MemOS API",[314,315,316,333,349,365,378,390,406,418],"tbody",{},[298,317,318,322,325,328],{},[319,320,321],"td",{},"Create a knowledge base",[319,323,324],{},"Store the mapping between Memmy and MemOS knowledge base IDs",[319,326,327],{},"Create the knowledge base",[319,329,330],{},[137,331,332],{},"/create/knowledgebase",[298,334,335,338,341,344],{},[319,336,337],{},"Upload files",[319,339,340],{},"Verify ownership and map the knowledge base ID",[319,342,343],{},"Store files and asynchronously parse, chunk, and index them",[319,345,346],{},[137,347,348],{},"/add/knowledgebase-file",[298,350,351,354,357,360],{},[319,352,353],{},"File list and processing status",[319,355,356],{},"Filter by folder",[319,358,359],{},"Return file details and processing status",[319,361,362],{},[137,363,364],{},"/get/knowledgebase-file",[298,366,367,370,373,376],{},[319,368,369],{},"Rename and folders",[319,371,372],{},"Store names and directory structure",[319,374,375],{},"—",[319,377,375],{},[298,379,380,383,386,388],{},[319,381,382],{},"Include in Retrieval",[319,384,385],{},"Store each user's switch for each library",[319,387,375],{},[319,389,375],{},[298,391,392,395,398,401],{},[319,393,394],{},"Search before an agent answers",[319,396,397],{},"Calculate scope and recheck results",[319,399,400],{},"Search selected knowledge bases",[319,402,403],{},[137,404,405],{},"/search/memory",[298,407,408,411,414,416],{},[319,409,410],{},"Share a knowledge base",[319,412,413],{},"Maintain memberships",[319,415,375],{},[319,417,375],{},[298,419,420,423,426,429],{},[319,421,422],{},"Delete a library or file",[319,424,425],{},"Remove it from the application first",[319,427,428],{},"Clean up libraries and files in the background",[319,430,431,434,435],{},[137,432,433],{},"/delete/knowledgebase",", ",[137,436,437],{},"/delete/knowledgebase-file",[11,439,440],{},"All MemOS calls pass through one entry point. The API key appears only here:",[130,442,446],{"className":443,"code":444,"language":445,"meta":135,"style":135},"language-python shiki shiki-themes material-theme-lighter github-light-high-contrast github-dark-default","MEMOS_BASE_URL = \"https://memos.memtensor.cn/api/openmem/v1\"\nMEMOS_API_KEY = os.environ[\"MEMOS_API_KEY\"]  # Configure only in the cloud service\n\n\ndef memos_post(path, body):\n    resp = requests.post(\n        MEMOS_BASE_URL + path,\n        headers={\"Authorization\": f\"Token {MEMOS_API_KEY}\"},\n        json=body,\n    )\n    return resp.json()[\"data\"]\n","python",[137,447,448,469,503,509,513,539,559,574,614,626,631],{"__ignoreMap":135},[140,449,450,454,458,462,466],{"class":142,"line":143},[140,451,453],{"class":452},"sZaqd","MEMOS_BASE_URL",[140,455,457],{"class":456},"saN0X"," =",[140,459,461],{"class":460},"sjUum"," \"",[140,463,465],{"class":464},"sp1uZ","https://memos.memtensor.cn/api/openmem/v1",[140,467,468],{"class":460},"\"\n",[140,470,471,474,476,479,482,486,489,492,494,496,499],{"class":142,"line":150},[140,472,473],{"class":452},"MEMOS_API_KEY",[140,475,457],{"class":456},[140,477,478],{"class":146}," os",[140,480,66],{"class":481},"suWxN",[140,483,485],{"class":484},"s5qkx","environ",[140,487,488],{"class":481},"[",[140,490,491],{"class":460},"\"",[140,493,473],{"class":464},[140,495,491],{"class":460},[140,497,498],{"class":481},"]",[140,500,502],{"class":501},"sfVK4","  # Configure only in the cloud service\n",[140,504,505],{"class":142,"line":156},[140,506,508],{"emptyLinePlaceholder":507},true,"\n",[140,510,511],{"class":142,"line":162},[140,512,508],{"emptyLinePlaceholder":507},[140,514,515,519,523,526,530,533,536],{"class":142,"line":168},[140,516,518],{"class":517},"sZ6T4","def",[140,520,522],{"class":521},"sbcIq"," memos_post",[140,524,525],{"class":481},"(",[140,527,529],{"class":528},"sM07a","path",[140,531,532],{"class":481},",",[140,534,535],{"class":528}," body",[140,537,538],{"class":481},"):\n",[140,540,541,544,547,550,552,556],{"class":142,"line":174},[140,542,543],{"class":146},"    resp ",[140,545,546],{"class":456},"=",[140,548,549],{"class":146}," requests",[140,551,66],{"class":481},[140,553,555],{"class":554},"sa-2m","post",[140,557,558],{"class":481},"(\n",[140,560,561,565,568,571],{"class":142,"line":180},[140,562,564],{"class":563},"svxCd","        MEMOS_BASE_URL",[140,566,567],{"class":456}," +",[140,569,570],{"class":554}," path",[140,572,573],{"class":481},",\n",[140,575,576,580,582,585,587,590,592,595,598,601,604,606,609,611],{"class":142,"line":186},[140,577,579],{"class":578},"sp4zP","        headers",[140,581,546],{"class":456},[140,583,584],{"class":481},"{",[140,586,491],{"class":460},[140,588,589],{"class":464},"Authorization",[140,591,491],{"class":460},[140,593,594],{"class":481},":",[140,596,597],{"class":517}," f",[140,599,600],{"class":464},"\"Token ",[140,602,584],{"class":603},"scyET",[140,605,473],{"class":563},[140,607,608],{"class":603},"}",[140,610,491],{"class":464},[140,612,613],{"class":481},"},\n",[140,615,616,619,621,624],{"class":142,"line":192},[140,617,618],{"class":578},"        json",[140,620,546],{"class":456},[140,622,623],{"class":554},"body",[140,625,573],{"class":481},[140,627,628],{"class":142,"line":198},[140,629,630],{"class":481},"    )\n",[140,632,633,637,640,642,645,648,650,653,655],{"class":142,"line":204},[140,634,636],{"class":635},"sBMTB","    return",[140,638,639],{"class":146}," resp",[140,641,66],{"class":481},[140,643,644],{"class":554},"json",[140,646,647],{"class":481},"()[",[140,649,491],{"class":460},[140,651,652],{"class":464},"data",[140,654,491],{"class":460},[140,656,657],{"class":481},"]\n",[11,659,660,661,664],{},"The remaining examples call MemOS through ",[137,662,663],{},"memos_post",". Memmy's own data is represented with dictionaries below; a real implementation can use a database. Folder data follows a similar structure and is omitted.",[130,666,668],{"className":443,"code":667,"language":445,"meta":135,"style":135},"knowledge_bases = {}  # Memmy KB ID -> {\"memos_kb_id\", \"owner_id\", \"name\"}\nmembers = {}          # Memmy KB ID -> set of recipient user IDs\nrecall_selected = {}  # (user ID, Memmy KB ID) -> included in retrieval\n\n\ndef can_access(user_id, kb_id):\n    # The owner or a recipient\n    owner_id = knowledge_bases[kb_id][\"owner_id\"]\n    return user_id == owner_id or user_id in members.get(kb_id, set())\n",[137,669,670,683,695,707,711,715,734,739,766],{"__ignoreMap":135},[140,671,672,675,677,680],{"class":142,"line":143},[140,673,674],{"class":146},"knowledge_bases ",[140,676,546],{"class":456},[140,678,679],{"class":481}," {}",[140,681,682],{"class":501},"  # Memmy KB ID -> {\"memos_kb_id\", \"owner_id\", \"name\"}\n",[140,684,685,688,690,692],{"class":142,"line":150},[140,686,687],{"class":146},"members ",[140,689,546],{"class":456},[140,691,679],{"class":481},[140,693,694],{"class":501},"          # Memmy KB ID -> set of recipient user IDs\n",[140,696,697,700,702,704],{"class":142,"line":156},[140,698,699],{"class":146},"recall_selected ",[140,701,546],{"class":456},[140,703,679],{"class":481},[140,705,706],{"class":501},"  # (user ID, Memmy KB ID) -> included in retrieval\n",[140,708,709],{"class":142,"line":162},[140,710,508],{"emptyLinePlaceholder":507},[140,712,713],{"class":142,"line":168},[140,714,508],{"emptyLinePlaceholder":507},[140,716,717,719,722,724,727,729,732],{"class":142,"line":174},[140,718,518],{"class":517},[140,720,721],{"class":521}," can_access",[140,723,525],{"class":481},[140,725,726],{"class":528},"user_id",[140,728,532],{"class":481},[140,730,731],{"class":528}," kb_id",[140,733,538],{"class":481},[140,735,736],{"class":142,"line":180},[140,737,738],{"class":501},"    # The owner or a recipient\n",[140,740,741,744,746,749,751,754,757,759,762,764],{"class":142,"line":186},[140,742,743],{"class":146},"    owner_id ",[140,745,546],{"class":456},[140,747,748],{"class":146}," knowledge_bases",[140,750,488],{"class":481},[140,752,753],{"class":146},"kb_id",[140,755,756],{"class":481},"][",[140,758,491],{"class":460},[140,760,761],{"class":464},"owner_id",[140,763,491],{"class":460},[140,765,657],{"class":481},[140,767,768,770,773,776,779,782,784,787,790,792,795,797,799,801,805],{"class":142,"line":192},[140,769,636],{"class":635},[140,771,772],{"class":146}," user_id ",[140,774,775],{"class":456},"==",[140,777,778],{"class":146}," owner_id ",[140,780,781],{"class":456},"or",[140,783,772],{"class":146},[140,785,786],{"class":456},"in",[140,788,789],{"class":146}," members",[140,791,66],{"class":481},[140,793,794],{"class":554},"get",[140,796,525],{"class":481},[140,798,753],{"class":554},[140,800,532],{"class":481},[140,802,804],{"class":803},"skqQ-"," set",[140,806,807],{"class":481},"())\n",[21,809],{},[24,811,813],{"id":812},"create-and-upload","Create and upload",[815,816,321],"h3",{"id":817},"create-a-knowledge-base",[11,819,820],{},"When a user submits a name, the cloud service creates the MemOS knowledge base, then stores the ID mapping:",[130,822,824],{"className":443,"code":823,"language":445,"meta":135,"style":135},"def create_knowledge_base(owner_id, name):\n    data = memos_post(\"/create/knowledgebase\", {\"knowledgebase_name\": name})\n\n    kb_id = str(uuid.uuid4())  # Memmy KB ID returned to the desktop app\n    knowledge_bases[kb_id] = {\n        \"memos_kb_id\": data[\"id\"],  # MemOS KB ID stays in the cloud service\n        \"owner_id\": owner_id,\n        \"name\": name,\n    }\n    recall_selected[(owner_id, kb_id)] = True  # Included by default\n    return kb_id\n",[137,825,826,844,880,884,910,926,956,971,986,991,1017],{"__ignoreMap":135},[140,827,828,830,833,835,837,839,842],{"class":142,"line":143},[140,829,518],{"class":517},[140,831,832],{"class":521}," create_knowledge_base",[140,834,525],{"class":481},[140,836,761],{"class":528},[140,838,532],{"class":481},[140,840,841],{"class":528}," name",[140,843,538],{"class":481},[140,845,846,849,851,853,855,857,859,861,863,866,868,871,873,875,877],{"class":142,"line":150},[140,847,848],{"class":146},"    data ",[140,850,546],{"class":456},[140,852,522],{"class":554},[140,854,525],{"class":481},[140,856,491],{"class":460},[140,858,332],{"class":464},[140,860,491],{"class":460},[140,862,532],{"class":481},[140,864,865],{"class":481}," {",[140,867,491],{"class":460},[140,869,870],{"class":464},"knowledgebase_name",[140,872,491],{"class":460},[140,874,594],{"class":481},[140,876,841],{"class":554},[140,878,879],{"class":481},"})\n",[140,881,882],{"class":142,"line":156},[140,883,508],{"emptyLinePlaceholder":507},[140,885,886,889,891,894,896,899,901,904,907],{"class":142,"line":162},[140,887,888],{"class":146},"    kb_id ",[140,890,546],{"class":456},[140,892,893],{"class":803}," str",[140,895,525],{"class":481},[140,897,898],{"class":554},"uuid",[140,900,66],{"class":481},[140,902,903],{"class":554},"uuid4",[140,905,906],{"class":481},"())",[140,908,909],{"class":501},"  # Memmy KB ID returned to the desktop app\n",[140,911,912,915,917,919,921,923],{"class":142,"line":168},[140,913,914],{"class":146},"    knowledge_bases",[140,916,488],{"class":481},[140,918,753],{"class":146},[140,920,498],{"class":481},[140,922,457],{"class":456},[140,924,925],{"class":481}," {\n",[140,927,928,931,934,936,938,941,943,945,948,950,953],{"class":142,"line":174},[140,929,930],{"class":460},"        \"",[140,932,933],{"class":464},"memos_kb_id",[140,935,491],{"class":460},[140,937,594],{"class":481},[140,939,940],{"class":146}," data",[140,942,488],{"class":481},[140,944,491],{"class":460},[140,946,947],{"class":464},"id",[140,949,491],{"class":460},[140,951,952],{"class":481},"],",[140,954,955],{"class":501},"  # MemOS KB ID stays in the cloud service\n",[140,957,958,960,962,964,966,969],{"class":142,"line":180},[140,959,930],{"class":460},[140,961,761],{"class":464},[140,963,491],{"class":460},[140,965,594],{"class":481},[140,967,968],{"class":146}," owner_id",[140,970,573],{"class":481},[140,972,973,975,978,980,982,984],{"class":142,"line":186},[140,974,930],{"class":460},[140,976,977],{"class":464},"name",[140,979,491],{"class":460},[140,981,594],{"class":481},[140,983,841],{"class":146},[140,985,573],{"class":481},[140,987,988],{"class":142,"line":192},[140,989,990],{"class":481},"    }\n",[140,992,993,996,999,1001,1003,1005,1008,1010,1014],{"class":142,"line":198},[140,994,995],{"class":146},"    recall_selected",[140,997,998],{"class":481},"[(",[140,1000,761],{"class":146},[140,1002,532],{"class":481},[140,1004,731],{"class":146},[140,1006,1007],{"class":481},")]",[140,1009,457],{"class":456},[140,1011,1013],{"class":1012},"smHB8"," True",[140,1015,1016],{"class":501},"  # Included by default\n",[140,1018,1019,1021],{"class":142,"line":204},[140,1020,636],{"class":635},[140,1022,1023],{"class":146}," kb_id\n",[11,1025,1026],{},"Subsequent desktop requests carry only the Memmy knowledge base ID. The cloud service does not accept client-supplied MemOS knowledge base IDs, keeping them outside client-controlled input. New libraries are included in retrieval by default. Renaming changes only the name stored in Memmy and makes no MemOS call.",[21,1028],{},[815,1030,1032],{"id":1031},"upload-and-manage-files","Upload and manage files",[11,1034,1035],{},"Before upload, the desktop and cloud service validate files against MemOS limits: PDF, DOCX, DOC, TXT, JSON, MD, or XML, with a maximum of 100 MB per file. After confirming that the caller is the owner, the service maps the Memmy ID to the MemOS ID and submits the file:",[130,1037,1039],{"className":443,"code":1038,"language":445,"meta":135,"style":135},"def upload_file(user_id, kb_id, filename, content):\n    kb = knowledge_bases[kb_id]\n    if kb[\"owner_id\"] != user_id:\n        raise PermissionError(\"Only the owner can upload files\")\n\n    mime_type, _ = mimetypes.guess_type(filename)\n    encoded = base64.b64encode(content).decode(\"ascii\")\n    files = memos_post(\"/add/knowledgebase-file\", {\n        \"knowledgebase_id\": kb[\"memos_kb_id\"],  # Map to the MemOS KB ID\n        \"file\": [{\n            \"name\": filename,\n            \"content\": f\"data:{mime_type};base64,{encoded}\",\n        }],\n    })\n    return files[0][\"status\"]  # Usually running while MemOS processes the file\n",[137,1040,1041,1068,1083,1110,1130,1134,1161,1198,1219,1245,1259,1274,1310,1315,1320],{"__ignoreMap":135},[140,1042,1043,1045,1048,1050,1052,1054,1056,1058,1061,1063,1066],{"class":142,"line":143},[140,1044,518],{"class":517},[140,1046,1047],{"class":521}," upload_file",[140,1049,525],{"class":481},[140,1051,726],{"class":528},[140,1053,532],{"class":481},[140,1055,731],{"class":528},[140,1057,532],{"class":481},[140,1059,1060],{"class":528}," filename",[140,1062,532],{"class":481},[140,1064,1065],{"class":528}," content",[140,1067,538],{"class":481},[140,1069,1070,1073,1075,1077,1079,1081],{"class":142,"line":150},[140,1071,1072],{"class":146},"    kb ",[140,1074,546],{"class":456},[140,1076,748],{"class":146},[140,1078,488],{"class":481},[140,1080,753],{"class":146},[140,1082,657],{"class":481},[140,1084,1085,1088,1091,1093,1095,1097,1099,1101,1104,1107],{"class":142,"line":156},[140,1086,1087],{"class":635},"    if",[140,1089,1090],{"class":146}," kb",[140,1092,488],{"class":481},[140,1094,491],{"class":460},[140,1096,761],{"class":464},[140,1098,491],{"class":460},[140,1100,498],{"class":481},[140,1102,1103],{"class":456}," !=",[140,1105,1106],{"class":146}," user_id",[140,1108,1109],{"class":481},":\n",[140,1111,1112,1115,1118,1120,1122,1125,1127],{"class":142,"line":162},[140,1113,1114],{"class":635},"        raise",[140,1116,1117],{"class":803}," PermissionError",[140,1119,525],{"class":481},[140,1121,491],{"class":460},[140,1123,1124],{"class":464},"Only the owner can upload files",[140,1126,491],{"class":460},[140,1128,1129],{"class":481},")\n",[140,1131,1132],{"class":142,"line":168},[140,1133,508],{"emptyLinePlaceholder":507},[140,1135,1136,1139,1141,1144,1146,1149,1151,1154,1156,1159],{"class":142,"line":174},[140,1137,1138],{"class":146},"    mime_type",[140,1140,532],{"class":481},[140,1142,1143],{"class":146}," _ ",[140,1145,546],{"class":456},[140,1147,1148],{"class":146}," mimetypes",[140,1150,66],{"class":481},[140,1152,1153],{"class":554},"guess_type",[140,1155,525],{"class":481},[140,1157,1158],{"class":554},"filename",[140,1160,1129],{"class":481},[140,1162,1163,1166,1168,1171,1173,1176,1178,1181,1184,1187,1189,1191,1194,1196],{"class":142,"line":180},[140,1164,1165],{"class":146},"    encoded ",[140,1167,546],{"class":456},[140,1169,1170],{"class":146}," base64",[140,1172,66],{"class":481},[140,1174,1175],{"class":554},"b64encode",[140,1177,525],{"class":481},[140,1179,1180],{"class":554},"content",[140,1182,1183],{"class":481},").",[140,1185,1186],{"class":554},"decode",[140,1188,525],{"class":481},[140,1190,491],{"class":460},[140,1192,1193],{"class":464},"ascii",[140,1195,491],{"class":460},[140,1197,1129],{"class":481},[140,1199,1200,1203,1205,1207,1209,1211,1213,1215,1217],{"class":142,"line":186},[140,1201,1202],{"class":146},"    files ",[140,1204,546],{"class":456},[140,1206,522],{"class":554},[140,1208,525],{"class":481},[140,1210,491],{"class":460},[140,1212,348],{"class":464},[140,1214,491],{"class":460},[140,1216,532],{"class":481},[140,1218,925],{"class":481},[140,1220,1221,1223,1226,1228,1230,1232,1234,1236,1238,1240,1242],{"class":142,"line":192},[140,1222,930],{"class":460},[140,1224,1225],{"class":464},"knowledgebase_id",[140,1227,491],{"class":460},[140,1229,594],{"class":481},[140,1231,1090],{"class":554},[140,1233,488],{"class":481},[140,1235,491],{"class":460},[140,1237,933],{"class":464},[140,1239,491],{"class":460},[140,1241,952],{"class":481},[140,1243,1244],{"class":501},"  # Map to the MemOS KB ID\n",[140,1246,1247,1249,1252,1254,1256],{"class":142,"line":198},[140,1248,930],{"class":460},[140,1250,1251],{"class":464},"file",[140,1253,491],{"class":460},[140,1255,594],{"class":481},[140,1257,1258],{"class":481}," [{\n",[140,1260,1261,1264,1266,1268,1270,1272],{"class":142,"line":204},[140,1262,1263],{"class":460},"            \"",[140,1265,977],{"class":464},[140,1267,491],{"class":460},[140,1269,594],{"class":481},[140,1271,1060],{"class":554},[140,1273,573],{"class":481},[140,1275,1276,1278,1280,1282,1284,1286,1289,1291,1294,1296,1299,1301,1304,1306,1308],{"class":142,"line":209},[140,1277,1263],{"class":460},[140,1279,1180],{"class":464},[140,1281,491],{"class":460},[140,1283,594],{"class":481},[140,1285,597],{"class":517},[140,1287,1288],{"class":464},"\"data:",[140,1290,584],{"class":603},[140,1292,1293],{"class":554},"mime_type",[140,1295,608],{"class":603},[140,1297,1298],{"class":464},";base64,",[140,1300,584],{"class":603},[140,1302,1303],{"class":554},"encoded",[140,1305,608],{"class":603},[140,1307,491],{"class":464},[140,1309,573],{"class":481},[140,1311,1312],{"class":142,"line":215},[140,1313,1314],{"class":481},"        }],\n",[140,1316,1317],{"class":142,"line":221},[140,1318,1319],{"class":481},"    })\n",[140,1321,1322,1324,1327,1329,1333,1335,1337,1340,1342,1344],{"class":142,"line":227},[140,1323,636],{"class":635},[140,1325,1326],{"class":146}," files",[140,1328,488],{"class":481},[140,1330,1332],{"class":1331},"sJNII","0",[140,1334,756],{"class":481},[140,1336,491],{"class":460},[140,1338,1339],{"class":464},"status",[140,1341,491],{"class":460},[140,1343,498],{"class":481},[140,1345,1346],{"class":501},"  # Usually running while MemOS processes the file\n",[11,1348,1349,1350,66],{},"For larger files, place the file at an address MemOS can access and pass the URL in ",[137,1351,1180],{},[11,1353,1354,1355,1358,1359,1362,1363,1366],{},"MemOS asynchronously parses, chunks, and indexes the file. Status moves from ",[137,1356,1357],{},"running"," to ",[137,1360,1361],{},"completed",", or to ",[137,1364,1365],{},"failed"," on failure. Only completed content enters retrieval results. Memmy displays Processing, Ready, or Failed, refreshing periodically while files are processing.",[11,1368,1369],{},"Memmy does not duplicate filenames, processing status, or other file details: opening a library queries MemOS directly, providing one status source. Memmy stores only the additional directory structure. MemOS knowledge base files are flat; the cloud service records folder hierarchy and each file's folder, then filters accordingly. Moving a file changes the mapping without uploading or parsing it again.",[21,1371],{},[24,1373,1375],{"id":1374},"retrieval-before-the-agent-answers","Retrieval before the agent answers",[11,1377,1378],{},"User isolation ultimately depends on the knowledge base IDs submitted for every search. An incorrect ID can expose another user's materials. The flow is:",[130,1380,1382],{"className":132,"code":1381,"language":134,"meta":135,"style":135},"sequenceDiagram\n    participant User as User\n    participant Hook as Knowledge Base Hook\n    participant Service as Memmy Cloud Service\n    participant MemOS as MemOS\n    participant Agent as Agent\n\n    User->>Hook: Ask a question\n    Note over Hook: Triggered before the agent runs\n    Hook->>Service: Current question\n    Service->>Service: Calculate retrieval scope\n    alt Empty scope\n        Service-->>Hook: Return without calling MemOS\n    else Nonempty scope\n        Service->>MemOS: /search/memory (knowledgebase_ids = scope)\n        MemOS-->>Service: Knowledge base snippets\n        Service->>Service: Recheck scope, discard results if changed\n        Service-->>Hook: Snippets and sources\n    end\n    Hook->>Agent: Append materials to this run's system prompt\n    Agent-->>User: Answer with source citations\n    Hook->>Hook: Remove injected content after the run\n",[137,1383,1384,1389,1394,1399,1404,1409,1414,1418,1423,1428,1433,1438,1443,1448,1453,1458,1463,1468,1473,1477,1482,1487],{"__ignoreMap":135},[140,1385,1386],{"class":142,"line":143},[140,1387,1388],{"class":146},"sequenceDiagram\n",[140,1390,1391],{"class":142,"line":150},[140,1392,1393],{"class":146},"    participant User as User\n",[140,1395,1396],{"class":142,"line":156},[140,1397,1398],{"class":146},"    participant Hook as Knowledge Base Hook\n",[140,1400,1401],{"class":142,"line":162},[140,1402,1403],{"class":146},"    participant Service as Memmy Cloud Service\n",[140,1405,1406],{"class":142,"line":168},[140,1407,1408],{"class":146},"    participant MemOS as MemOS\n",[140,1410,1411],{"class":142,"line":174},[140,1412,1413],{"class":146},"    participant Agent as Agent\n",[140,1415,1416],{"class":142,"line":180},[140,1417,508],{"emptyLinePlaceholder":507},[140,1419,1420],{"class":142,"line":186},[140,1421,1422],{"class":146},"    User->>Hook: Ask a question\n",[140,1424,1425],{"class":142,"line":192},[140,1426,1427],{"class":146},"    Note over Hook: Triggered before the agent runs\n",[140,1429,1430],{"class":142,"line":198},[140,1431,1432],{"class":146},"    Hook->>Service: Current question\n",[140,1434,1435],{"class":142,"line":204},[140,1436,1437],{"class":146},"    Service->>Service: Calculate retrieval scope\n",[140,1439,1440],{"class":142,"line":209},[140,1441,1442],{"class":146},"    alt Empty scope\n",[140,1444,1445],{"class":142,"line":215},[140,1446,1447],{"class":146},"        Service-->>Hook: Return without calling MemOS\n",[140,1449,1450],{"class":142,"line":221},[140,1451,1452],{"class":146},"    else Nonempty scope\n",[140,1454,1455],{"class":142,"line":227},[140,1456,1457],{"class":146},"        Service->>MemOS: /search/memory (knowledgebase_ids = scope)\n",[140,1459,1460],{"class":142,"line":233},[140,1461,1462],{"class":146},"        MemOS-->>Service: Knowledge base snippets\n",[140,1464,1465],{"class":142,"line":238},[140,1466,1467],{"class":146},"        Service->>Service: Recheck scope, discard results if changed\n",[140,1469,1470],{"class":142,"line":244},[140,1471,1472],{"class":146},"        Service-->>Hook: Snippets and sources\n",[140,1474,1475],{"class":142,"line":249},[140,1476,195],{"class":146},[140,1478,1479],{"class":142,"line":255},[140,1480,1481],{"class":146},"    Hook->>Agent: Append materials to this run's system prompt\n",[140,1483,1484],{"class":142,"line":261},[140,1485,1486],{"class":146},"    Agent-->>User: Answer with source citations\n",[140,1488,1489],{"class":142,"line":267},[140,1490,1491],{"class":146},"    Hook->>Hook: Remove injected content after the run\n",[11,1493,1494],{},"The hook automatically retrieves before the agent runs; the agent calls no knowledge base APIs itself. After Include in Retrieval is enabled, users do not need to request a search explicitly. The trade-off is one search per turn, including questions unrelated to the materials.",[11,1496,1497],{},"The hook appends materials to the current run's system prompt, then removes them when the run ends. Each new question triggers fresh retrieval, so materials do not accumulate over multiple turns.",[11,1499,1500],{},"The cloud service checks scope before and after the MemOS call: first to select libraries, then to confirm that access did not change during retrieval.",[11,1502,1503],{},"The retrieval scope is the intersection of:",[1505,1506,1507,1510],"ul",{},[35,1508,1509],{},"Libraries the user has enabled for retrieval.",[35,1511,1512],{},"Libraries the user can currently access, including owned and shared libraries.",[11,1514,1515],{},"With an empty intersection, the service skips the MemOS call. In the example, if the colleague owns one library and receives the manager's shared library, both enabled, the scope contains both MemOS IDs. Disabling retrieval for the personal library leaves only the shared one.",[11,1517,1518,1521,1522,1525],{},[137,1519,1520],{},"knowledgebase_ids"," is the final permission boundary in this path. MemOS searches no knowledge base by default; only explicitly supplied IDs enter scope. It also accepts ",[137,1523,1524],{},"all",", which searches every library in the project, including other users' libraries. Memmy recomputes scope on every search, supplies an explicit ID list, and derives it from server-side state.",[130,1527,1529],{"className":443,"code":1528,"language":445,"meta":135,"style":135},"def recall_scope(user_id):\n    return [\n        kb[\"memos_kb_id\"]\n        for kb_id, kb in knowledge_bases.items()\n        if can_access(user_id, kb_id)                     # Owned and shared\n        and recall_selected.get((user_id, kb_id), False)  # Retrieval enabled\n    ]\n\n\ndef recall(user_id, query):\n    scope = recall_scope(user_id)\n    if not scope:\n        return []  # Skip MemOS\n\n    data = memos_post(\"/search/memory\", {\n        \"user_id\": f\"kb-reader-{user_id}\",  # Retrieval-only identifier\n        \"query\": query,\n        \"knowledgebase_ids\": scope,         # Explicit IDs, never all\n    })\n\n    if recall_scope(user_id) != scope:  # Discard results if scope changed\n        return []\n\n    return [\n        {\"title\": item[\"memory_key\"], \"content\": item[\"memory_value\"]}\n        for item in data[\"memory_detail_list\"]\n    ]\n",[137,1530,1531,1544,1551,1566,1590,1611,1643,1648,1652,1656,1674,1689,1701,1712,1716,1736,1764,1779,1796,1800,1804,1825,1832,1836,1842,1892,1915],{"__ignoreMap":135},[140,1532,1533,1535,1538,1540,1542],{"class":142,"line":143},[140,1534,518],{"class":517},[140,1536,1537],{"class":521}," recall_scope",[140,1539,525],{"class":481},[140,1541,726],{"class":528},[140,1543,538],{"class":481},[140,1545,1546,1548],{"class":142,"line":150},[140,1547,636],{"class":635},[140,1549,1550],{"class":481}," [\n",[140,1552,1553,1556,1558,1560,1562,1564],{"class":142,"line":156},[140,1554,1555],{"class":146},"        kb",[140,1557,488],{"class":481},[140,1559,491],{"class":460},[140,1561,933],{"class":464},[140,1563,491],{"class":460},[140,1565,657],{"class":481},[140,1567,1568,1571,1573,1575,1578,1580,1582,1584,1587],{"class":142,"line":162},[140,1569,1570],{"class":635},"        for",[140,1572,731],{"class":146},[140,1574,532],{"class":481},[140,1576,1577],{"class":146}," kb ",[140,1579,786],{"class":635},[140,1581,748],{"class":146},[140,1583,66],{"class":481},[140,1585,1586],{"class":554},"items",[140,1588,1589],{"class":481},"()\n",[140,1591,1592,1595,1597,1599,1601,1603,1605,1608],{"class":142,"line":168},[140,1593,1594],{"class":635},"        if",[140,1596,721],{"class":554},[140,1598,525],{"class":481},[140,1600,726],{"class":554},[140,1602,532],{"class":481},[140,1604,731],{"class":554},[140,1606,1607],{"class":481},")",[140,1609,1610],{"class":501},"                     # Owned and shared\n",[140,1612,1613,1616,1619,1621,1623,1626,1628,1630,1632,1635,1638,1640],{"class":142,"line":174},[140,1614,1615],{"class":456},"        and",[140,1617,1618],{"class":146}," recall_selected",[140,1620,66],{"class":481},[140,1622,794],{"class":554},[140,1624,1625],{"class":481},"((",[140,1627,726],{"class":554},[140,1629,532],{"class":481},[140,1631,731],{"class":554},[140,1633,1634],{"class":481},"),",[140,1636,1637],{"class":1012}," False",[140,1639,1607],{"class":481},[140,1641,1642],{"class":501},"  # Retrieval enabled\n",[140,1644,1645],{"class":142,"line":180},[140,1646,1647],{"class":481},"    ]\n",[140,1649,1650],{"class":142,"line":186},[140,1651,508],{"emptyLinePlaceholder":507},[140,1653,1654],{"class":142,"line":192},[140,1655,508],{"emptyLinePlaceholder":507},[140,1657,1658,1660,1663,1665,1667,1669,1672],{"class":142,"line":198},[140,1659,518],{"class":517},[140,1661,1662],{"class":521}," recall",[140,1664,525],{"class":481},[140,1666,726],{"class":528},[140,1668,532],{"class":481},[140,1670,1671],{"class":528}," query",[140,1673,538],{"class":481},[140,1675,1676,1679,1681,1683,1685,1687],{"class":142,"line":204},[140,1677,1678],{"class":146},"    scope ",[140,1680,546],{"class":456},[140,1682,1537],{"class":554},[140,1684,525],{"class":481},[140,1686,726],{"class":554},[140,1688,1129],{"class":481},[140,1690,1691,1693,1696,1699],{"class":142,"line":209},[140,1692,1087],{"class":635},[140,1694,1695],{"class":456}," not",[140,1697,1698],{"class":146}," scope",[140,1700,1109],{"class":481},[140,1702,1703,1706,1709],{"class":142,"line":215},[140,1704,1705],{"class":635},"        return",[140,1707,1708],{"class":481}," []",[140,1710,1711],{"class":501},"  # Skip MemOS\n",[140,1713,1714],{"class":142,"line":221},[140,1715,508],{"emptyLinePlaceholder":507},[140,1717,1718,1720,1722,1724,1726,1728,1730,1732,1734],{"class":142,"line":227},[140,1719,848],{"class":146},[140,1721,546],{"class":456},[140,1723,522],{"class":554},[140,1725,525],{"class":481},[140,1727,491],{"class":460},[140,1729,405],{"class":464},[140,1731,491],{"class":460},[140,1733,532],{"class":481},[140,1735,925],{"class":481},[140,1737,1738,1740,1742,1744,1746,1748,1751,1753,1755,1757,1759,1761],{"class":142,"line":233},[140,1739,930],{"class":460},[140,1741,726],{"class":464},[140,1743,491],{"class":460},[140,1745,594],{"class":481},[140,1747,597],{"class":517},[140,1749,1750],{"class":464},"\"kb-reader-",[140,1752,584],{"class":603},[140,1754,726],{"class":554},[140,1756,608],{"class":603},[140,1758,491],{"class":464},[140,1760,532],{"class":481},[140,1762,1763],{"class":501},"  # Retrieval-only identifier\n",[140,1765,1766,1768,1771,1773,1775,1777],{"class":142,"line":238},[140,1767,930],{"class":460},[140,1769,1770],{"class":464},"query",[140,1772,491],{"class":460},[140,1774,594],{"class":481},[140,1776,1671],{"class":554},[140,1778,573],{"class":481},[140,1780,1781,1783,1785,1787,1789,1791,1793],{"class":142,"line":244},[140,1782,930],{"class":460},[140,1784,1520],{"class":464},[140,1786,491],{"class":460},[140,1788,594],{"class":481},[140,1790,1698],{"class":554},[140,1792,532],{"class":481},[140,1794,1795],{"class":501},"         # Explicit IDs, never all\n",[140,1797,1798],{"class":142,"line":249},[140,1799,1319],{"class":481},[140,1801,1802],{"class":142,"line":255},[140,1803,508],{"emptyLinePlaceholder":507},[140,1805,1806,1808,1810,1812,1814,1816,1818,1820,1822],{"class":142,"line":261},[140,1807,1087],{"class":635},[140,1809,1537],{"class":554},[140,1811,525],{"class":481},[140,1813,726],{"class":554},[140,1815,1607],{"class":481},[140,1817,1103],{"class":456},[140,1819,1698],{"class":146},[140,1821,594],{"class":481},[140,1823,1824],{"class":501},"  # Discard results if scope changed\n",[140,1826,1827,1829],{"class":142,"line":267},[140,1828,1705],{"class":635},[140,1830,1831],{"class":481}," []\n",[140,1833,1834],{"class":142,"line":273},[140,1835,508],{"emptyLinePlaceholder":507},[140,1837,1838,1840],{"class":142,"line":278},[140,1839,636],{"class":635},[140,1841,1550],{"class":481},[140,1843,1844,1847,1849,1852,1854,1856,1859,1861,1863,1866,1868,1870,1872,1874,1876,1878,1880,1882,1884,1887,1889],{"class":142,"line":284},[140,1845,1846],{"class":481},"        {",[140,1848,491],{"class":460},[140,1850,1851],{"class":464},"title",[140,1853,491],{"class":460},[140,1855,594],{"class":481},[140,1857,1858],{"class":146}," item",[140,1860,488],{"class":481},[140,1862,491],{"class":460},[140,1864,1865],{"class":464},"memory_key",[140,1867,491],{"class":460},[140,1869,952],{"class":481},[140,1871,461],{"class":460},[140,1873,1180],{"class":464},[140,1875,491],{"class":460},[140,1877,594],{"class":481},[140,1879,1858],{"class":146},[140,1881,488],{"class":481},[140,1883,491],{"class":460},[140,1885,1886],{"class":464},"memory_value",[140,1888,491],{"class":460},[140,1890,1891],{"class":481},"]}\n",[140,1893,1895,1897,1900,1902,1904,1906,1908,1911,1913],{"class":142,"line":1894},26,[140,1896,1570],{"class":635},[140,1898,1899],{"class":146}," item ",[140,1901,786],{"class":635},[140,1903,940],{"class":146},[140,1905,488],{"class":481},[140,1907,491],{"class":460},[140,1909,1910],{"class":464},"memory_detail_list",[140,1912,491],{"class":460},[140,1914,657],{"class":481},[140,1916,1918],{"class":142,"line":1917},27,[140,1919,1647],{"class":481},[11,1921,1922],{},"The second check is easy to overlook. Retrieval takes time, during which an owner may revoke sharing or a user may disable a library. If the manager revokes access while the colleague's request is running, the library is authorized before the MemOS call but no longer authorized when results return. The service discards the entire result; the next turn uses the new scope.",[11,1924,1925,1926,1928,1929,1931,1932,66],{},"The example's ",[137,1927,726],{}," is reserved for retrieval and never receives conversation writes, so results contain only knowledge base snippets. Memmy's personal memory is handled by a separate Memory module; each context type has its own hook. Applications without a separate memory system can pass the real ",[137,1930,726],{}," to retrieve user facts and preferences in the same search. See ",[1933,1934,1936],"a",{"href":1935},"/memos_cloud/features/knowledge_base","knowledge base features",[11,1938,1939],{},"The hook labels retrieved content as reference material, asks the agent to cite sources, and tells it to ignore instructions contained in the materials to reduce prompt-injection risk.",[11,1941,1942],{},[87,1943],{"alt":1944,"src":1945},"Agent answer citing document sources","https://cdn.memtensor.com.cn/img/memos-best-practices-memmy-citations-en-20261028_compressed.png",[21,1947],{},[24,1949,410],{"id":1950},"share-a-knowledge-base",[11,1952,1953],{},"MemOS has no membership or sharing API. Memmy implements sharing in the application layer. Because all libraries belong to one MemOS project, the service can add an owner's MemOS knowledge base ID to a recipient's retrieval scope once access is authorized.",[32,1955,1956,1959,1962],{},[35,1957,1958],{},"The owner enters a Memmy user ID, phone number, or email in Sharing.",[35,1960,1961],{},"The cloud service resolves it to a Memmy account, verifies that it exists and is not the owner, and stores a read-only membership. No MemOS call is made.",[35,1963,1964],{},"After refreshing, the recipient sees the library under Shared, with its owner's name. New shared libraries are included in the recipient's retrieval by default.",[11,1966,1967],{},[87,1968],{"alt":1969,"src":1970},"Sharing management","https://cdn.memtensor.com.cn/img/memos-best-practices-memmy-sharing-en-20261028_compressed.png",[292,1972,1973,1986],{},[295,1974,1975],{},[298,1976,1977,1980,1983],{},[301,1978,1979],{},"Operation",[301,1981,1982],{},"Owner",[301,1984,1985],{},"Recipient",[314,1987,1988,1998,2008,2017,2026,2035],{},[298,1989,1990,1993,1996],{},[319,1991,1992],{},"View files",[319,1994,1995],{},"Yes",[319,1997,1995],{},[298,1999,2000,2003,2005],{},[319,2001,2002],{},"Toggle Include in Retrieval",[319,2004,1995],{},[319,2006,2007],{},"Yes, for their own account only",[298,2009,2010,2013,2015],{},[319,2011,2012],{},"Upload or delete files",[319,2014,1995],{},[319,2016,375],{},[298,2018,2019,2022,2024],{},[319,2020,2021],{},"Create, move, or delete folders",[319,2023,1995],{},[319,2025,375],{},[298,2027,2028,2031,2033],{},[319,2029,2030],{},"Rename or delete the knowledge base",[319,2032,1995],{},[319,2034,375],{},[298,2036,2037,2040,2042],{},[319,2038,2039],{},"Manage sharing",[319,2041,1995],{},[319,2043,375],{},[11,2045,2046],{},"Sharing creates no content copies: all members search the same MemOS knowledge base. A newly uploaded document can appear in the colleague's next search once available. Revoking sharing immediately removes the library from that member's retrieval scope.",[21,2048],{},[24,2050,2052],{"id":2051},"delete-a-knowledge-base","Delete a knowledge base",[11,2054,2055],{},"Deletion has two stages. First remove the library from Memmy so it immediately disappears from members' lists and retrieval scopes. Then clean up MemOS data in the background.",[130,2057,2059],{"className":443,"code":2058,"language":445,"meta":135,"style":135},"def delete_knowledge_base(user_id, kb_id):\n    kb = knowledge_bases[kb_id]\n    if kb[\"owner_id\"] != user_id:\n        raise PermissionError(\"Only the owner can delete a knowledge base\")\n\n    # 1. Remove from Memmy first\n    del knowledge_bases[kb_id]\n    members.pop(kb_id, None)\n\n    # 2. Clean up MemOS in the background\n    threading.Thread(target=memos_post, args=(\"/delete/knowledgebase\", {\n        \"knowledgebase_id\": kb[\"memos_kb_id\"],\n        \"delete_all\": True,\n    })).start()\n",[137,2060,2061,2078,2092,2114,2131,2135,2140,2153,2174,2178,2183,2221,2244,2259],{"__ignoreMap":135},[140,2062,2063,2065,2068,2070,2072,2074,2076],{"class":142,"line":143},[140,2064,518],{"class":517},[140,2066,2067],{"class":521}," delete_knowledge_base",[140,2069,525],{"class":481},[140,2071,726],{"class":528},[140,2073,532],{"class":481},[140,2075,731],{"class":528},[140,2077,538],{"class":481},[140,2079,2080,2082,2084,2086,2088,2090],{"class":142,"line":150},[140,2081,1072],{"class":146},[140,2083,546],{"class":456},[140,2085,748],{"class":146},[140,2087,488],{"class":481},[140,2089,753],{"class":146},[140,2091,657],{"class":481},[140,2093,2094,2096,2098,2100,2102,2104,2106,2108,2110,2112],{"class":142,"line":156},[140,2095,1087],{"class":635},[140,2097,1090],{"class":146},[140,2099,488],{"class":481},[140,2101,491],{"class":460},[140,2103,761],{"class":464},[140,2105,491],{"class":460},[140,2107,498],{"class":481},[140,2109,1103],{"class":456},[140,2111,1106],{"class":146},[140,2113,1109],{"class":481},[140,2115,2116,2118,2120,2122,2124,2127,2129],{"class":142,"line":162},[140,2117,1114],{"class":635},[140,2119,1117],{"class":803},[140,2121,525],{"class":481},[140,2123,491],{"class":460},[140,2125,2126],{"class":464},"Only the owner can delete a knowledge base",[140,2128,491],{"class":460},[140,2130,1129],{"class":481},[140,2132,2133],{"class":142,"line":168},[140,2134,508],{"emptyLinePlaceholder":507},[140,2136,2137],{"class":142,"line":174},[140,2138,2139],{"class":501},"    # 1. Remove from Memmy first\n",[140,2141,2142,2145,2147,2149,2151],{"class":142,"line":180},[140,2143,2144],{"class":635},"    del",[140,2146,748],{"class":146},[140,2148,488],{"class":481},[140,2150,753],{"class":146},[140,2152,657],{"class":481},[140,2154,2155,2158,2160,2163,2165,2167,2169,2172],{"class":142,"line":186},[140,2156,2157],{"class":146},"    members",[140,2159,66],{"class":481},[140,2161,2162],{"class":554},"pop",[140,2164,525],{"class":481},[140,2166,753],{"class":554},[140,2168,532],{"class":481},[140,2170,2171],{"class":1012}," None",[140,2173,1129],{"class":481},[140,2175,2176],{"class":142,"line":192},[140,2177,508],{"emptyLinePlaceholder":507},[140,2179,2180],{"class":142,"line":198},[140,2181,2182],{"class":501},"    # 2. Clean up MemOS in the background\n",[140,2184,2185,2188,2190,2193,2195,2198,2200,2202,2204,2207,2209,2211,2213,2215,2217,2219],{"class":142,"line":204},[140,2186,2187],{"class":146},"    threading",[140,2189,66],{"class":481},[140,2191,2192],{"class":554},"Thread",[140,2194,525],{"class":481},[140,2196,2197],{"class":578},"target",[140,2199,546],{"class":456},[140,2201,663],{"class":554},[140,2203,532],{"class":481},[140,2205,2206],{"class":578}," args",[140,2208,546],{"class":456},[140,2210,525],{"class":481},[140,2212,491],{"class":460},[140,2214,433],{"class":464},[140,2216,491],{"class":460},[140,2218,532],{"class":481},[140,2220,925],{"class":481},[140,2222,2223,2225,2227,2229,2231,2233,2235,2237,2239,2241],{"class":142,"line":209},[140,2224,930],{"class":460},[140,2226,1225],{"class":464},[140,2228,491],{"class":460},[140,2230,594],{"class":481},[140,2232,1090],{"class":554},[140,2234,488],{"class":481},[140,2236,491],{"class":460},[140,2238,933],{"class":464},[140,2240,491],{"class":460},[140,2242,2243],{"class":481},"],\n",[140,2245,2246,2248,2251,2253,2255,2257],{"class":142,"line":215},[140,2247,930],{"class":460},[140,2249,2250],{"class":464},"delete_all",[140,2252,491],{"class":460},[140,2254,594],{"class":481},[140,2256,1013],{"class":1012},[140,2258,573],{"class":481},[140,2260,2261,2264,2267],{"class":142,"line":221},[140,2262,2263],{"class":481},"    })).",[140,2265,2266],{"class":554},"start",[140,2268,1589],{"class":481},[11,2270,2271,2273,2274,2277,2278,2281,2282,2284],{},[137,2272,2250],{}," defaults to ",[137,2275,2276],{},"false",", which unlinks the knowledge base from the current project while retaining the library and files. Complete deletion requires explicit ",[137,2279,2280],{},"true",". Files and folders follow the same sequence, using ",[137,2283,437],{}," in the background. Prepare retries or periodic reconciliation for failed cleanup so deleted application data does not remain in MemOS.",[21,2286],{},[24,2288,2290],{"id":2289},"summary","Summary",[11,2292,2293],{},"MemOS handles what the documents say; Memmy handles who can use them and which ones are in scope. AI products with clients and end users can follow the same division when integrating MemOS knowledge bases.",[11,2295,2296],{},"Memmy permissions apply to the whole knowledge base. For file-level visibility differences, place files with different audiences into separate libraries.",[2298,2299,2300],"style",{},"html pre.shiki code .s5ojA, html code.shiki .s5ojA{--shiki-light:#90A4AE;--shiki-default:#0E1116;--shiki-dark:#E6EDF3}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sZaqd, html code.shiki .sZaqd{--shiki-light:#90A4AE;--shiki-default:#023B95;--shiki-dark:#79C0FF}html pre.shiki code .saN0X, html code.shiki .saN0X{--shiki-light:#39ADB5;--shiki-default:#A0111F;--shiki-dark:#FF7B72}html pre.shiki code .sjUum, html code.shiki .sjUum{--shiki-light:#39ADB5;--shiki-default:#032563;--shiki-dark:#A5D6FF}html pre.shiki code .sp1uZ, html code.shiki .sp1uZ{--shiki-light:#91B859;--shiki-default:#032563;--shiki-dark:#A5D6FF}html pre.shiki code .suWxN, html code.shiki .suWxN{--shiki-light:#39ADB5;--shiki-default:#0E1116;--shiki-dark:#E6EDF3}html pre.shiki code .s5qkx, html code.shiki .s5qkx{--shiki-light:#E53935;--shiki-default:#0E1116;--shiki-dark:#E6EDF3}html pre.shiki code .sfVK4, html code.shiki .sfVK4{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#66707B;--shiki-default-font-style:inherit;--shiki-dark:#8B949E;--shiki-dark-font-style:inherit}html pre.shiki code .sZ6T4, html code.shiki .sZ6T4{--shiki-light:#9C3EDA;--shiki-default:#A0111F;--shiki-dark:#FF7B72}html pre.shiki code .sbcIq, html code.shiki .sbcIq{--shiki-light:#6182B8;--shiki-default:#622CBC;--shiki-dark:#D2A8FF}html pre.shiki code .sM07a, html code.shiki .sM07a{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#0E1116;--shiki-default-font-style:inherit;--shiki-dark:#E6EDF3;--shiki-dark-font-style:inherit}html pre.shiki code .sa-2m, html code.shiki .sa-2m{--shiki-light:#6182B8;--shiki-default:#0E1116;--shiki-dark:#E6EDF3}html pre.shiki code .svxCd, html code.shiki .svxCd{--shiki-light:#6182B8;--shiki-default:#023B95;--shiki-dark:#79C0FF}html pre.shiki code .sp4zP, html code.shiki .sp4zP{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#702C00;--shiki-default-font-style:inherit;--shiki-dark:#FFA657;--shiki-dark-font-style:inherit}html pre.shiki code .scyET, html code.shiki .scyET{--shiki-light:#F76D47;--shiki-default:#A0111F;--shiki-dark:#FF7B72}html pre.shiki code .sBMTB, html code.shiki .sBMTB{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#A0111F;--shiki-default-font-style:inherit;--shiki-dark:#FF7B72;--shiki-dark-font-style:inherit}html pre.shiki code .skqQ-, html code.shiki .skqQ-{--shiki-light:#E2931D;--shiki-default:#023B95;--shiki-dark:#79C0FF}html pre.shiki code .smHB8, html code.shiki .smHB8{--shiki-light:#39ADB5;--shiki-default:#023B95;--shiki-dark:#79C0FF}html pre.shiki code .sJNII, html code.shiki .sJNII{--shiki-light:#F76D47;--shiki-default:#023B95;--shiki-dark:#79C0FF}",{"title":135,"searchDepth":150,"depth":150,"links":2302},[2303,2304,2305,2309,2310,2311,2312],{"id":26,"depth":150,"text":27},{"id":95,"depth":150,"text":96},{"id":812,"depth":150,"text":813,"children":2306},[2307,2308],{"id":817,"depth":156,"text":321},{"id":1031,"depth":156,"text":1032},{"id":1374,"depth":150,"text":1375},{"id":1950,"depth":150,"text":410},{"id":2051,"depth":150,"text":2052},{"id":2289,"depth":150,"text":2290},"How Memmy integrates knowledge bases into its desktop app, keeping API keys on the server and calculating ownership, sharing, and retrieval scopes in the application while MemOS handles document parsing and search.","md",{},"/en/usecase/memmy_knowledge_base",{"title":5,"description":13},"en/usecase/memmy_knowledge_base","NhxKsXrU9PkU6HuXxuDgE-UYRf1jQKgnLvs6IqZsb6I",[2321,2329],{"title":2322,"path":2323,"stem":2324,"icon":2325,"framework":6,"module":6,"class":2326,"target":-1,"active":2327,"defaultOpen":2327,"children":-1,"description":2328},"Build a Shared Knowledge Base for AI Apps","/usecase/shared_knowledge_base","usecase/shared_knowledge_base","i-ri-book-2-line",[],false,"Keep ownership and sharing in your app. Let MemOS parse documents and retrieve them so authorized users can ask questions against the same knowledge base.",{"title":2330,"path":2331,"stem":2332,"icon":2333,"framework":6,"module":6,"class":2334,"target":-1,"active":2327,"defaultOpen":2327,"children":-1,"description":2335},"Knowledge Q&A Assistant","/usecase/knowledge_qa_assistant","usecase/knowledge_qa_assistant","i-ri-customer-service-2-line",[],"Combine long-term memory with a knowledge base to move beyond “one-size-fits-all” retrieval results—deliver personalized, more accurate answers based on each user’s background and preferences, and turn your knowledge base into a consultant that truly understands you.",1793163799379]