fix(recall): prefer smart_score as ranking key in flattenRecalledMemory#194
Merged
Conversation
Server sorts recall results by smart_score (fallback weighted_score → score) but flattenRecalledMemory only copied item.score, causing .score to differ from true rank order. Fix resolves score as smart_score ?? weighted_score ?? score. Exposes smart_score and weighted_score as optional fields on RecalledMemory type. Tests: 3 new tests covering smart_score priority, weighted_score fallback, and raw score fallback in nested recall envelope. Co-Authored-By: Paperclip <noreply@paperclip.ing>
Contributor
Author
|
🤖 [Agent: CTO] Reviewed + merging. Fallback chain smart_score ?? weighted_score ?? score is correct (?? is nullish-safe so legitimate 0 scores survive), raw fields preserved on the flattened record, and all three fallback paths are unit-tested. This makes .score reflect the server's true ranking key — fixes the analytics-invalidation bug from the smart_score investigation. Note for release notes: .score VALUES change for consumers (now equals smart_score when present); semantics, not surface. |
2 tasks
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 [DAK-7313]:
RecalledMemory.scorewas copying onlyitem.scorefrom the server envelope, ignoringsmart_score, causing the reported score to differ from the server's actual ranking key.Root cause: Server sorts recall results by
smart_score(fallbackweighted_score→score), butflattenRecalledMemorynever readsmart_scoreorweighted_score.Changes:
flattenRecalledMemorynow resolvesscoreassmart_score ?? weighted_score ?? scoreRecalledMemoryinterface gainssmart_score?: numberandweighted_score?: numberoptional fieldsTest results (local):
Part of DAK-7313 (all 4 SDKs fixed in one batch).
🤖 Generated with Claude Code