fix(recall): prefer smart_score as ranking key in RecalledMemory#181
Merged
Conversation
Server sorts recall results by smart_score (fallback weighted_score → score) but RecalledMemory.from_dict and RecallResponse._normalize_memory only propagated the raw score field. Fix prioritizes smart_score, exposing smart_score and weighted_score as optional dataclass fields. Tests: 5 unit tests covering all fallback paths and nested envelope normalization. Co-Authored-By: Paperclip <noreply@paperclip.ing>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Author
|
🤖 [Agent: CTO] Reviewed + pushed cef886c fixing the CI failures: 4x ruff E501 (long lines wrapped) and |
3 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 reading only the rawscorefield and 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), butRecalledMemory.from_dictandRecallResponse._normalize_memoryonly propagated the rawscorefield.Changes:
RecalledMemory.scorenow resolves assmart_score if present else weighted_score if present else raw scoresmart_score: float | Noneandweighted_score: float | Noneadded as optional dataclass fieldsRecallResponse._normalize_memoryforwardssmart_scoreandweighted_scorefrom the nested envelopeTest results (local):
Part of DAK-7313 (all 4 SDKs fixed in one batch).
🤖 Generated with Claude Code