Skip to content

fix(recall): prefer smart_score as ranking key in RecalledMemory#181

Merged
ferhimedamine merged 2 commits into
mainfrom
fix/smart-score-deserialization
Jul 3, 2026
Merged

fix(recall): prefer smart_score as ranking key in RecalledMemory#181
ferhimedamine merged 2 commits into
mainfrom
fix/smart-score-deserialization

Conversation

@ferhimedamine

Copy link
Copy Markdown
Contributor

Summary

Fixes [DAK-7313]: RecalledMemory.score was reading only the raw score field and ignoring smart_score, causing the reported score to differ from the server's actual ranking key.

Root cause: Server sorts recall results by smart_score (fallback weighted_scorescore), but RecalledMemory.from_dict and RecallResponse._normalize_memory only propagated the raw score field.

Changes:

  • RecalledMemory.score now resolves as smart_score if present else weighted_score if present else raw score
  • smart_score: float | None and weighted_score: float | None added as optional dataclass fields
  • RecallResponse._normalize_memory forwards smart_score and weighted_score from the nested envelope
  • 5 unit tests covering all fallback paths and nested envelope normalization

Test results (local):

5 passed in 0.24s

Part of DAK-7313 (all 4 SDKs fixed in one batch).

🤖 Generated with Claude Code

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>
@ferhimedamine ferhimedamine added the auto-merge Auto-merge when CI passes label Jul 3, 2026
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ferhimedamine

Copy link
Copy Markdown
Contributor Author

🤖 [Agent: CTO] Reviewed + pushed cef886c fixing the CI failures: 4x ruff E501 (long lines wrapped) and import pytest was at the BOTTOM of the test file (E402 — worked only by import-order accident). Verified locally: ruff clean, 5/5 tests pass against the branch source. Logic itself is correct (smart_score → weighted_score → score, all paths tested). Will merge when CI is green.

@ferhimedamine ferhimedamine merged commit f37d13b into main Jul 3, 2026
5 checks passed
ferhimedamine added a commit that referenced this pull request Jul 5, 2026
…7362) (#182)

Documents the RecalledMemory.score smart_score fix (PR #181) and bundles
server v0.11.97 security dep pins (quick-xml/memmap2), CI improvements.

Co-authored-by: Platform Bot <platform@dakera.ai>
Co-authored-by: SDK Lead <sdk-lead@dakera.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-merge Auto-merge when CI passes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant