fix(dashboard): handle undefined vectors in cosineSimilarity #83
+3
−3
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 the Dashboard AI Chat crash caused by undefined vectors passed to
cosineSimilarity().Fixes #82
Changes
TextProcessor.cosineSimilarity()before accessing.lengthMemoryClusterer.cluster()before similarity calculationsRoot Cause
The
computeTfIdf()function stores vectors in a Map keyed by document content. When memory content is empty or duplicated, this can result in undefined entries when iterating vectors by index.Testing
Additional Observation
While testing the fix, we noticed that after the crash is resolved, the Chat with Memories feature generates responses that may not be semantically relevant to the user's query. For example, asking "What are the largest memories I have?" returned documentation about MCP usage rather than memory size information. This appears to be a separate issue with the retrieval/synthesis logic and is outside the scope of this fix, but we wanted to flag it for the maintainers' awareness.
🤖 Generated with Claude Code