Skip to content

fix(embeddings): leave out every embedding fallback but Ollama behind Ollama (#853) - #865

Merged
goruck merged 1 commit into
mainfrom
fix/openai-compatible-embedding-fallback
Oct 26, 2026
Merged

goruck merged 1 commit into
mainfrom
fix/openai-compatible-embedding-fallback

Conversation

@goruck

@goruck goruck commented Oct 26, 2026

Copy link
Copy Markdown
Owner

Closes #853.

What was wrong

Setup builds one embedding client per provider type (one per server for Ollama). A second OpenAI-compatible server in the embedding chain therefore got the primary's own client. After the #751 review, the chain dropped it as a duplicate and logged nothing, so the fallback the user picked was never used. A second OpenAI or Gemini provider was dropped the same way.

Decision

We are not giving each OpenAI-compatible server its own client. Instead this enforces the rule that the #751 form and repair text already state: an embedding fallback is kept only when the primary and the fallback are both Ollama. Each Ollama server's build of the model is checked against the primary's (#855). Two OpenAI-compatible servers can serve different weights under the same model name, and nothing can check that, so failing over between them could mix models in the memory store without anyone noticing.

Changes

Users who saved a same-type non-Ollama embedding fallback before #751 will now see the repair issue after upgrading. Saving the Embeddings feature clears it.

Testing

  • make lint passes and make typecheck reports 0 errors. make test: 6470 passed, 1 skipped.
  • New tests:
    • unit: no fallback is kept behind an OpenAI-compatible, OpenAI or Gemini primary
    • setup, chosen fallback: a same-type fallback (all three types) raises the repair with a WARNING, and the size check measures the primary only
    • setup, automatic fallback: the same case logs at INFO and raises no repair
    • the size-check tests are rewritten for the primary-only check
  • The new tests fail without the resolver change.
  • Not field-tested. The test box has an Ollama primary, so this code path doesn't run there.

Review

gstack /review converged after 3 cycles (2 of them made edits).

  • Codex adversarial: clean in all 3 cycles.
  • Claude adversarial, red team, and the testing, maintainability, security, performance and simplification specialists ran in every cycle. Every confirmed finding was fixed.
  • Three low items were skipped by choice:
    • a now-dead wrapper, _embedding_instance_for_provider
    • a guard for the size check's assumption that the chain's head type equals the configured primary type, which holds today
    • an existing catch-all branch that treats an unknown embedding provider type as Ollama

Ships in the 3.45.0 bundle.

🤖 Generated with Claude Code

https://claude.ai/code/session_019kuwyteUa5Q6rkkB8hgwwj

… Ollama

Closes #853.

Setup builds one embedding client per provider type (per server for
Ollama), so a second OpenAI-compatible, OpenAI or Gemini provider in the
embedding chain resolved to the primary's own client and was dropped by
the chain's identity check without a word. Rather than give each
OpenAI-compatible server its own client, enforce the rule the #751 form
and repair text already state: split_embedding_chain keeps a fallback
only when it and the primary are both Ollama, whose build is checked
against the primary's (#855). Two OpenAI-compatible servers can serve
other weights under one model name, which nothing can check.

- A chosen fallback left out raises the embedding_fallback_other_model
  repair (WARNING); one HGA added on its own logs at INFO. The repair
  text now gives both reasons: no failover for a second OpenAI or Gemini
  provider, possibly mixed models otherwise (en, cs, zh-Hans).
- The size check (#760) measures only a non-Ollama primary, with the
  primary's own client. The fallback size issue, added after the last
  pre-release and never raised, is removed with its strings.
- Text that still described Ollama fallbacks behind a non-Ollama primary
  (the Ollama fallback size repair, docs, code comments) is updated.
- TODOS: the size issue is cleared on every unload, so an unmeasured
  primary loses it across a reload (pre-existing, #760).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019kuwyteUa5Q6rkkB8hgwwj
@claude

claude Bot commented Oct 26, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

🤖 Generated with Claude Code

@goruck
goruck merged commit 2cb5008 into main Oct 26, 2026
11 checks passed
@goruck
goruck deleted the fix/openai-compatible-embedding-fallback branch October 26, 2026 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Embeddings: a second OpenAI-compatible fallback is never used; its calls go to the primary's server

1 participant