fix(mem0-plugin): store assistant-authored summaries with role="assistant" (#6316)

This commit is contained in:
Kartik
2026-07-14 20:03:36 +05:30
committed by GitHub
parent 6c1741e3a4
commit d6d2588ef5
14 changed files with 197 additions and 19 deletions
@@ -104,8 +104,11 @@ def store_summary(api_key: str, summary: str, user_id: str, session_id: str, pro
}
if branch:
metadata["branch"] = branch
# The compact summary is model-authored prose, in the first person and with no
# framing to mark it as such. Under role="user" mem0 reads "I recommend X" as
# the human saying it and stores "User recommends X".
body = {
"messages": [{"role": "user", "content": summary}],
"messages": [{"role": "assistant", "content": summary}],
"user_id": user_id,
"app_id": project_id,
"metadata": metadata,
@@ -175,8 +175,12 @@ def store_summary(
if files:
metadata["files_touched"] = files[:20]
# summary_prompt wraps the assistant's own last message. Mem0 extracts "facts
# about the user" from each message and role is the only signal telling it who
# spoke, so role="user" here turns Claude's opinions into the human's stated
# preferences ("User prefers dropping Redis...").
body = {
"messages": [{"role": "user", "content": summary_prompt}],
"messages": [{"role": "assistant", "content": summary_prompt}],
"user_id": user_id,
"app_id": project_id,
"run_id": session_id,