Skip to content

route suggestion and scheduler LLM configs by model & update env examples and readmes - #2282

Merged
bittergreen merged 3 commits into
MemTensor:dev-v2.0.32from
bittergreen:wq-dev-v2.0.32
Aug 26, 2026
Merged

route suggestion and scheduler LLM configs by model & update env examples and readmes#2282
bittergreen merged 3 commits into
MemTensor:dev-v2.0.32from
bittergreen:wq-dev-v2.0.32

Conversation

@bittergreen

Copy link
Copy Markdown
Collaborator

Description

doc: update env examples and readmes
fix: route suggestion and scheduler LLM configs by model

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Documentation update

How Has This Been Tested?

  • Unit Test: tests/api/test_llm_provider_config.py etc

Checklist

  • I have performed a self-review of my own code | 我已自行检查了自己的代码
  • I have commented my code in hard-to-understand areas | 我已在难以理解的地方对代码进行了注释
  • I have added tests that prove my fix is effective or that my feature works | 我已添加测试以证明我的修复有效或功能正常
  • I have created related documentation issue/PR in MemOS-Docs (if applicable) | 我已在 MemOS-Docs 中创建了相关的文档 issue/PR(如果适用)
  • I have linked the issue to this PR (if applicable) | 我已将 issue 链接到此 PR(如果适用)
  • I have mentioned the person who will review this PR | 我已提及将审查此 PR 的人

Reviewer Checklist

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Made sure Checks passed
  • Tests have been provided

@Memtensor-AI Memtensor-AI added area:api 云服务 / FastAPI / OpenAPI / MCP area:core MOS 编排层 / 框架底座 / 跨模块问题 area:docs 文档、示例 area:scheduler 调度模块 status:in-progress Someone or AI is working on it | 人工或 AI 正在处理 labels Aug 25, 2026
@Memtensor-AI

Memtensor-AI commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

🤖 Open Code Review

Target: PR #2282
Task: 3da805fdb98d240b
Base: dev-v2.0.32
Head: wq-dev-v2.0.32

🔍 OpenCodeReview found 6 issue(s) in this PR.


1. src/memos/api/config.py (L477-L482)

The docstring states the fallback chain as MEMSCHEDULER_MODEL -> MEMREADER_GENERAL_MODEL, but get_memreader_general_llm_config() itself has a further fallback to the memreader config (i.e., MEMRADER_MODEL). The actual full chain is MEMSCHEDULER_MODEL -> MEMREADER_GENERAL_MODEL -> memreader config, which is inconsistent with the sibling get_suggestion_llm_config docstring that correctly documents all three hops.

💡 Suggested Change

Before:

    @staticmethod
    def get_scheduler_llm_config() -> dict[str, Any]:
        """Get LLM configuration for scheduler-owned LLM tasks.

        Fallback chain: MEMSCHEDULER_MODEL -> MEMREADER_GENERAL_MODEL.
        """

After:

    @staticmethod
    def get_scheduler_llm_config() -> dict[str, Any]:
        """Get LLM configuration for scheduler-owned LLM tasks.

        Fallback chain: MEMSCHEDULER_MODEL -> MEMREADER_GENERAL_MODEL -> memreader config.
        """

2. src/memos/configs/mem_scheduler.py (L217-L219)

When neither MEMSCHEDULER_MODEL nor MEMREADER_GENERAL_MODEL is set, default_model becomes "". This empty string is then passed to cls(default_model=default_model) and later written to os.environ["MODEL"] and os.environ["MEMSCHEDULER_MODEL"], causing any downstream API call that relies on the model name to fail at runtime.

The previous code had an explicit fallback of "gpt-4o-mini". The terminal or "" should be restored to a concrete default to preserve that behavior for users who have not set any model env var.

💡 Suggested Change

Before:

        default_model = (
            os.getenv("MEMSCHEDULER_MODEL") or os.getenv("MEMREADER_GENERAL_MODEL") or ""
        )

After:

        default_model = (
            os.getenv("MEMSCHEDULER_MODEL") or os.getenv("MEMREADER_GENERAL_MODEL") or "gpt-4o-mini"
        )

3. src/memos/mem_scheduler/analyzer/eval_analyzer.py (L62)

This code calls a private method (_build_provider_llm_config) from outside APIConfig, crossing a module boundary. Private methods are considered implementation details and can be renamed or restructured without warning. Since get_scheduler_llm_config() already resolves the model and its provider credentials, consider exposing a dedicated public method on APIConfig (e.g. get_eval_analyzer_llm_config(model)) instead of reaching into the private helper directly.

💡 Suggested Change

Before:

        provider_config = APIConfig._build_provider_llm_config(self.openai_model)["config"]

After:

        provider_config = APIConfig.build_provider_llm_config(self.openai_model)["config"]

4. tests/api/test_llm_provider_config.py (L136-L139)

The OPENAI_API_KEY and OPENAI_API_BASE set here serve no testing purpose. In this fallback test, the model is always resolved to qwen3.6-flash (from MEMREADER_GENERAL_MODEL), so _build_provider_llm_config only consults QWEN_API_*. The OpenAI vars are never read and never asserted against.

In test_task_specific_model_uses_provider_env the pattern is intentional: two competing providers are set to verify that the correct one wins. Here there is no such ambiguity — the model name alone determines the provider. Removing the stale OpenAI lines eliminates misleading noise and makes the test's env setup self-documenting.

💡 Suggested Change

Before:

    monkeypatch.setenv("OPENAI_API_KEY", "openai-key")
    monkeypatch.setenv("OPENAI_API_BASE", "https://openai.example/v1")

    config = getter()

After:

    config = getter()

5. tests/mem_scheduler/test_config.py (L206)

Typo in environment variable key: MEMRADER_MODEL is missing the letter E — it should be MEMREADER_MODEL. As written, this pop targets a key that almost certainly never exists, making it a silent no-op. If MEMREADER_MODEL happens to be set in the test runner's environment, it will not be cleared before OpenAIConfig.from_env() is called, which could cause self.assertEqual(config.default_model, "") to fail intermittently.

💡 Suggested Change

Before:

        os.environ.pop("MEMRADER_MODEL", None)

After:

        os.environ.pop("MEMREADER_MODEL", None)

6. tests/api/test_llm_provider_config.py (L136-L141)

In the fallback test, MEMREADER_GENERAL_MODEL is set to "qwen3.6-flash", so _build_provider_llm_config will always resolve to the qwen backend and only read QWEN_API_* credentials. The OPENAI_API_KEY and OPENAI_API_BASE values set here are never consulted and are never asserted against, making them pure noise.

This is different from test_task_specific_model_uses_provider_env, where setting both provider envs deliberately verifies that the correct one wins. Here there is no provider ambiguity — the model name alone determines the provider. Remove the unused OpenAI lines to keep the env setup self-documenting.

💡 Suggested Change

Before:

    monkeypatch.setenv("OPENAI_API_KEY", "openai-key")
    monkeypatch.setenv("OPENAI_API_BASE", "https://openai.example/v1")

    config = getter()

    assert config["backend"] == "qwen"

After:

    config = getter()

    assert config["backend"] == "qwen"

Generated by cloud-assistant via Open Code Review.

@Memtensor-AI

Copy link
Copy Markdown
Collaborator

⚠️ Automated Test Results: ENV ISSUE

The test environment encountered an issue that requires manual attention.

Details: Executor error: Command failed: git clone --depth 1 --branch wq-dev-v2.0.32 git@github.com:bittergreen/MemOS.git /data/test-workspaces/ef2daeae7f1a997a/repo
Cloning into '/data/test-workspaces/ef2daeae7f1a997a/repo'...
kex_exchange_identification: Connection closed by remote host
Connection closed by UNKNOWN port 65535
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Branch: wq-dev-v2.0.32

@Memtensor-AI

Copy link
Copy Markdown
Collaborator

⚠️ Automated Test Results: ENV ISSUE

The test environment encountered an issue that requires manual attention.

Details: Executor error: Command failed: git clone --depth 1 --branch wq-dev-v2.0.32 git@github.com:bittergreen/MemOS.git /data/test-workspaces/3da805fdb98d240b/repo
Cloning into '/data/test-workspaces/3da805fdb98d240b/repo'...
kex_exchange_identification: Connection closed by remote host
Connection closed by UNKNOWN port 65535
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Branch: wq-dev-v2.0.32

@Memtensor-AI

Copy link
Copy Markdown
Collaborator

✅ Automated Test Results: PASSED

All tests passed (46/46 executed, 1 skipped). memos_github_open_source/smoke: 1/1, memos_python_core/changed-repo-python: 45 passed, 1 skipped. Duration: 10s [advisory, non-gating] AI-generated tests: 99/99 passed.

Branch: wq-dev-v2.0.32

@Memtensor-AI Memtensor-AI added status:ready Ready for implementation; waiting for assignee or AI dispatch | 可进入实现,等待认领或派发 and removed status:in-progress Someone or AI is working on it | 人工或 AI 正在处理 labels Aug 26, 2026
@bittergreen
bittergreen merged commit 27e4bdb into MemTensor:dev-v2.0.32 Aug 26, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:api 云服务 / FastAPI / OpenAPI / MCP area:core MOS 编排层 / 框架底座 / 跨模块问题 area:docs 文档、示例 area:scheduler 调度模块 status:ready Ready for implementation; waiting for assignee or AI dispatch | 可进入实现,等待认领或派发

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants