← Back to PRs

#19100: Fix memory vector store dimension mismatch by resetting index

by Clawborn open 2026-02-17 11:23 View on GitHub →
size: S trusted-contributor
## Description When switching embedding models (e.g. text-embedding-3-small to nomic-embed-text), the vector dimensions change, causing qmd update/embed commands to fail with 'dimension mismatch'. This leaves the memory system broken. ## Fix Detect dimension mismatch errors during update/embed loop, and automatically reset the index (delete index.sqlite) to trigger a full re-index. The repair is attempted once per manager lifetime to avoid infinite loops. Key improvement over previous attempt: `resetIndex()` does NOT call `this.close()`, which would permanently disable the memory manager after repair. ## AI Transparency - **Assisted by**: OpenClaw Agent (Claude Opus) - **Testing level**: Manual review + type check verification - **Prompt strategy**: Extracted targeted fix from multi-feature PR <!-- greptile_comment --> <h3>Greptile Summary</h3> Added automatic recovery for dimension mismatch errors that occur when switching embedding models. When `qmd update` or `qmd embed` fails with a dimension mismatch, the system now detects the error and resets the index by deleting the SQLite database files and re-initializing collections. The repair is attempted once per manager lifetime via the `attemptedDimensionMismatchRepair` flag to prevent infinite loops. Key improvements: - Detects dimension mismatch errors through pattern matching on error messages - `resetIndex()` closes the read-only DB handle without calling `this.close()`, which would permanently disable the manager - Handles both `update` and `embed` command failures - Falls back gracefully if the reset itself fails <h3>Confidence Score: 4/5</h3> - Safe to merge with low risk - implements a focused auto-repair mechanism for a known error scenario - The implementation follows the existing pattern for null-byte repair, correctly avoids calling `this.close()` during reset (which was the bug in the previous attempt), and includes proper once-per-lifetime guard against infinite loops. The dimension mismatch detection patterns are reasonable and the error handling is consistent with the codebase style. Minor confidence deduction for lack of test coverage for the new repair logic. - No files require special attention - the changes are well-contained and follow established patterns <sub>Last reviewed commit: ea26886</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs