Skip to content

init: --provider flags required even when config.json has persisted embedding settings (DX) #203

@jamebobob

Description

@jamebobob

Running a BGE-M3 local embedding setup on v0.10.3 using the pluggable provider layer from #172. ~/.gbrain/config.json has the embedding settings persisted:

{
  "engine": "pglite",
  "database_path": "/home/user/.gbrain/brain.pglite",
  "embedding": {
    "provider": "ollama",
    "model": "bge-m3",
    "dimensions": 1024,
    "base_url": "http://localhost:8085/v1"
  }
}

When PR #188 merged I wanted to apply the new schema migrations, so I ran gbrain init --pglite and got:

Cannot re-init: existing brain has a different embedding dimension.
  Existing: ollama / bge-m3 (1024d)
  Requested: openai / text-embedding-3-large (1536d)

The "Existing" line proves config.json was read somewhere in the flow. The "Requested" line is the baked default, not anything I passed on the CLI. So every re-init fails unless I repeat the flags I already wrote down in the config file.

Workaround:

gbrain init --pglite --provider ollama --model bge-m3 --dimensions 1024 --base-url http://localhost:8085/v1

Which works but feels like the config file is there for a reason.

Looking at src/commands/init.ts::resolveProviderWithGuard(), it calls resolveEmbeddingConfig(parseEmbeddingFlags(args)) using env vars and CLI flags, without threading the loaded config's embedding section in as defaults.

Rough shape of a fix:

const existing = loadConfig();
const defaults = existing?.embedding
  ? {
      provider: existing.embedding.provider,
      model: existing.embedding.model,
      dimensions: existing.embedding.dimensions,
      baseUrl: existing.embedding.base_url,
    }
  : {};
const resolved = resolveEmbeddingConfig({ ...defaults, ...parseEmbeddingFlags(args) });

Can take a crack at a PR if that shape looks right to you, or if you'd prefer a different fallback order let me know.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions