Skip to content

LongMemEval judge drops a correct answer unless the model returns raw JSON #2525

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/longmemeval/lme_eval.py lme_grader parses the judge reply with json.loads(message_content)["label"]. The judge prompt in evaluation/scripts/utils/prompts.py (LME_JUDGE_MODEL_TEMPLATE) asks the model to write a one-sentence explanation and then a JSON label. A reply that follows that prompt is not raw JSON, so json.loads raises JSONDecodeError.

process_qa has no handler for that exception. main catches it, prints [ERROR] Processing user failed: ..., and does not record a judgment. evaluate_accuracy then reports No responses were evaluated. LLM-as-a-Judge score: N/A (0/0). lme_metric.py prints that missing result as score 0.0000 over 0 questions.

LoCoMo's grader in evaluation/scripts/locomo/locomo_eval.py already extracts a {"label": ...} object from surrounding text with extract_label_json. The same judge text that LoCoMo accepts is rejected by LongMemEval.

On a one-question LongMemEval smoke run, the generated answer was Business Administration, matching the gold answer, and the judge step failed with Expecting value: line 1 column 1 (char 0). An empty model body and a prose-plus-JSON body both raise that same error, so a transient empty completion and a normal explanation-plus-JSON completion are not distinguishable in the log. Either one drops the sample. The failure is in the parser, not only in the gateway.

How to Reproduce | 如何重现

  1. Use evaluation/scripts/longmemeval/lme_eval.py lme_grader on commit a7367d07.
  2. Stub the chat client so message.content is The generated answer matches the gold answer.\n{"label": "CORRECT"}.
  3. Call lme_grader with question What degree did I graduate with?, gold Business Administration, and the same text as the generated answer.
  4. Observed: JSONDecodeError: Expecting value: line 1 column 1 (char 0). The sample is not stored, and the summary is N/A (0/0).
  5. Pass that same string to LoCoMo extract_label_json. Observed: it returns {"label": "CORRECT"}.
  6. Repeat step 2 with message.content == "". Observed: the same JSONDecodeError, and again no recorded judgment.

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:modelllm + embedder + reranker
    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: 0ee609f367fb34cc
    Working branch: bugfix/autodev-2525-20261021095904941
    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. Memtensor-AI commented on Oct 21, 2026

    @Memtensor-AI
    Collaborator

    ✅ AutoDev task 0ee609f367fb34cc completed.

    Summary: Fixed issue #2525: LongMemEval's lme_grader was passing the full judge chat completion into json.loads(...)["label"], but the judge prompt (LME_JUDGE_MODEL_TEMPLATE) asks the model for one sentence of reasoning followed by a {"label": "..."} snippet. Any prompt-compliant reply therefore raised JSONDecodeError: Expecting value: line 1 column 1 (char 0); the exception bubbled to main, which dropped the sample and degraded the summary to N/A (0/0). LoCoMo had already solved the same prompt shape with extract_label_json; LongMemEval had not.

    The fix introduces a shared evaluation/scripts/utils/judge.py with extract_label_json (same regex semantics as LoCoMo's) and parse_judge_label, which returns the label string on success and raises ValueError with a 200-byte quoted preview of the raw content on empty / no-label replies — making a transient empty completion visibly different from a prose-only reply in the [ERROR] Processing user failed: log line. lme_grader now calls parse_judge_label; locomo_grader was rewired to the same helper (behaviour preserved by the existing try/except) so the two codepaths cannot drift again. The judge prompt itself was not changed.

    Tests: 12 unit tests on parse_judge_label (raw JSON, prose+JSON reproduction from the issue, single-quoted value, empty, None, no-label, long content preview truncation) plus 4 integration tests driving lme_grader through a mocked OpenAI client — eval-only deps (bert_score, sentence_transformers, rouge_score) are stubbed in sys.modules so the suite runs under the standard test extras without poetry install --with eval. pytest tests/evaluation/longmemeval: 17/17 passed. Combined with unrelated tests (tests/test_hello_world.py, tests/test_log.py): 33/33 passed. ruff check and ruff format --check both clean on all touched files. No src/memos/ or docs/openapi.json edits.

    Base branch: main
    Branch: bugfix/autodev-2525-20261021095904941
    Commit: a0acd63
    PR: #2528
    Assigned to: @CarltonXiang
    Reviewers: @endxxxx

  5. 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:modelllm + embedder + rerankerstatus: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