Skip to content

fix(mem0): merge env vars with mem0.json instead of either/or (salvage #4836)#4939

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-a82207c8
Apr 4, 2026
Merged

fix(mem0): merge env vars with mem0.json instead of either/or (salvage #4836)#4939
teknium1 merged 2 commits into
mainfrom
hermes/hermes-a82207c8

Conversation

@teknium1

@teknium1 teknium1 commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Salvage of PR #4836 by @ellenlivia-mem0 with a truthiness fix on top.

The bug

hermes memory status shows mem0 as "not available" even when MEM0_API_KEY is set in .env. The cause: _load_config() treats mem0.json and env vars as mutually exclusive. If mem0.json exists (created by hermes memory setup with just user_id/agent_id), it returns that file and never checks env vars — so api_key is silently empty.

The fix

Env vars provide defaults, mem0.json overrides individual keys on top. Both sources work together.

Our follow-up

Changed the merge filter from if v (truthiness) to if v is not None and v != "". The original would silently drop False and 0 from the JSON — so "rerank": false in mem0.json would be ignored, stuck on the default True.

E2E verified (7 cases)

  • Env vars only (no json) → works
  • api_key in env + user/agent in json (the bug case) → both merge correctly
  • JSON overrides env when both set
  • Empty string in json doesn't clobber env default
  • False in json preserved (the truthiness fix)
  • Integer 0 in json preserved
  • null in json doesn't clobber env default

Closes #4836

liviaellen and others added 2 commits April 3, 2026 20:34
When mem0.json exists but is missing the api_key (e.g. after running
`hermes memory setup`), the plugin reports "not available" even though
MEM0_API_KEY is set in .env.  This happens because _load_config()
returns the JSON file contents verbatim, never falling back to env vars.

Use env vars as the base config and let mem0.json override individual
keys on top, so both config sources work together.

Fixes: mem0 plugin shows "not available" despite valid MEM0_API_KEY in .env
…merge

The original filter (if v) silently drops False and 0, so
'rerank: false' in mem0.json would be ignored. Use explicit
None/empty-string check to preserve intentional falsy values.
@teknium1 teknium1 merged commit 585a3b4 into main Apr 4, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants