fix(memory): prevent stuck typing on embedding model switch#27175
Open
dakshaymehta wants to merge 2 commits intoopenclaw:mainfrom
Open
fix(memory): prevent stuck typing on embedding model switch#27175dakshaymehta wants to merge 2 commits intoopenclaw:mainfrom
dakshaymehta wants to merge 2 commits intoopenclaw:mainfrom
Conversation
Contributor
Greptile SummaryFixes a race condition that caused Telegram to show infinite "typing..." and become unresponsive after changing embedding models. The core issue was concurrent async operations accessing shared Key changes:
The implementation correctly sets/resets the Confidence Score: 5/5
Last reviewed commit: 66bd50b |
|
This pull request has been automatically marked as stale due to inactivity. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #27143 — changing the embedding model (e.g.
text-embedding-3-small→text-embedding-3-large) causes the gateway to get stuck with an infinite "typing..." indicator on Telegram after replying, becoming unresponsive to new messages.Root cause: A race condition in
MemoryIndexManagerduring safe reindex triggered by the model change. The reindex mutates shared state (this.db,this.vector.*) on the singleton manager instance while concurrent async operations (agent memory search, session warm) use the same instance. Additionally, a falsy dimension check inensureVectorTablefailed to drop stale vec0 tables when dimensions were reset toundefinedduring the reindex, and an unguarded vec0 INSERT could throw unhandled errors that corrupt the indexing pipeline.Changes
Fix falsy dimension check in
ensureVectorTable(manager-sync-ops.ts:223)this.vector.dims && this.vector.dims !== dimensionstothis.vector.dims !== undefined && this.vector.dims !== dimensionsdropVectorTable()when dims was reset toundefinedduring safe reindex, leaving a stale vec0 table with wrong dimensionsAdd
reindexingguard flag (manager-sync-ops.ts)protected reindexing = falseflag set duringrunSafeReindexensureVectorReadyreturnsfalsewhen reindexing, causing search to gracefully fall back to the non-vec0 cosine similarity path instead of operating on a temp database that may be closed mid-queryWrap vec0 INSERT in try-catch (
manager-embedding-ops.ts:771-783)Improve
dropVectorTableerror logging (manager-sync-ops.ts:244)log.debugtolog.warn— a failed table drop is a significant issue that was invisible at debug levelTest plan
pnpm test src/memory/)pnpm test src/channels/typing.test.ts src/auto-reply/reply/reply-flow.test.ts src/auto-reply/reply/followup-runner.test.ts)pnpm check)🤖 Generated with Claude Code