From 3665470f3ff0bfa9b2af123362f4058b3e9bf8a3 Mon Sep 17 00:00:00 2001 From: bittergreen Date: Thu, 20 Aug 2026 14:25:37 +0800 Subject: [PATCH 1/3] fix: (embedders)preserve config for cached factory instances --- src/memos/embedders/factory.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/memos/embedders/factory.py b/src/memos/embedders/factory.py index 4f9d1bda8..2a2ca4826 100644 --- a/src/memos/embedders/factory.py +++ b/src/memos/embedders/factory.py @@ -29,6 +29,8 @@ def from_config(cls, config_factory: EmbedderConfigFactory) -> BaseEmbedder: raise ValueError(f"Invalid backend: {backend}") embedder_class = cls.backend_to_class[backend] embedder = embedder_class(config_factory.config) + if not hasattr(embedder, "config"): + embedder.config = config_factory.config if backend in cls.cacheable_backends and embedding_optimization_enabled(): return CachingEmbedder(embedder) return embedder From faadbcb187557cd2db65ac7edc2c8c1626b58d33 Mon Sep 17 00:00:00 2001 From: bittergreen Date: Thu, 20 Aug 2026 14:48:35 +0800 Subject: [PATCH 2/3] fix: add DashScope wait timeout header for Qwen requests --- src/memos/llms/qwen.py | 17 +++++++++++++++++ tests/llms/test_qwen.py | 27 ++++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/memos/llms/qwen.py b/src/memos/llms/qwen.py index d54e23c7f..c50ca978a 100644 --- a/src/memos/llms/qwen.py +++ b/src/memos/llms/qwen.py @@ -1,3 +1,5 @@ +from typing import Any + from memos.configs.llm import QwenLLMConfig from memos.llms.openai import OpenAILLM from memos.log import get_logger @@ -5,9 +7,24 @@ logger = get_logger(__name__) +DASHSCOPE_WAIT_TIMEOUT_HEADER = "X-DashScope-Wait-Timeout" +DASHSCOPE_WAIT_TIMEOUT_SECONDS = "30" + + +def _add_dashscope_wait_timeout_header( + default_headers: dict[str, Any] | None, +) -> dict[str, Any]: + headers = dict(default_headers or {}) + if not any(key.lower() == DASHSCOPE_WAIT_TIMEOUT_HEADER.lower() for key in headers): + headers[DASHSCOPE_WAIT_TIMEOUT_HEADER] = DASHSCOPE_WAIT_TIMEOUT_SECONDS + return headers + class QwenLLM(OpenAILLM): """Qwen (DashScope) LLM class via OpenAI-compatible API.""" def __init__(self, config: QwenLLMConfig): + config = config.model_copy( + update={"default_headers": _add_dashscope_wait_timeout_header(config.default_headers)} + ) super().__init__(config) diff --git a/tests/llms/test_qwen.py b/tests/llms/test_qwen.py index 71a4c75dd..594597657 100644 --- a/tests/llms/test_qwen.py +++ b/tests/llms/test_qwen.py @@ -1,13 +1,38 @@ import unittest from types import SimpleNamespace -from unittest.mock import MagicMock +from unittest.mock import MagicMock, patch from memos.configs.llm import QwenLLMConfig from memos.llms.qwen import QwenLLM class TestQwenLLM(unittest.TestCase): + def test_qwen_llm_adds_dashscope_wait_timeout_header(self): + """Test QwenLLM adds DashScope server-side queue wait timeout header.""" + config = QwenLLMConfig.model_validate( + { + "model_name_or_path": "qwen-test", + "api_key": "sk-test", + "api_base": "https://dashscope.aliyuncs.com/api/v1", + "default_headers": {"X-Custom-Header": "custom"}, + } + ) + + with patch("memos.llms.openai.openai.Client") as mock_client: + QwenLLM(config) + + default_headers = mock_client.call_args.kwargs["default_headers"] + self.assertEqual(default_headers["X-DashScope-Wait-Timeout"], "30") + self.assertEqual(default_headers["X-Custom-Header"], "custom") + + config_without_headers = config.model_copy(update={"default_headers": None}) + with patch("memos.llms.openai.openai.Client") as mock_client: + QwenLLM(config_without_headers) + + default_headers = mock_client.call_args.kwargs["default_headers"] + self.assertEqual(default_headers["X-DashScope-Wait-Timeout"], "30") + def test_qwen_llm_generate_with_and_without_think_prefix(self): """Test QwenLLM non-streaming response generation with and without prefix removal.""" From e1380b841456046d702abab4712de3ab54dfdafb Mon Sep 17 00:00:00 2001 From: harvey_xiang Date: Thu, 20 Aug 2026 21:46:44 +0800 Subject: [PATCH 3/3] chore: update version to v2.0.31 --- pyproject.toml | 2 +- src/memos/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 0acbcc296..46723d239 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ ############################################################################## name = "MemoryOS" -version = "2.0.30" +version = "2.0.31" description = "Intelligence Begins with Memory" license = {text = "Apache-2.0"} readme = "README.md" diff --git a/src/memos/__init__.py b/src/memos/__init__.py index 0f6dec9f7..5d4adb823 100644 --- a/src/memos/__init__.py +++ b/src/memos/__init__.py @@ -1,4 +1,4 @@ -__version__ = "2.0.30" +__version__ = "2.0.31" from memos.configs.mem_cube import GeneralMemCubeConfig from memos.configs.mem_os import MOSConfig