fix(mem0): merge env vars with mem0.json instead of either/or (salvage #4836)#4939
Merged
Conversation
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.
This was referenced Apr 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Salvage of PR #4836 by @ellenlivia-mem0 with a truthiness fix on top.
The bug
hermes memory statusshows mem0 as "not available" even whenMEM0_API_KEYis set in.env. The cause:_load_config()treatsmem0.jsonand env vars as mutually exclusive. Ifmem0.jsonexists (created byhermes memory setupwith justuser_id/agent_id), it returns that file and never checks env vars — soapi_keyis silently empty.The fix
Env vars provide defaults,
mem0.jsonoverrides individual keys on top. Both sources work together.Our follow-up
Changed the merge filter from
if v(truthiness) toif v is not None and v != "". The original would silently dropFalseand0from the JSON — so"rerank": falseinmem0.jsonwould be ignored, stuck on the defaultTrue.E2E verified (7 cases)
Falsein json preserved (the truthiness fix)0in json preservednullin json doesn't clobber env defaultCloses #4836