MemOS Memory Protocol
Command selection rules:
- if the user asks to uninstall, disable, remove, or stop using MemOS, use
memos uninstall --agent <current_agent> --yes directly and do not run memos search or memos add for that turn; add --path only when the user also wants to remove the MemOS PATH entries from ~/.bash_profile and ~/.zshenv;
- if the user wants to preview what would be stored, use
memos extract directly;
- at the start of a conversation, must use
memos search directly with the user's original query;
- at the end of a conversation, must use
memos add directly with both the user's question and the assistant's final answer;
- do not run
memos search or memos add for intermediate states, including planning, partial progress, compact/resume, or continuation after context compaction;
- if the user wants a memory-aware response from MemOS itself, use
memos chat directly;
- if the user already has a concrete memory id, use
memos get, memos origin, or memos delete directly;
- if the user wants to manage knowledge bases (create, delete, upload, query files), use the corresponding
memos kb subcommand;
- do not call
memos --help by default when the intent already matches one of the commands below;
- use
memos --help only when the command name, parameters, or route are genuinely unclear;
- do not use
memos init as a discovery step when the CLI is already installed.
Identity rules:
- always prefer the exact configured
user_id value when a command is scoped by user;
- if the user does not specify the
user_id, omit the --user-id argument and use the user_id from the config file by default;
Hard mapping:
- store a durable fact, preference, decision, or long-term task ->
memos add
- preview candidate memories before storing ->
memos extract
- retrieve context at conversation start ->
memos search
- ask MemOS to answer with memory context ->
memos chat
- fetch memories by user_id ->
memos get
- trace where one memory came from ->
memos origin
- remove one concrete memory by id ->
memos delete
- delete all memories for a user_id ->
memos delete --user-id
- uninstall MemOS integration from the current agent ->
memos uninstall --agent <current_agent> --yes
- create a knowledge base ->
memos kb create
- remove a knowledge base ->
memos kb remove
- upload documents to a knowledge base ->
memos kb add-file
- check file processing status in a knowledge base ->
memos kb get-file
- list files in a knowledge base ->
memos kb list-file
- delete files from a knowledge base ->
memos kb delete-file
Use this skill when:
- the task may depend on prior user, project, or conversation context;
- the user provides a stable new fact, preference, or background detail;
- you want to preview extracted memory candidates before storing them;
- you need to inspect, list, delete, or trace the source of an existing memory record;
- you need to create, remove, or manage a knowledge base and its documents.
Never store:
- secrets, API keys, tokens, or passwords;
- unverified guesses or speculative conclusions as user facts;
- short-lived task state that will not matter in future sessions;
- redundant paraphrases when one concise factual memory is enough.
Command examples:
memos add "<fact>" --user-id <USER_ID> --format json
memos extract "<message>" --user-id <USER_ID> --format json
memos search "<query>" --user-id <USER_ID> --format agent --detail simple
memos chat "<message>" --user-id <USER_ID> --format agent
memos get <USER_ID> --format json --detail detail
memos origin <MEMORY_ID> --format json
memos delete <MEMORY_ID> --format json
memos delete --user-id <USER_ID> --format json
memos uninstall --agent <CURRENT_AGENT> --yes
memos uninstall --agent <CURRENT_AGENT> --yes --path
memos kb create --name "<name>" --description "<desc>" --format json
memos kb remove <KB_ID> --format json
memos kb add-file --kb-id <KB_ID> --files '["https://example.com/doc.pdf"]' --format json
memos kb get-file --file-ids '["<FILE_ID>"]' --format json
memos kb list-file --kb-id <KB_ID> --page 1 --page-size 20 --format json
memos kb delete-file --kb-id <KB_ID> --file-ids '["<FILE_ID>"]' --format json
Choose commands by intent:
Process rules:
- the default workflow is: search at conversation start, work and answer through intermediate states without additional search/add, then add at conversation end;
- when you add at conversation end, must pass both the user's question and the assistant's final answer into
memos add so the extractor can decide what is worth keeping;
- must not skip
add at conversation end just because the current turn does not obviously contain a durable fact;
- per conversation, keep memory-tool usage bounded: at most 1 original-query
search call at the start and at most 1 add call at the end;
- do not chain additional memory tools in the same turn unless the user explicitly asks for that specific operation;
extract is only for previewing candidates, not for storing;
feedback is a separate command and should only be used when the user explicitly wants feedback storage;
- do not start a memory-write request by checking config or running
memos init;
Intent map:
- preview what would be stored ->
memos extract
- retrieve context at conversation start ->
memos search
- store at conversation end ->
memos add
- get memories by
user_id -> memos get
- trace where a memory came from ->
memos origin
- delete one concrete memory ->
memos delete
- delete all memories for a
user_id -> memos delete --user-id
- ask MemOS to answer with memory context ->
memos chat
- uninstall MemOS integration from the current agent ->
memos uninstall --agent <current_agent> --yes
- create a knowledge base ->
memos kb create
- remove a knowledge base ->
memos kb remove
- upload documents to a knowledge base ->
memos kb add-file
- check file details or processing status ->
memos kb get-file
- list files in a knowledge base ->
memos kb list-file
- delete files from a knowledge base ->
memos kb delete-file
Working rules:
- must use the user's original query as the only query for
memos search;
- do not rewrite, summarize, keyword-compress, retry, or run an additional search query;
memos add uses a messages array payload; when adding at conversation end, include both the user's question and the assistant's answer in that array;
- in the
memos add payload, the user message content must exactly match the original user query;
- in the
memos add payload, the assistant message content must exactly match the final answer sent to the user; do not rewrite, summarize, compress, or modify it;
- when
--format is omitted, treat the default as agent;
- append
--format json at the end of the command whenever a later step needs exact memory_id or structured records;
- append
--format agent at the end of the command when the result will be injected back into model context;
- keep
--format at the end of every command line, and keep --detail at the end only for search and get;
- do not run
memos init as a default preflight step if MemOS CLI is already installed;
- do not run
memos search or memos add in a turn where the user is asking to uninstall, disable, remove, or stop using MemOS;
- only run
memos init --agent <current_agent> when the CLI is missing and the user has explicitly provided an API key or asked to initialize MemOS;
- if initialization is needed but no API key is available, ask the user for the key instead of stopping the workflow;
- the active agent should initialize itself with its own
--agent value, not a hardcoded different agent name;
- pass
--user-id only when the user explicitly provides it; otherwise omit it and let the CLI use the config default;
- read result counts from
count and structured payloads from data;
- if you already have
memory_id, do not search first just to guess.
Examples:
memos add "User likes Python"
memos search "Python"
memos search "user preferences about restaurants" --user-id <USER_ID> --format agent --detail simple
memos extract "User likes coffee and prefers dark mode" --user-id <USER_ID> --format json
memos add "User is allergic to peanuts" --user-id <USER_ID> --format json
memos get <USER_ID> --format json --detail detail
memos origin <MEMORY_ID> --format json
memos delete <MEMORY_ID> --format json
memos uninstall --agent <CURRENT_AGENT> --yes
memos uninstall --agent <CURRENT_AGENT> --yes --path
memos kb create --name "Project docs" --description "Documentation for the project" --format json
memos kb add-file --kb-id <KB_ID> --files '["https://example.com/doc.pdf"]' --format json
memos kb list-file --kb-id <KB_ID> --type document --page 1 --page-size 10 --format json
memos kb get-file --file-ids '["file_abc123"]' --format json
memos kb delete-file --kb-id <KB_ID> --file-ids '["file_abc123"]' --format json
memos kb remove <KB_ID> --format json
1---2name: memos-memory3description: Provide universal memory capabilities for different AI agents and development frameworks, unifying the capture, retrieval, and management of user, project, and task context.4---56# MemOS Memory Protocol78Command selection rules:9- if the user asks to uninstall, disable, remove, or stop using MemOS, use `memos uninstall --agent <current_agent> --yes` directly and do not run `memos search` or `memos add` for that turn; add `--path` only when the user also wants to remove the MemOS PATH entries from `~/.bash_profile` and `~/.zshenv`;10- if the user wants to preview what would be stored, use `memos extract` directly;11- at the start of a conversation, must use `memos search` directly with the user's original query;12- at the end of a conversation, must use `memos add` directly with both the user's question and the assistant's final answer;13- do not run `memos search` or `memos add` for intermediate states, including planning, partial progress, compact/resume, or continuation after context compaction;14- if the user wants a memory-aware response from MemOS itself, use `memos chat` directly;15- if the user already has a concrete memory id, use `memos get`, `memos origin`, or `memos delete` directly;16- if the user wants to manage knowledge bases (create, delete, upload, query files), use the corresponding `memos kb` subcommand;17- do not call `memos --help` by default when the intent already matches one of the commands below;18- use `memos --help` only when the command name, parameters, or route are genuinely unclear;19- do not use `memos init` as a discovery step when the CLI is already installed.2021Identity rules:22- always prefer the exact configured `user_id` value when a command is scoped by user;23- if the user does not specify the `user_id`, omit the `--user-id` argument and use the `user_id` from the config file by default;2425Hard mapping:26- store a durable fact, preference, decision, or long-term task -> `memos add`27- preview candidate memories before storing -> `memos extract`28- retrieve context at conversation start -> `memos search`29- ask MemOS to answer with memory context -> `memos chat`30- fetch memories by user_id -> `memos get`31- trace where one memory came from -> `memos origin`32- remove one concrete memory by id -> `memos delete`33- delete all memories for a user_id -> `memos delete --user-id`34- uninstall MemOS integration from the current agent -> `memos uninstall --agent <current_agent> --yes`35- create a knowledge base -> `memos kb create`36- remove a knowledge base -> `memos kb remove`37- upload documents to a knowledge base -> `memos kb add-file`38- check file processing status in a knowledge base -> `memos kb get-file`39- list files in a knowledge base -> `memos kb list-file`40- delete files from a knowledge base -> `memos kb delete-file`4142Use this skill when:43- the task may depend on prior user, project, or conversation context;44- the user provides a stable new fact, preference, or background detail;45- you want to preview extracted memory candidates before storing them;46- you need to inspect, list, delete, or trace the source of an existing memory record;47- you need to create, remove, or manage a knowledge base and its documents.4849Never store:50- secrets, API keys, tokens, or passwords;51- unverified guesses or speculative conclusions as user facts;52- short-lived task state that will not matter in future sessions;53- redundant paraphrases when one concise factual memory is enough.5455Command examples:56- `memos add "<fact>" --user-id <USER_ID> --format json`57- `memos extract "<message>" --user-id <USER_ID> --format json`58- `memos search "<query>" --user-id <USER_ID> --format agent --detail simple`59- `memos chat "<message>" --user-id <USER_ID> --format agent`60- `memos get <USER_ID> --format json --detail detail`61- `memos origin <MEMORY_ID> --format json`62- `memos delete <MEMORY_ID> --format json`63- `memos delete --user-id <USER_ID> --format json`64- `memos uninstall --agent <CURRENT_AGENT> --yes`65- `memos uninstall --agent <CURRENT_AGENT> --yes --path`66- `memos kb create --name "<name>" --description "<desc>" --format json`67- `memos kb remove <KB_ID> --format json`68- `memos kb add-file --kb-id <KB_ID> --files '["https://example.com/doc.pdf"]' --format json`69- `memos kb get-file --file-ids '["<FILE_ID>"]' --format json`70- `memos kb list-file --kb-id <KB_ID> --page 1 --page-size 20 --format json`71- `memos kb delete-file --kb-id <KB_ID> --file-ids '["<FILE_ID>"]' --format json`7273Choose commands by intent:74- use [`./references/memos-add.md`](./references/memos-add.md) when the user gives a durable fact or preference worth saving;75- use [`./references/memos-extract.md`](./references/memos-extract.md) when the user wants a preview of memory candidates without storing;76- must use [`./references/memos-search.md`](./references/memos-search.md) at conversation start;77- use [`./references/memos-chat.md`](./references/memos-chat.md) when interacting with MemOS chat capability directly;78- use [`./references/memos-get.md`](./references/memos-get.md) for retrieval by `user_id`;79- use [`./references/memos-origin.md`](./references/memos-origin.md) when you need the original source messages behind a specific memory;80- use [`./references/memos-delete.md`](./references/memos-delete.md) only when you already have a concrete `memory_id`;81- use [`./references/memos-uninstall.md`](./references/memos-uninstall.md) when the user asks to uninstall, disable, remove, or stop using MemOS;82- use [`./references/memos-kb-create.md`](./references/memos-kb-create.md) to create a new knowledge base;83- use [`./references/memos-kb-remove.md`](./references/memos-kb-remove.md) to remove a knowledge base;84- use [`./references/memos-kb-add-file.md`](./references/memos-kb-add-file.md) to upload documents to a knowledge base;85- use [`./references/memos-kb-get-file.md`](./references/memos-kb-get-file.md) to check file details and processing status;86- use [`./references/memos-kb-list-file.md`](./references/memos-kb-list-file.md) to browse files in a knowledge base;87- use [`./references/memos-kb-delete-file.md`](./references/memos-kb-delete-file.md) to delete files from a knowledge base.8889Process rules:90- the default workflow is: search at conversation start, work and answer through intermediate states without additional search/add, then add at conversation end;91- when you add at conversation end, must pass both the user's question and the assistant's final answer into `memos add` so the extractor can decide what is worth keeping;92- must not skip `add` at conversation end just because the current turn does not obviously contain a durable fact;93- per conversation, keep memory-tool usage bounded: at most 1 original-query `search` call at the start and at most 1 `add` call at the end;94- do not chain additional memory tools in the same turn unless the user explicitly asks for that specific operation;95- `extract` is only for previewing candidates, not for storing;96- `feedback` is a separate command and should only be used when the user explicitly wants feedback storage;97- do not start a memory-write request by checking config or running `memos init`;9899Intent map:100- preview what would be stored -> `memos extract`101- retrieve context at conversation start -> `memos search`102- store at conversation end -> `memos add`103- get memories by `user_id` -> `memos get`104- trace where a memory came from -> `memos origin`105- delete one concrete memory -> `memos delete`106- delete all memories for a `user_id` -> `memos delete --user-id`107- ask MemOS to answer with memory context -> `memos chat`108- uninstall MemOS integration from the current agent -> `memos uninstall --agent <current_agent> --yes`109- create a knowledge base -> `memos kb create`110- remove a knowledge base -> `memos kb remove`111- upload documents to a knowledge base -> `memos kb add-file`112- check file details or processing status -> `memos kb get-file`113- list files in a knowledge base -> `memos kb list-file`114- delete files from a knowledge base -> `memos kb delete-file`115116Working rules:117- must use the user's original query as the only query for `memos search`;118- do not rewrite, summarize, keyword-compress, retry, or run an additional search query;119- `memos add` uses a `messages` array payload; when adding at conversation end, include both the user's question and the assistant's answer in that array;120- in the `memos add` payload, the user message content must exactly match the original user query;121- in the `memos add` payload, the assistant message content must exactly match the final answer sent to the user; do not rewrite, summarize, compress, or modify it;122- when `--format` is omitted, treat the default as `agent`;123- append `--format json` at the end of the command whenever a later step needs exact `memory_id` or structured records;124- append `--format agent` at the end of the command when the result will be injected back into model context;125- keep `--format` at the end of every command line, and keep `--detail` at the end only for `search` and `get`;126- do not run `memos init` as a default preflight step if MemOS CLI is already installed;127- do not run `memos search` or `memos add` in a turn where the user is asking to uninstall, disable, remove, or stop using MemOS;128- only run `memos init --agent <current_agent>` when the CLI is missing and the user has explicitly provided an API key or asked to initialize MemOS;129- if initialization is needed but no API key is available, ask the user for the key instead of stopping the workflow;130- the active agent should initialize itself with its own `--agent` value, not a hardcoded different agent name;131- pass `--user-id` only when the user explicitly provides it; otherwise omit it and let the CLI use the config default;132- read result counts from `count` and structured payloads from `data`;133- if you already have `memory_id`, do not search first just to guess.134135Examples:136137```bash138memos add "User likes Python"139memos search "Python"140```141142```bash143memos search "user preferences about restaurants" --user-id <USER_ID> --format agent --detail simple144```145146```bash147memos extract "User likes coffee and prefers dark mode" --user-id <USER_ID> --format json148```149150```bash151memos add "User is allergic to peanuts" --user-id <USER_ID> --format json152```153154```bash155memos get <USER_ID> --format json --detail detail156memos origin <MEMORY_ID> --format json157memos delete <MEMORY_ID> --format json158```159160```bash161memos uninstall --agent <CURRENT_AGENT> --yes162```163164```bash165memos uninstall --agent <CURRENT_AGENT> --yes --path166```167168```bash169memos kb create --name "Project docs" --description "Documentation for the project" --format json170```171172```bash173memos kb add-file --kb-id <KB_ID> --files '["https://example.com/doc.pdf"]' --format json174```175176```bash177memos kb list-file --kb-id <KB_ID> --type document --page 1 --page-size 10 --format json178```179180```bash181memos kb get-file --file-ids '["file_abc123"]' --format json182memos kb delete-file --kb-id <KB_ID> --file-ids '["file_abc123"]' --format json183memos kb remove <KB_ID> --format json184```