You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(reranker): preserve memory text when sources are missing - #2634
With rerank_source="sources", an HTTP BGE candidate with valid memory text but missing or None sources was sent as an empty document. The concatenator now falls back to the cleaned primary memory text when none of the selected source fields exists.
Each candidate retains its document position, so returned scores map back to the correct original items. Tests cover normal source enrichment, empty source lists, missing metadata, custom selected fields, prefix stripping, both factory aliases and both supported HTTP response formats.
Target: PR #2634 Task:b442dc8f47e02e26 Base:dev-v2.0.37 Head:fix/bge-source-memory-fallback Head SHA:feaee5e91517965069eb0ab6196a589f00a1d858
🔍 OpenCodeReview found 1 issue(s) in this PR.
1. src/memos/reranker/concat.py (L102)
memory is not guaranteed to be a str here: line 88 deliberately keeps the raw value (_TAG1.sub(...) if isinstance(m, str) else m), so a non-string m (e.g. None or a dict/list) flows through unchanged. When there are no sources, memory or "" therefore returns that non-string value, and it is appended to a list[str] that is later serialized as the JSON documents payload sent to the reranker (http_bge.rerank, where non-string memories are otherwise filtered out). Use the empty-string fallback for non-string values to keep the return type and payload well-formed.
💡 Suggested Change
Before:
concat_string = process_source(sources) if sources else (memory or "")
After:
if sources:
concat_string = process_source(sources)
else:
concat_string = memory if isinstance(memory, str) else ""
Generated by cloud-assistant via Open Code Review.
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
area:coreMOS 编排层 / 框架底座 / 跨模块问题status:readyReady for implementation; waiting for assignee or AI dispatch | 可进入实现,等待认领或派发
3 participants
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.
Description
With rerank_source="sources", an HTTP BGE candidate with valid memory text but missing or None sources was sent as an empty document. The concatenator now falls back to the cleaned primary memory text when none of the selected source fields exists.
Each candidate retains its document position, so returned scores map back to the correct original items. Tests cover normal source enrichment, empty source lists, missing metadata, custom selected fields, prefix stripping, both factory aliases and both supported HTTP response formats.
Fixes #2559.
Type of change
How Has This Been Tested?
Actual verification output
The commit passed all applicable repository pre-commit hooks.
Checklist
Reviewer Checklist