Skip to content

Fix API embedding fallback order and cache isolation#26

Merged
AVIDS2 merged 1 commit intoAVIDS2:mainfrom
RaviTharuma:fix/embedding-api-fallback-cache-key
Mar 27, 2026
Merged

Fix API embedding fallback order and cache isolation#26
AVIDS2 merged 1 commit intoAVIDS2:mainfrom
RaviTharuma:fix/embedding-api-fallback-cache-key

Conversation

@RaviTharuma
Copy link
Copy Markdown
Contributor

Summary

This fixes two related embedding issues:

  • MEMORIX_EMBEDDING=auto now prefers a configured remote embedding API before falling back to local providers
  • API embedding caches are now isolated by embedding config, including requested dimensions

Closes #25.

What changed

  • added API-first resolution in auto mode when embedding API config is present
  • namespaced API embedding cache keys by baseUrl + model + requestedDimensions
  • namespaced probe-dimension cache entries by the same identity
  • kept backward-compatible reads for the previous probe-dimension cache file shape
  • added regression tests for API-first auto mode, cache isolation, and requested-dimension probe isolation
  • documented the behavior change in docs/CONFIGURATION.md and CHANGELOG.md

Verification

Passed:

  • npx vitest run tests/embedding/provider.test.ts tests/embedding/api-provider.test.ts
  • npm run lint
  • npm run build
  • npx vitest run tests/integration/release-blockers.test.ts tests/git/extractor.test.ts tests/git/subdir-scan.test.ts

Note on remaining local failures:

  • tests/git/extractor.test.ts
  • tests/git/subdir-scan.test.ts

Those still fail in my local fork because the assertions are hard-coded to the upstream remote (AVIDS2/memorix) and to a specific sibling-repo layout, while this branch is running from RaviTharuma/memorix inside a workspace that also contains CLIProxyAPI. They are unrelated to this patch.

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Copy link
Copy Markdown
Owner

@AVIDS2 AVIDS2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我手动对照了当前 main 和这次修复的目标,两个核心问题在主线里都是真实存在的:

  1. MEMORIX_EMBEDDING=auto 目前仍然优先本地 fastembed / transformers,不会在 API embedding 已配置时优先走远端 API。
  2. API embedding cache 与 probe-dimension cache 目前没有按完整 embedding config(尤其是 requestedDimensions)隔离,存在 stale cache 复用风险。

这条 PR 的修复范围集中、方向正确,而且把测试和文档一起补上了:

  • auto 改为 API-first(当 embedding API 配置存在时)
  • embedding cache 与 probe-dimension cache 按 baseUrl + model + requestedDimensions 隔离
  • 保留旧 probe cache 结构的兼容读取
  • 增加了对应回归测试

我已经手动复审过,批准这条 PR。感谢这次补得很扎实。

@AVIDS2 AVIDS2 merged commit b8f47c5 into AVIDS2:main Mar 27, 2026
5 checks passed
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.

Make auto embeddings API-first and isolate caches by embedding config

2 participants