d7e2a0e7b0
The deterministic resolver from #5076 silently rebucketed every user who hadn't set MEM0_USER_ID. With MEM0_API_KEY present (the normal case — hooks early-exit without it), the resolver picked "mem0-<sha256(api_key)[:12]>" instead of $USER, so an existing "deshraj" bucket suddenly became "mem0-f34dd1cba657" on update with no migration. The old memories aren't reachable from the plugin anymore, and the user gets a fresh empty bucket without warning. Resolution priority is now back to: 1. MEM0_USER_ID env var 2. \$USER, else "default" The ~/.mem0/identity.json cache is no longer written or read; any existing cache file becomes inert. Users on multiple machines who want a single bucket can still set MEM0_USER_ID explicitly — that's the supported path, not silent derivation. Also dropped the "regardless of which machine you're on" line from the session bootstrap header since it no longer applies.
18 lines
349 B
Python
18 lines
349 B
Python
"""Resolve mem0 user_id.
|
|
|
|
Resolution priority:
|
|
1. MEM0_USER_ID env var (explicit override)
|
|
2. $USER, else "default"
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
|
|
|
|
def resolve_user_id() -> str:
|
|
explicit = os.environ.get("MEM0_USER_ID", "").strip()
|
|
if explicit:
|
|
return explicit
|
|
return os.environ.get("USER") or "default"
|