Fix vector index Buffer serialization#653
Conversation
|
Someone is attempting to deploy a commit to the rohitg00's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
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 (2)
📝 WalkthroughWalkthroughThe PR fixes ChangesFloat32Array Serialization Codec
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add 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 |
Summary
Fix vector index serialization/deserialization so persisted
Float32Arrayembeddings preserve their intended byte range instead of using the entire backingArrayBuffer.Why
Buffer.from(arr.buffer)serializes the entire backing buffer, ignoringFloat32Array.byteOffsetandbyteLength. Similarly,new Float32Array(Buffer.from(b64, "base64").buffer)can read the entire pooled Buffer backing store instead of just the decoded bytes.In a live AgentMemory instance this caused a rebuilt 384-dimension local embedding index to be persisted, then rejected on restart as 2048-dimensional vectors:
The service then refused to start until the installed package was patched locally or the vector index was discarded.
Changes
Float32Arraybyte range.byteOffsetandbyteLength.Verification
Summary by CodeRabbit
Bug Fixes
Tests