Skip to content

[BUG] Ollama embeddings crash due to EnvConfig attribute mismatch #114

@evertvorster

Description

@evertvorster

What happened?

When configuring OpenMemory to use Ollama embeddings (OM_EMBED_KIND=ollama), memory ingestion fails immediately with an AttributeError before any HTTP request is made to Ollama.

The crash occurs because the Ollama adapter attempts to access env.ollama_base_url, which does not exist in EnvConfig. As a result, Ollama embeddings are unusable in the current release.

Steps to Reproduce

Ensure Ollama is running locally (default http://localhost:11434) and has an embedding model available (e.g. nomic-embed-text).

Run the following minimal script with Ollama embeddings enabled:

OM_EMBED_KIND=ollama
OM_OLLAMA_EMBEDDING_MODEL=nomic-embed-text:latest
python - <<'PY'
from openmemory.client import Memory
import asyncio

async def test():
mem = Memory()
await mem.add("probe text")

asyncio.run(test())
PY

Observe the crash during memory ingestion.

Component

AI/LLM Integration

Environment

OS: Arch Linux

Python: 3.13.7

OpenMemory: v1.3.x (installed via system site-packages)
(I created an Arch AUR package for the git version and latest release)

Ollama: Local instance at http://localhost:11434

Embedding model: nomic-embed-text (v1.5)

Relevant log output

Traceback (most recent call last):
  File "/usr/lib/python3.13/site-packages/openmemory/ai/ollama.py", line 8, in __init__
    self.base_url = base_url or env.ollama_base_url or "http://localhost:11434"
                                ^^^^^^^^^^^^^^^^^^^
AttributeError: 'EnvConfig' object has no attribute 'ollama_base_url'. Did you mean: 'database_url'?

Additional context (root cause)

openmemory/core/config.py defines the configuration attribute as env.ollama_url

openmemory/ai/ollama.py attempts to read env.ollama_base_url

This attribute mismatch causes an immediate crash whenever OM_EMBED_KIND=ollama is enabled

Suggested fix (backward-compatible)
base = getattr(env, "ollama_base_url", None) or getattr(env, "ollama_url", None)
self.base_url = base_url or base or "http://localhost:11434"

This supports both attribute names and prevents the crash.

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions