fix(memory): harden embedding reindex recovery - #1966
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
🚧 Files skipped from review as they are similar to previous changes (5)
📝 WalkthroughWalkthroughEmbedding operations now support cancellation and adaptive batch sizing. Memory reindexing records structured outcomes and sanitized errors, exposes them through status APIs, and displays localized retry diagnostics in the settings panel. ChangesEmbedding runtime and cancellation
Memory reindex lifecycle
Diagnostics UI
Estimated code review effort: 5 (Critical) | ~120 minutes Sequence Diagram(s)sequenceDiagram
participant MemoryPresenter
participant LLMProviderPresenter
participant AiSdkProvider
participant EmbeddingPipeline
participant MemoryDiagnosticsPanel
MemoryPresenter->>LLMProviderPresenter: request embeddings with AbortSignal
LLMProviderPresenter->>AiSdkProvider: forward cancellation signal
AiSdkProvider->>EmbeddingPipeline: provide embedding results or errors
EmbeddingPipeline->>EmbeddingPipeline: record reindex outcome
EmbeddingPipeline->>MemoryDiagnosticsPanel: expose lastReindex through status
MemoryDiagnosticsPanel->>MemoryPresenter: request retry
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/presenter/llmProviderPresenter/providers/aiSdkProvider.ts (1)
1196-1209: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winHonor cancellation before returning hard-coded dimensions.
These early returns never observe an already-aborted signal, so a cancelled reindex can continue past dimension resolution. Call
signal?.throwIfAborted()before the model-specific branches.Proposed fix
public async runDimensions(modelId: string, signal?: AbortSignal): Promise<LLM_EMBEDDING_ATTRS> { + signal?.throwIfAborted() + if (modelId === 'text-embedding-3-small' || modelId === 'text-embedding-ada-002') {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/main/presenter/llmProviderPresenter/providers/aiSdkProvider.ts` around lines 1196 - 1209, Update runDimensions to call signal?.throwIfAborted() before the model-specific hard-coded dimension branches, ensuring an already-aborted operation stops before either early return.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/main/presenter/memoryPresenter/infra/embeddingPipeline.ts`:
- Around line 949-952: Sanitize result.error before logging it in the failed
branch of the warmup flow. Reuse the existing toMemoryReindexError conversion to
redact provider credentials, then log the sanitized error instead of
String(result.error), while preserving clear agent context and the vector-store
readiness reset.
- Around line 1234-1241: Update the invalid-dimension error construction in the
embedding pipeline to preserve the stable `embedding-invalid` code even when
attrs.errorMsg is provided. Use the existing MemoryReindexFailure path with the
provider message as its diagnostic detail, while retaining the current fallback
message and invalid-dimension validation behavior.
---
Outside diff comments:
In `@src/main/presenter/llmProviderPresenter/providers/aiSdkProvider.ts`:
- Around line 1196-1209: Update runDimensions to call signal?.throwIfAborted()
before the model-specific hard-coded dimension branches, ensuring an
already-aborted operation stops before either early return.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 23f28468-8bd9-4476-a909-f0aee42a9705
📒 Files selected for processing (44)
src/main/presenter/configPresenter/modelCapabilities.tssrc/main/presenter/index.tssrc/main/presenter/llmProviderPresenter/aiSdk/embeddingBatchLimits.tssrc/main/presenter/llmProviderPresenter/aiSdk/runtime.tssrc/main/presenter/llmProviderPresenter/baseProvider.tssrc/main/presenter/llmProviderPresenter/index.tssrc/main/presenter/llmProviderPresenter/managers/embeddingManager.tssrc/main/presenter/llmProviderPresenter/providers/aiSdkProvider.tssrc/main/presenter/llmProviderPresenter/providers/ollamaProvider.tssrc/main/presenter/memoryPresenter/domain/types.tssrc/main/presenter/memoryPresenter/index.tssrc/main/presenter/memoryPresenter/infra/embeddingPipeline.tssrc/main/presenter/memoryPresenter/infra/reindexResult.tssrc/main/presenter/memoryPresenter/services/managementService.tssrc/renderer/settings/components/MemoryDiagnosticsPanel.vuesrc/renderer/src/i18n/da-DK/settings.jsonsrc/renderer/src/i18n/de-DE/settings.jsonsrc/renderer/src/i18n/en-US/settings.jsonsrc/renderer/src/i18n/es-ES/settings.jsonsrc/renderer/src/i18n/fa-IR/settings.jsonsrc/renderer/src/i18n/fr-FR/settings.jsonsrc/renderer/src/i18n/he-IL/settings.jsonsrc/renderer/src/i18n/id-ID/settings.jsonsrc/renderer/src/i18n/it-IT/settings.jsonsrc/renderer/src/i18n/ja-JP/settings.jsonsrc/renderer/src/i18n/ko-KR/settings.jsonsrc/renderer/src/i18n/ms-MY/settings.jsonsrc/renderer/src/i18n/pl-PL/settings.jsonsrc/renderer/src/i18n/pt-BR/settings.jsonsrc/renderer/src/i18n/ru-RU/settings.jsonsrc/renderer/src/i18n/tr-TR/settings.jsonsrc/renderer/src/i18n/vi-VN/settings.jsonsrc/renderer/src/i18n/zh-CN/settings.jsonsrc/renderer/src/i18n/zh-HK/settings.jsonsrc/renderer/src/i18n/zh-TW/settings.jsonsrc/shared/contracts/routes/memory.routes.tssrc/shared/types/presenters/core.presenter.d.tssrc/shared/types/presenters/llmprovider.presenter.d.tstest/main/presenter/llmProviderPresenter/aiSdkRuntime.test.tstest/main/presenter/llmProviderPresenter/embeddingBatchLimits.test.tstest/main/presenter/memory/embeddingPipeline.test.tstest/main/presenter/memory/managementService.test.tstest/main/presenter/memory/reindexResult.test.tstest/renderer/components/MemoryDiagnosticsPanel.test.ts
Summary by CodeRabbit