Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

fix: guard against empty choices and message=None in LoCaMo LLM judge (#2096)

Jonathan Hill02a1de89935d
diff --git a/benchmark/locomo/mem0/eval.py b/benchmark/locomo/mem0/eval.py
index 24b1c155a..67fcb40b2 100644
--- a/benchmark/locomo/mem0/eval.py
+++ b/benchmark/locomo/mem0/eval.py
@@ -494,7 +494,12 @@ def judge_answer(
temperature=0,
timeout=60,
)
- content = resp.choices[0].message.content.strip()
+ if not resp.choices:
+ raise ValueError("LLM returned empty or filtered response")
+ message = resp.choices[0].message
+ if message is None or message.content is None:
+ raise ValueError("LLM returned empty or filtered response")
+ content = message.content.strip()
start, end = content.find("{"), content.rfind("}")
if start != -1 and end != -1:
parsed = json.loads(content[start : end + 1])
diff --git a/benchmark/locomo/supermemory/eval.py b/benchmark/locomo/supermemory/eval.py
index b9fbbe257..f7e6cd306 100644
--- a/benchmark/locomo/supermemory/eval.py
+++ b/benchmark/locomo/supermemory/eval.py
@@ -456,7 +456,12 @@ def judge_answer(
temperature=0,
timeout=60,
)
- content = resp.choices[0].message.content.strip()
+ if not resp.choices:
+ raise ValueError("LLM returned empty or filtered response")
+ message = resp.choices[0].message
+ if message is None or message.content is None:
+ raise ValueError("LLM returned empty or filtered response")
+ content = message.content.strip()
start, end = content.find("{"), content.rfind("}")
if start != -1 and end != -1:
parsed = json.loads(content[start : end + 1])