retrieve_strategy defaults to 'embedding' but embedding_retriever defaults to None, so a minimal config cannot construct LightMemory
Summary
BaseMemoryConfigs sets retrieve_strategy="embedding" by default, while embedding_retriever defaults to None. LightMemory.__init__ then builds the retriever unconditionally for that strategy, so constructing LightMemory with a minimal configuration fails with an AttributeError that does not name the missing setting.
Reproduction
Nothing is stubbed here; the only key supplied is the required memory_manager:
from lightmem.memory.lightmem import LightMemory
LightMemory.from_config({
"memory_manager": {
"model_name": "openai",
"configs": {"model": "gpt-4o-mini", "api_key": "sk-test"},
}
})
AttributeError: 'NoneType' object has no attribute 'model_name'
File ".../lightmem/factory/retriever/embeddingretriever/factory.py", line 25, in from_config
model_name = config.model_name
Verified on Python 3.11 with the pinned transformers==4.57.0.
Cause
In src/lightmem/configs/base.py:
retrieve_strategy: Optional[Literal["context", "embedding", "hybrid"]] = Field(
default="embedding", # non-None default
)
embedding_retriever: Optional[EmbeddingRetrieverConfig] = Field(
default=None, # but its config defaults to None
)
In src/lightmem/memory/lightmem.py:
if self.retrieve_strategy in ["embedding", "hybrid"]:
self.embedding_retriever = EmbeddingRetrieverFactory.from_config(self.config.embedding_retriever)
EmbeddingRetrieverFactory.from_config dereferences config.model_name immediately, so None raises. The same shape applies to retrieve_strategy="context", since context_retriever also defaults to None.
Notably the declared signature is def __init__(self, config: BaseMemoryConfigs = BaseMemoryConfigs()), which advertises that a default-constructed config is usable, but that default combination cannot construct.
The field description says the retriever config is "active only if retrieve_strategy is 'embedding' or 'hybrid'", which reads as though the pairing is optional, while in practice the default strategy makes it mandatory.
Impact
Any user starting from a minimal config, or following the documented default, hits an error that points at NoneType rather than at the configuration key they need to set. The shipped examples all specify retrieve_strategy together with a matching retriever config, which is why this is not visible in the repo's own scripts.
It also surfaces in test authoring: the test added in PR #75 has to pass retrieve_strategy=None explicitly to construct LightMemory at all.
Possible directions
I did not send a patch because the preferred behavior is a design decision. Options as I see them:
- Default
retrieve_strategytoNone, matchingindex_strategy, so retrieval is opt-in and a minimal config constructs. - Keep the default and raise a validation error naming the missing key, for example "retrieve_strategy='embedding' requires embedding_retriever to be configured".
- Add a
model_validatoronBaseMemoryConfigsthat checks the strategy and its retriever config together, so the error arrives at config-validation time rather than mid-initialization.
Happy to open a PR for whichever direction you prefer.