Skip to content

fix(config): generate unique default identifiers - #2201

Open
JiataiWang wants to merge 3 commits into
MemTensor:dev-v2.0.29from
JiataiWang:fix/unique-config-identifiers
Open

fix(config): generate unique default identifiers#2201
JiataiWang wants to merge 3 commits into
MemTensor:dev-v2.0.29from
JiataiWang:fix/unique-config-identifiers

Conversation

@JiataiWang

Copy link
Copy Markdown

Description

MOSConfig.session_id and GeneralMemCubeConfig.cube_id currently call uuid.uuid4() when their modules are loaded. Pydantic then treats those generated strings as static defaults, so separate config instances created in the same process reuse the same identifier.

This switches both fields to default_factory. Explicit IDs and existing serialized configs keep the same behavior; only omitted IDs now get a fresh UUID per instance.

No dependencies are added. I couldn't find an existing issue or PR for this, and the contribution guide says small bug fixes can go directly to a PR.

Related Issue (Required): N/A

Type of change

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

How Has This Been Tested?

  • Unit Test
  • Test Script Or Test Steps

Local verification:

  • uv run --frozen --with 'pytest==8.3.5' pytest tests/configs/ -q — 39 passed
  • uv run --frozen --extra mem-reader --with 'pytest==8.3.5' pytest tests/mem_os/ -q — 36 passed (3 existing Pydantic serialization warnings)
  • uv run --frozen --with 'poetry>=2,<3' --with 'ruff==0.11.13' make format — Ruff passed; 617 files unchanged
  • git diff --check origin/dev-v2.0.29...HEAD — passed

Checklist

  • I have performed a self-review of my own code | 我已自行检查了自己的代码
  • I have commented my code in hard-to-understand areas (no hard-to-understand code added) | 我已在难以理解的地方对代码进行了注释
  • 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 (not applicable; no documentation behavior changed) | 我已在 MemOS-Docs 中创建了相关的文档 issue/PR(如适用)
  • I have linked the issue to this PR (not applicable; no existing issue found) | 我已将 issue 链接到此 PR(如适用)
  • I have mentioned the person who will review this PR | 我已提及将审查此 PR 的人

@WeiminLee when you have a moment, could you take a look?

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:core MOS 编排层 / 框架底座 / 跨模块问题 status:in-progress Someone or AI is working on it | 人工或 AI 正在处理 labels Aug 3, 2026
@Memtensor-AI
Memtensor-AI requested a review from WeiminLee August 3, 2026 13:45
@Memtensor-AI

Memtensor-AI commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

🤖 Open Code Review

Target: PR #2201
Task: 2d018f7ca2c29a15
Base: dev-v2.0.29
Head: fix/unique-config-identifiers

OpenCodeReview: No comments generated. Looks good to me.

Generated by cloud-assistant via Open Code Review.

@JiataiWang

Copy link
Copy Markdown
Author

Good catch to check. I reran this with the exact test setup: Pydantic v2 model_construct() calls field defaults with call_default_factory=True; both session_id values are strings, parse as UUIDv4, and differ. The same test failed before the fix because both instances received the same import-time UUID. I am using model_construct(chat_model=None, mem_reader=None) only to avoid the invalid empty defaults of the nested configs, not to bypass the session_id factory, so I am leaving the test as-is.

@Memtensor-AI

Copy link
Copy Markdown
Collaborator

⚠️ Automated Test Results: ENV ISSUE

The test environment encountered an issue that requires manual attention.

Details: Both failing tests cannot locate 'examples/data/mem_cube_2/config.json' relative to the current working directory, causing FileNotFoundError before any assertion runs. [advisory, non-gating] AI-generated tests on branch test/auto-gen-a546a3da2f1dfb5b-20260807153108: 66/66 passed — these do NOT affect the PR verdict; review the branch manually.
Branch: fix/unique-config-identifiers

@JiataiWang

Copy link
Copy Markdown
Author

Fixed the CWD dependency in 7e8769c: both tests now resolve the fixture relative to test_mem_cube.py. I reran that file from /private/tmp (3 passed), then the full config suite (39 passed) and mem_os suite (36 passed).

@Memtensor-AI

Copy link
Copy Markdown
Collaborator

✅ Automated Test Results: PASSED

All tests passed (4/4 executed). memos_python_core/changed-repo-python: 4/4. Duration: 5s [advisory, non-gating] AI-generated tests on branch test/auto-gen-2d018f7ca2c29a15-20260808102020: 61/61 passed — these do NOT affect the PR verdict; review the branch manually.

Branch: fix/unique-config-identifiers

@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 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core MOS 编排层 / 框架底座 / 跨模块问题 status:ready Ready for implementation; waiting for assignee or AI dispatch | 可进入实现,等待认领或派发

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants