Skip to content

PrefEval drops a sample when search returns no text memories, so the judge gets an empty file #2526

Open

Description

@JunfengRan

Pre-submission checklist | 提交前检查

  • I have searched existing issues and this hasn't been mentioned before
  • I have read the project documentation and confirmed this issue doesn't already exist
  • This issue is specific to MemOS and not a general software issue

Bug Description | 问题描述

evaluation/scripts/PrefEval/pref_memos.py search_memory_for_line always reads relevant_memories["text_mem"][0]["memories"]. A successful search payload with "text_mem": [] raises IndexError: list index out of range. The except block prints the error and returns None.

The search, response, and add writers keep a row only when if result: is true. A None result is not written. generate_response_for_line does the same on an API error: it prints the error and returns None, so that row is also omitted.

evaluation/scripts/PrefEval/pref_eval.py then opens the response file, sees no lines, prints Error: Input file is empty., and returns before any judge call. An empty memory list, which the response function itself treats as valid when retrieved_memories_text is "", never reaches the judge. A failed answer call is also dropped instead of being recorded as an error row.

On a two-row PrefEval smoke run, one search returned no text_mem and logged list index out of range. The other row reached answer generation, the chat gateway returned HTTP 503, and that exception also returned None. The response file was 0 bytes, and pref_eval.py reported an empty input. The 503 is an environment failure. The missing judge input is the script discarding the row. The empty-text_mem crash happens with a healthy model as well.

How to Reproduce | 如何重现

  1. From evaluation/, import search_memory_for_line in evaluation/scripts/PrefEval/pref_memos.py on commit a7367d07.
  2. Call it with a client whose search returns {"text_mem": [], "pref_string": ""} and a JSONL line {"user_id": "u1", "question": "What should I study?", "metrics": {}}.
  3. Observed: Error searching memory for line 1 (user_id: u1): list index out of range, and the function returns None.
  4. The search writer (if result: outfile.write(...)) writes 0 lines.
  5. Run evaluation/scripts/PrefEval/pref_eval.py on that empty response file.
  6. Observed: Error: Input file is empty. No judge prompt is sent.

Environment | 环境信息

  • Python version: 3.12.15
  • Operating System: macOS (darwin)
  • MemOS version: MemoryOS 2.0.33 (commit a7367d07)

Willingness to Implement | 实现意愿

  • I'm willing to implement this myself

Activity

  1. added
    ai:taskDispatched to AI coding agent | 已派发给 AI 编码任务
    area:coreMOS 编排层 / 框架底座 / 跨模块问题
    status:in-progressSomeone or AI is working on it | 人工或 AI 正在处理
    types:bugSomething isn't working | 功能异常
    on Oct 21, 2026
  2. self-assigned this
    on Oct 21, 2026
  3. Memtensor-AI commented on Oct 21, 2026

    @Memtensor-AI
    Collaborator

    🤖 AutoDev has picked up this issue and started working on it.

    Task ID: 1e7e18e1535eb444
    Working branch: bugfix/autodev-2526-20261021095907885
    Target branch: latest dev* branch
    Workflow: opsp (analysis → coding → testing → PR)

    I will post the PR link here once done. If I need more information, I will ask in the comments.

  4. added a commit that references this issue on Oct 21, 2026
    1602f82
  5. Memtensor-AI commented on Oct 21, 2026

    @Memtensor-AI
    Collaborator

    ✅ AutoDev task 1e7e18e1535eb444 completed.

    Summary: Fixes #2526. evaluation/scripts/PrefEval/pref_memos.py no longer drops PrefEval rows when the MemOS product search returns an empty text_mem list, nor when the chat gateway raises on the answer call. search_memory_for_line now defensively extracts the first text_mem bucket's memories (empty list → retrieved_memories_text = "" + pref_string, which is the "no retrieved memories" state the response stage already treats as valid). Both search_memory_for_line and generate_response_for_line annotate the row with an error field instead of returning None on exception, and the response helper also sets response = "" so pref_eval.py's judge (data["response"]) still fires — classifying the failed call as Unhelpful Response, the correct accounting for an upstream API failure.

    Added tests/evaluation/test_pref_memos.py with 5 pytest cases: empty text_mem keeps the row with the right retrieved_memories_text; search exception keeps the row with error + empty retrieved_memories_text; OpenAI exception keeps the row with error + response = ""; search-flagged pass-through row gains an empty response key (no OpenAI call); and a happy-path regression test pinning the pre-existing "- mem_1\n- mem_2\npref-string-X" output format. All 5 tests fail against the unmodified file (4 as the bug and 1 as the pass-through gap) and pass after the fix. ruff format and ruff check are clean on both touched files.

    opsp artifacts live under .ai-tasks/ and openspec/changes/ (excluded from the working branch via .git/info/exclude) and have been archived to the sibling memos-autodev-specs repo under 2026-10-21-2526-prefeval-drops-a-sample-when-search-returns-no-text-memories/ and pushed to main.

    Base branch: main
    Branch: bugfix/autodev-2526-20261021095907885
    Commit: 1602f82
    PR: #2530
    Assigned to: @CarltonXiang
    Reviewers: @WeiminLee

  6. added
    ai:testingAI agent is running tests | AI 正在运行测试
    and removed
    ai:codingAI agent is coding | AI 正在编码
    on Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

ai:taskDispatched to AI coding agent | 已派发给 AI 编码任务ai:testingAI agent is running tests | AI 正在运行测试area:coreMOS 编排层 / 框架底座 / 跨模块问题status:in-progressSomeone or AI is working on it | 人工或 AI 正在处理types:bugSomething isn't working | 功能异常

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions