Skip to content

fix: send session_id in LongMemEval add requests - #2410

Open
wangxinyufighting wants to merge 1 commit into
MemTensor:mainfrom
wangxinyufighting:fix/longmemeval-add-api-contract
Open

wangxinyufighting wants to merge 1 commit into
MemTensor:mainfrom
wangxinyufighting:fix/longmemeval-add-api-contract

Conversation

@wangxinyufighting

Copy link
Copy Markdown

Description

Fix the session ID field sent by the evaluation client's MemosApiClient.add() to the open-source /product/add endpoint.

Problem

LongMemEval ingestion passes its session ID through the conv_id argument. However, the client serializes it as conversation_id, while APIADDRequest expects session_id.

The unrecognized field is ignored, so the server falls back to default_session instead of preserving the original session ID.

Implementation

  • Change the request payload key from conversation_id to session_id.
  • Keep the existing conv_id argument and call sites unchanged.
  • Add a regression test that inspects the serialized HTTP request.

This change does not modify the server API, asynchronous ingestion behavior, or the MemOS Cloud client.

Dependencies: No new dependencies.

Related Issue (Required): None

Type of change

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

How Has This Been Tested?

  • Unit Test

The regression test mocks the HTTP request and verifies that the payload contains the expected session_id and no conversation_id.
It does not require a running MemOS server, database, or LLM service.

Before the fix:

  • The regression test fails with KeyError: 'session_id'.

After the fix:

  • The regression test and existing API model tests pass:
    4 passed, 1 warning.
  • Ruff lint checks pass.

Commands run from the repository root:

pytest -q tests/evaluation/test_longmemeval_add_api_contract.py tests/api/test_product_models.py
ruff check --no-cache evaluation/scripts/utils/client.py tests/evaluation/test_longmemeval_add_api_contract.py

Test environment: Python 3.11, pytest 9.0.2.
Pytest reports an Unknown config option: asyncio_mode warning.

These checks cover the focused fix; a full end-to-end benchmark was not run.

Checklist

  • I have performed a self-review of my own code
  • I have commented my code in hard-to-understand areas (N/A: the production change is a single payload-key correction)
  • I have added tests that prove my fix is effective
  • I have created related documentation issue/PR in MemOS-Docs (N/A: this fixes compliance with the existing API contract)
  • I have linked the issue to this PR
  • I have mentioned the person who will review this PR

Requested reviewer: None

Copilot AI lite review requested due to automatic review settings September 25, 2026 12:41
@Memtensor-AI Memtensor-AI added area:core MOS 编排层 / 框架底座 / 跨模块问题 status:in-progress Someone or AI is working on it | 人工或 AI 正在处理 labels Sep 25, 2026
@Memtensor-AI

Copy link
Copy Markdown
Collaborator

🤖 Open Code Review

Target: PR #2410
Task: 9d0ee616598c3ad0
Base: main
Head: fix/longmemeval-add-api-contract

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


1. tests/evaluation/test_longmemeval_add_api_contract.py (L12-L14)

Module-level assert is used for runtime validation of _CLIENT_SPEC and its loader. When Python runs with the -O flag, assertions are stripped entirely, so if spec_from_file_location returns None (e.g., the path is wrong), the subsequent exec_module call on line 14 will raise an AttributeError rather than a clear failure message.

Replace the assert with an explicit if/raise guard:

💡 Suggested Change

Before:

assert _CLIENT_SPEC is not None and _CLIENT_SPEC.loader is not None
_CLIENT_MODULE = importlib.util.module_from_spec(_CLIENT_SPEC)
_CLIENT_SPEC.loader.exec_module(_CLIENT_MODULE)

After:

if _CLIENT_SPEC is None or _CLIENT_SPEC.loader is None:
    raise RuntimeError(f"Cannot load client module from {_CLIENT_PATH}")
_CLIENT_MODULE = importlib.util.module_from_spec(_CLIENT_SPEC)
_CLIENT_SPEC.loader.exec_module(_CLIENT_MODULE)

Generated by cloud-assistant via Open Code Review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The focused fix is covered by a regression test and no unresolved issues were identified.

Review effort: Lite
Findings: None

What changed in this PR

Fixes LongMemEval ingestion by sending the session ID as session_id to /product/add.

Changes:

  • Corrects the payload key from conversation_id to session_id.
  • Adds a regression test for the serialized request.
File Summary
tests/​evaluation/​test_longmemeval_add_api_contract.py Verifies the corrected request payload contract.
evaluation/​scripts/​utils/​client.py Sends the session identifier as session_id.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@Memtensor-AI

Copy link
Copy Markdown
Collaborator

✅ Automated Test Results: PASSED

All tests passed (1/1 executed). memos_python_core/changed-repo-python: 1/1. Duration: 1s [advisory, non-gating] AI-generated tests on branch test/auto-gen-9d0ee616598c3ad0-20260925204429: 33/35 passed, 2 failed — these do NOT affect the PR verdict; review the branch manually.

Branch: fix/longmemeval-add-api-contract

@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 Sep 25, 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