You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
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
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_nameprefers 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
Setting the override changes active_embedding_model() without a restart (test).
No production reader of the embedding model bypasses active_embedding_model(); a guard pins this.
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.
AC evidence (origin/main 129148e, delivered by #19383 in train 85a). All four ticked:
Override changes the model without a restart:autobot_shared/embedding_model.py:128set_embedding_model_override; active_embedding_model() (:145) reads the override first. Guard: autobot_shared/embedding_model_override_19377_test.py:44.
No production reader bypasses the resolver:repo_tests/embedding_model_one_resolver_19377_test.py:71 scans every tracked non-test .py (asserting more than 1000 enumerated), with detector controls.
Activity
mrveiss commentedon Oct 23, 2026
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.
fix(train): train-85a CI — the guard sweep lives in _guard_import so …
Merge pull request #19425 from mrveiss/train-2026-10-23-85a
mrveiss commentedon Oct 25, 2026
AC evidence (origin/main 129148e, delivered by #19383 in train 85a). All four ticked:
autobot_shared/embedding_model.py:128set_embedding_model_override;active_embedding_model()(:145) reads the override first. Guard:autobot_shared/embedding_model_override_19377_test.py:44.repo_tests/embedding_model_one_resolver_19377_test.py:71scans every tracked non-test.py(asserting more than 1000 enumerated), with detector controls.autobot-backend/knowledge/embedding_model_resolution.py:22-38(a warning naming feat(kb): switching the embedding model rebuilds into a new collection in the background and cuts over on completion #19379). Guard:embedding_model_resolution_test.py:15._apply_embedding_confighas 0 hits on main;PUT /api/embeddings/settingsreturns 409 (api/embeddings.py:120); dispositions are in the refactor(kb): one runtime embedding-model resolver with a user override; readers routed through it; dead copies retired (#19377) #19383 body. Note:api/embeddings.pystill reads thebackend.llm.unified.embeddingblock for provider and endpoint (not the model).github-actions commentedon Oct 28, 2026
Landed in train train-2026-10-28-86b (#19880, merge
0b473f2ed5) via #19641