Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
a318a6e
docs: align Chinese contribution links with the English docs
MatthewZhuang Sep 22, 2026
568e9a1
fix: recall playground memories from every searched cube (#2436)
Wang-Daoji Sep 29, 2026
aba1391
fix: skip vision calls for non-sendable image URLs
Wang-Daoji Oct 8, 2026
1827738
fix: skip vision calls for non-sendable image URLs (#2463)
syzsunshine219 Oct 8, 2026
1729844
Decouple knowledge memories from graph-edge relationships
Oct 10, 2026
8511502
Decouple knowledge memories from graph-edge relationships (#2479)
syzsunshine219 Oct 10, 2026
721416d
fix(scheduler): align enhanced_mem_ids with filtered mem_group in mem…
keeponlight Oct 17, 2026
9b4fea3
fix(llm): prevent IndexError when reasoning items are absent in respo…
keeponlight Oct 17, 2026
fe70153
fix(memory): decode JSON-encoded internal_info metadata
linsheng-li Oct 20, 2026
c8aed14
feat: align PostgreSQL graph storage with current v2.0.36 APIs (#2531)
Zyntrael Oct 21, 2026
9b35357
fix(scheduler): initialize RabbitMQ IO thread before shutdown
linsheng-li Oct 21, 2026
f6266be
fix: pin certifi 2026.10.19 to drop compromised eMudhra roots (#2536)
syzsunshine219 Oct 23, 2026
837d42e
Merge branch 'dev-v2.0.36' into fix/rabbitmq-shutdown-thread-init
endxxxx Oct 24, 2026
c0cb83f
Merge branch 'dev-v2.0.36' into fix/mem-read-handler-zip-mem-group
endxxxx Oct 24, 2026
66f30bc
Merge branch 'dev-v2.0.36' into fix/decode-internal-info-json
endxxxx Oct 24, 2026
734fc93
Merge branch 'dev-v2.0.36' into fix/openai-responses-empty-reasoning
endxxxx Oct 24, 2026
4701866
fix(scheduler): align enhanced_mem_ids with filtered mem_group in mem…
endxxxx Oct 24, 2026
5fa7293
fix(llm): prevent IndexError when reasoning items are absent in respo…
endxxxx Oct 24, 2026
4bfddc8
fix(memory): decode JSON-encoded internal_info metadata (#2517)
endxxxx Oct 24, 2026
af0108d
fix(api): strip Bearer scheme so keyed requests reach per-key rate-li…
RerankerGuo Oct 13, 2026
981130c
fix(api): enforce canonical hex format on validate_key_format (#2427)
RerankerGuo Oct 13, 2026
c50bc8a
Merge branch 'dev-v2.0.36' into fix/rabbitmq-shutdown-thread-init
endxxxx Oct 28, 2026
4094d8e
fix(api): strip Bearer scheme so keyed requests reach per-key rate-li…
endxxxx Oct 29, 2026
db41eb5
fix(api): enforce canonical hex format on validate_key_format (#2427)…
endxxxx Oct 29, 2026
c2e2acd
Merge branch 'dev-v2.0.36' into fix/rabbitmq-shutdown-thread-init
endxxxx Oct 29, 2026
e85b9db
fix(scheduler): initialize RabbitMQ IO thread before shutdown (#2532)
syzsunshine219 Oct 29, 2026
faec48d
fix: preserve identifier types in PolarDB lightweight recall
endxxxx Oct 29, 2026
b1a7d5f
refactor: reuse lightweight identifier field set
endxxxx Oct 29, 2026
0e58d0e
fix: preserve identifier types in PolarDB lightweight recall (#2551)
syzsunshine219 Oct 29, 2026
755e8eb
chore: change version number to v2.0.36
endxxxx Nov 9, 2026
a3944ac
chore: change version number to v2.0.36 (#2567)
syzsunshine219 Nov 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker/requirements-full.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ attrs==25.3.0
authlib==1.6.0
beautifulsoup4==4.13.4
cachetools==6.2.1
certifi==2025.7.14
certifi==2026.10.19
cffi==1.17.1
charset-normalizer==3.4.2
chonkie==1.1.1
Expand Down
2 changes: 1 addition & 1 deletion docker/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ attrs==25.4.0
Authlib==1.6.5
beartype==0.22.5
cachetools==6.2.2
certifi==2025.11.12
certifi==2026.10.19
cffi==2.0.0
charset-normalizer==3.4.4
chonkie==1.1.0
Expand Down
2 changes: 1 addition & 1 deletion docs/cn/open_source/contribution/development_workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ git fetch upstream
git rebase upstream/dev # 把你的 feat 分支基于最新 dev 重放
```

提交更改时请遵循项目的提交规范(参见 [提交规范](commit_guidelines.md))。
提交更改时请遵循项目的提交规范(参见 [提交规范](./commit_guidelines.md))。

#### 推送到你的 Fork 仓库

Expand Down
10 changes: 5 additions & 5 deletions docs/cn/open_source/contribution/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ title: 参与 MemOS 开发
desc: 欢迎阅读 MemOS 贡献指南!了解如何配置开发环境、遵循我们的开发流程、撰写规范的提交信息、完善文档以及添加测试用例。
---

- **首次贡献者:** 请先阅读 [环境配置指南](setting_up.md),以准备你的开发环境。
- **准备开始编码了吗?** 请查看 [开发流程](development_workflow.md) 指南,了解我们提交更改的流程。
- **撰写规范的提交信息:** 请参考我们的 [提交规范](commit_guidelines.md)。
- **参与文档编写:** 如果你正在帮助我们改进文档,请阅读 [文档编写指南](writing_docs.md)。
- **添加或完善测试用例:** 请参考 [测试编写指南](writing_tests.md)。
- **首次贡献者:** 请先阅读 [环境配置指南](./setting_up.md),以准备你的开发环境。
- **准备开始编码了吗?** 请查看 [开发流程](./development_workflow.md) 指南,了解我们提交更改的流程。
- **撰写规范的提交信息:** 请参考我们的 [提交规范](./commit_guidelines.md)。
- **参与文档编写:** 如果你正在帮助我们改进文档,请阅读 [文档编写指南](./writing_docs.md)。
- **添加或完善测试用例:** 请参考 [测试编写指南](./writing_tests.md)。

你的贡献让这个项目更加优秀!✨ 如果有任何问题,欢迎提交 issue 或参与讨论,也可以扫描下方二维码加入我们的 Discord 或微信社群与我们联系。

Expand Down
6 changes: 3 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
##############################################################################

name = "MemoryOS"
version = "2.0.33"
version = "2.0.36"
description = "Intelligence Begins with Memory"
license = {text = "Apache-2.0"}
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion src/memos/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "2.0.33"
__version__ = "2.0.36"

from memos.configs.mem_cube import GeneralMemCubeConfig
from memos.configs.mem_os import MOSConfig
Expand Down
6 changes: 3 additions & 3 deletions src/memos/api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -906,8 +906,8 @@ def get_polardb_config(user_id: str | None = None) -> dict[str, Any]:
def get_postgres_config(user_id: str | None = None) -> dict[str, Any]:
"""Get PostgreSQL + pgvector configuration for MemOS graph storage.

Uses standard PostgreSQL with pgvector extension.
Schema: memos.memories, memos.edges
Uses standard PostgreSQL with pgvector. Shard count, index, and
full-text configuration keep the backend defaults unless overridden.
"""
user_name = os.getenv("MEMOS_USER_NAME", "default")
if user_id:
Expand All @@ -922,7 +922,7 @@ def get_postgres_config(user_id: str | None = None) -> dict[str, Any]:
"schema_name": os.getenv("MEMOS_SCHEMA", "memos"),
"user_name": user_name,
"use_multi_db": False,
"embedding_dimension": int(os.getenv("EMBEDDING_DIMENSION", "384")),
"embedding_dimension": int(os.getenv("EMBEDDING_DIMENSION", "1024")),
"maxconn": int(os.getenv("POSTGRES_MAX_CONN", "20")),
}

Expand Down
24 changes: 12 additions & 12 deletions src/memos/api/handlers/chat_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,12 +482,8 @@ def generate_chat_response() -> Generator[str, None, None]:

yield f"data: {json.dumps({'type': 'status', 'data': '1'})}\n\n"

# Extract memories from search results (first search)
memories_list = []
if search_response.data and search_response.data.get("text_mem"):
text_mem_results = search_response.data["text_mem"]
if text_mem_results and text_mem_results[0].get("memories"):
memories_list = text_mem_results[0]["memories"]
# Extract memories from every searched cube (first search)
memories_list = self._memories_from_cube_results(search_response.data)

# Filter memories by threshold
filtered_memories = self._filter_memories_by_threshold(memories_list)[:5]
Expand Down Expand Up @@ -577,12 +573,8 @@ def generate_chat_response() -> Generator[str, None, None]:
project_id=chat_req.project_id,
)

# Extract memories from search results (second search)
memories_list = []
if search_response.data and search_response.data.get("text_mem"):
text_mem_results = search_response.data["text_mem"]
if text_mem_results and text_mem_results[0].get("memories"):
memories_list = text_mem_results[0]["memories"]
# Extract memories from every searched cube (second search)
memories_list = self._memories_from_cube_results(search_response.data)

# Filter memories by threshold, min_num is the min number of memories for playground
second_filtered_memories = self._filter_memories_by_threshold(
Expand Down Expand Up @@ -1161,6 +1153,14 @@ def _format_mem_block(

return "\n".join(lines_o), "\n".join(lines_p)

@staticmethod
def _memories_from_cube_results(search_data: dict[str, Any] | None) -> list[Any]:
"""Collect textual memories from every cube in a search response."""
memories_list: list[Any] = []
for cube_result in (search_data or {}).get("text_mem") or []:
memories_list.extend(cube_result.get("memories") or [])
return memories_list

def _filter_memories_by_threshold(
self,
memories: list,
Expand Down
28 changes: 17 additions & 11 deletions src/memos/api/middleware/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
import memos.log


# Canonical format check; re-exported here so the middleware shares the
# same logic as ``src/memos/api/utils/api_keys.py``. Keeping one source of
# truth is what fixes issue #2427 (previously the middleware copy and the
# utils copy could drift independently).
from memos.api.utils.api_keys import validate_key_format as validate_key_format_canonical


logger = memos.log.get_logger(__name__)

# API key header configuration
Expand Down Expand Up @@ -63,17 +70,16 @@ def hash_api_key(key: str) -> str:


def validate_key_format(key: str) -> bool:
"""Validate API key format: krlk_<64-hex>."""
if not key or not key.startswith("krlk_"):
return False
hex_part = key[5:] # Remove 'krlk_' prefix
if len(hex_part) != 64:
return False
try:
int(hex_part, 16)
return True
except ValueError:
return False
"""Validate API key format: krlk_<64-hex>.

Re-exported from ``memos.api.utils.api_keys.validate_key_format`` for
backwards compatibility with callers that imported this symbol from
the middleware path. Issue #2427: the previous copy used ``int(...)``
which accepted non-canonical hex (leading signs, ``0x`` prefix, ``_``
separators, whitespace) — see the canonical implementation for the
fix.
"""
return validate_key_format_canonical(key)


def get_key_prefix(key: str) -> str:
Expand Down
7 changes: 6 additions & 1 deletion src/memos/api/middleware/rate_limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,13 @@ def _get_client_key(request: Request) -> str:

Uses API key if available, otherwise falls back to IP.
"""
# Try to get API key from header
# Try to get API key from header. Real clients send a Bearer scheme
# per RFC 6750 (``Authorization: Bearer krlk_<hex>``); we strip the
# scheme before the prefix check so keyed requests actually land on
# a per-key bucket (issue #2428).
auth_header = request.headers.get("Authorization", "")
if auth_header.lower().startswith("bearer "):
auth_header = auth_header[len("bearer ") :].lstrip()
if auth_header.startswith("krlk_"):
# Use first 20 chars of key as identifier
return f"ratelimit:key:{auth_header[:20]}"
Expand Down
20 changes: 11 additions & 9 deletions src/memos/api/utils/api_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"""

import hashlib
import re
import secrets

from dataclasses import dataclass
Expand Down Expand Up @@ -45,11 +46,19 @@ def hash_key(key: str) -> str:
return hashlib.sha256(key.encode()).hexdigest()


# Match the only form ``generate_api_key()`` produces: ``krlk_`` followed by
# exactly 64 lowercase hex characters. Using ``int(hex_part, 16)`` would also
# accept leading signs, ``0x`` prefixes, ``_`` separators, and surrounding
# whitespace, none of which a real key ever carries (issue #2427).
_KEY_FORMAT_HEX_RE = re.compile(r"[0-9a-f]{64}")


def validate_key_format(key: str) -> bool:
"""
Validate API key format.

Valid format: krlk_<64-hex-chars>
Valid format: ``krlk_<64-hex-chars>`` where the hex part is exactly 64
characters from ``[0-9a-f]`` — the only form ``generate_api_key()`` produces.
"""
if not key or not isinstance(key, str):
return False
Expand All @@ -58,14 +67,7 @@ def validate_key_format(key: str) -> bool:
return False

hex_part = key[5:]
if len(hex_part) != 64:
return False

try:
int(hex_part, 16)
return True
except ValueError:
return False
return _KEY_FORMAT_HEX_RE.fullmatch(hex_part) is not None


def generate_master_key() -> tuple[str, str]:
Expand Down
33 changes: 28 additions & 5 deletions src/memos/configs/graph_db.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, ClassVar
from typing import Any, ClassVar, Literal

from pydantic import BaseModel, Field, field_validator, model_validator

Expand Down Expand Up @@ -195,8 +195,7 @@ class PostgresGraphDBConfig(BaseConfig):
Does NOT require Apache AGE or other graph extensions.

Schema:
- memos_memories: Main table for memory nodes (id, memory, properties JSONB, embedding vector)
- memos_edges: Edge table for relationships (source_id, target_id, type)
- {schema}_graph_{n}."Memory" and "Edges", one physical shard per tenant

Example:
---
Expand All @@ -223,13 +222,33 @@ class PostgresGraphDBConfig(BaseConfig):
default=False,
description="If False: use single database with logical isolation by user_name",
)
embedding_dimension: int = Field(
default=768, description="Dimension of vector embedding (768 for all-mpnet-base-v2)"
embedding_dimension: int = Field(default=1024, description="Dimension of vector embedding")
shard_count: int = Field(
default=400,
ge=1,
le=4096,
description="Number of MD5 tenant shards",
)
maxconn: int = Field(
default=20,
description="Maximum number of connections in the connection pool",
)
minconn: int = Field(
default=8,
ge=1,
description="Warm connections kept in the pool",
)
vector_index_type: Literal["hnsw", "ivfflat"] = Field(
default="hnsw",
description="pgvector approximate index type",
)
hnsw_m: int = Field(default=16, ge=2, le=100)
hnsw_ef_construction: int = Field(default=64, ge=4, le=1000)
ivfflat_lists: int = Field(default=100, ge=1)
fulltext_config: str = Field(
default="jiebacfg",
description="PostgreSQL text search configuration used to build search_vector",
)

@model_validator(mode="after")
def validate_config(self):
Expand All @@ -238,6 +257,10 @@ def validate_config(self):
raise ValueError("`db_name` must be provided")
if not self.use_multi_db and not self.user_name:
raise ValueError("In single-database mode, `user_name` must be provided")
if self.minconn > self.maxconn:
raise ValueError(f"`minconn` ({self.minconn}) must be <= `maxconn` ({self.maxconn})")
if not self.fulltext_config.replace(".", "_").isidentifier():
raise ValueError("`fulltext_config` must be a valid PostgreSQL configuration name")
return self


Expand Down
28 changes: 26 additions & 2 deletions src/memos/graph_dbs/polardb.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@

logger = get_logger(__name__)

_LIGHTWEIGHT_IDENTIFIER_FIELDS = frozenset(
{
"user_id",
"user_name",
"session_id",
"mem_cube_id",
"dialog_id",
"working_binding",
"project_id",
"manager_user_id",
}
)


def _build_lightweight_return_columns(return_fields: list[str]) -> str:
columns = []
Expand All @@ -33,9 +46,20 @@ def _build_lightweight_return_columns(return_fields: list[str]) -> str:
return "".join(f",\n {column}" for column in columns)


def _decode_lightweight_return_value(value: Any) -> Any:
def _decode_lightweight_return_value(value: Any, field: str | None = None) -> Any:
if hasattr(value, "value"):
value = value.value
# Drivers may return agtype identifiers as already-decoded scalar strings.
# Parsing a numeric ID again would change its type.
if field in _LIGHTWEIGHT_IDENTIFIER_FIELDS:
if isinstance(value, str):
try:
decoded = json.loads(value)
except (json.JSONDecodeError, TypeError):
return value
return decoded if decoded is None or isinstance(decoded, str) else value
if isinstance(value, int) and not isinstance(value, bool):
return str(value)
if isinstance(value, str):
try:
return json.loads(value)
Expand Down Expand Up @@ -1990,7 +2014,7 @@ def search_by_embedding(
item = {"id": id_val, "score": score_val}
if light_weight_mode:
for offset, field in enumerate(validated_return_fields, start=5):
item[field] = _decode_lightweight_return_value(row[offset])
item[field] = _decode_lightweight_return_value(row[offset], field=field)
elif validated_return_fields:
properties = row[1] # properties column
item.update(
Expand Down
Loading
Loading