When deploying Mem0 on AWS Lambda, you need to adjust the storage directory because Lambda only allows writing to the /tmp directory. By default, Mem0 tries to write to a directory in the user's home path, which isn’t writable in Lambda.
Set the MEM0_DIR environment variable to a writable path in /tmp.
MEM0_DIR=/tmp/.mem0
If you're not using environment variables, modify the storage path directly in your code.
Change this:
home_dir = os.path.expanduser("~")
mem0_dir = os.environ.get("MEM0_DIR") or os.path.join(home_dir, ".mem0")
To this:
mem0_dir = os.environ.get("MEM0_DIR", "/tmp/.mem0")
Refer the doc for more info: https://docs.mem0.ai/faqs#how-do-i-configure-mem0-for-aws-lambda