Skip to content

feat: add configurable embedding dimensions for self-hosted providers #409

@kaitranntt

Description

@kaitranntt

Description

Embedding dimensions are hardcoded to 1536 (OpenAI standard) in both the pgvector schema and provider wiring. Self-hosted providers like Ollama with models that output different native dimensions (e.g. qwen3-embedding:8b at 4096) cannot be used for embeddings even though:

  1. The WithDimensions() plumbing already exists on OpenAIEmbeddingProvider
  2. Ollama's OpenAI-compatible endpoint supports the dimensions parameter for Matryoshka truncation
  3. The DB registry fallback path (createEmbeddingProvider → registry) creates providers without WithDimensions()

Root Cause

Commit 4db5259 added WithDimensions(1536) only for the Gemini case. The registry-based provider path (commit 1b99406) doesn't call WithDimensions() because all initial providers (OpenAI, OpenRouter) natively output 1536.

Affected Files

  • internal/config/config.goMemoryConfig struct missing EmbeddingDimensions field
  • cmd/gateway_agents.gocreateEmbeddingProvider() registry path doesn't apply dimensions

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions