Skip to content

refactor(kb): one runtime embedding-model resolver -- a user override over the SSOT default, every reader routed through active_embedding_model(), the dead second sources retired #19377

Closed

Description

@mrveiss

Part of #19373 (owner, 2026-10-23: "user can switch llm providers at any moment").

Problem

The embedding model is decided in several places, and no runtime switch can work until there is one:

  • autobot_shared.embedding_model.active_embedding_model() returns config.llm.embedding_model (env and .env only; reload_config re-reads .env).
  • KB init: knowledge/base.py:268 _resolve_embedding_model_name prefers the model found in stored facts' metadata (_detect_stored_embedding_model, :659) over config, and :285 reads SSOT directly. A config change alone therefore never switches the KB.
  • services/knowledge/org_knowledge_config.py:144 reads SSOT directly; only doc_indexer uses the org override.
  • Dead second sources: PUT /api/embeddings/settings writes backend.llm.unified.embedding.* to settings.json, which nothing outside api/embeddings.py reads; api/llm.py _apply_embedding_config (:320) is unused behind 410 routes.

Fix

  • Override: one runtime-mutable override (a ConfigRegistry key or an equivalent single store) that active_embedding_model() consults before the SSOT default.
  • One resolver: every reader goes through active_embedding_model(): KB init, org config fallback, search, vectorizer, npu_client.
  • Stored metadata: KB init's stored-model detection keeps the stored model (its vectors were made with it) and warns loudly when it differs from the active model.
  • Retire the dead sources: the settings.json embedding block and the unused api/llm.py helper. Wire or remove each, with each disposition stated.

Acceptance criteria

Activity

  1. added
    enhancementNew feature or request
    phase:M1.4Wizard and SLM: choose a mode, apply it, default models work
    on Oct 23, 2026
  2. mrveiss commented on Oct 23, 2026

    @mrveiss
    OwnerAuthor

    AC3 reworded while implementing. "Never silently adopted" would mean the KB switches to the configured model while its stored vectors were made with another, so queries and stored vectors stop being comparable. The stored model is now kept AND reported with a warning naming both models and the switch (#19379). Changing it remains the rebuild-and-cutover flow's job.

  3. added a commit that references this issue on Oct 24, 2026
  4. mrveiss commented on Oct 25, 2026

    @mrveiss
    OwnerAuthor

    AC evidence (origin/main 129148e, delivered by #19383 in train 85a). All four ticked:

  5. github-actions commented on Oct 28, 2026

    @github-actions
    Contributor

    Landed in train train-2026-10-28-86b (#19880, merge 0b473f2ed5) via #19641

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendenhancementNew feature or requestphase:M1.4Wizard and SLM: choose a mode, apply it, default models work

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions