Skip to content

fix: propagate Xinference rerank failures instead of returning empty results - #10051

Open
he-yufeng wants to merge 1 commit into
AstrBotDevs:masterfrom
he-yufeng:fix/xinference-rerank-raise
Open

fix: propagate Xinference rerank failures instead of returning empty results#10051
he-yufeng wants to merge 1 commit into
AstrBotDevs:masterfrom
he-yufeng:fix/xinference-rerank-raise

Conversation

@he-yufeng

@he-yufeng he-yufeng commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

What this PR does

The Xinference rerank provider no longer swallows failures as an empty list. An upstream rerank error or an uninitialized model now raises, matching the contract the other rerank providers already follow (TEI raises on network and HTTP errors) and the behavior the retrieval manager is built around.

Why

Fixes #10000. The retrieval manager preserves the fused candidates only when reranking raises (except around _rerank keeps the unreranked results with a warning). Because the Xinference provider returned [] on failure instead, the manager treated the outage as a legitimate empty rerank and overwrote the fused candidates with nothing, so a transient upstream failure silently turned every knowledge-base query into zero matches until it recovered.

How it's tested

New regression file tests/test_xinference_rerank_source.py pins both failure paths: an exception from the upstream model call propagates instead of returning [], and an uninitialized model raises instead of returning []. Verified red-first (both fail against current master), then green with the change. Full rerank source suite (test_bailian + test_vllm + test_xinference) passes 23/23, and the knowledge-base/retrieval tests pass 15/15. ruff format and ruff check are clean.

Summary by Sourcery

Preserve retrieval results when Xinference reranking fails by allowing errors to reach the retrieval fallback path.

Bug Fixes:

  • Propagate Xinference rerank failures and uninitialized-model errors so retrieval can preserve unreranked candidates instead of treating failures as empty results.

Tests:

  • Add regression coverage for upstream rerank failures and uninitialized Xinference models.

…results

The Xinference rerank provider swallowed upstream failures and an
uninitialized model by returning an empty list, which the retrieval
manager read as a legitimate empty rerank and used to overwrite the
fused candidates with nothing. Other providers (e.g. TEI) raise, and
the manager only preserves the fused results on that path, so a
transient Xinference outage silently degraded every knowledge-base
query to zero hits. Raise instead, matching the provider contract and
letting the manager's degradation keep the unreranked results.

Fixes AstrBotDevs#10000

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Xinference rerank 吞掉上游异常并返回空列表,导致知识库丢失已融合的检索结果

1 participant