Tencent/WeKnora · error
rerank call failed: %w
Error message
rerank call failed: %w
What it means
rerankScores calls the configured rerank model to rescore retrieved passages; any error returned by rerankModel.Rerank is wrapped as 'rerank call failed: %w'. This is a downstream-model invocation failure, not a validation error — the search results exist but the reranking step could not complete.
Source
Thrown at internal/agent/tools/knowledge_search.go:695
return meta, nil
}
// rerankScores scores the candidates with the configured rerank model and
// returns the raw relevance scores, leaving threshold filtering and composite
// scoring to the caller.
func (t *KnowledgeSearchTool) rerankScores(
ctx context.Context,
query string,
results []*searchResultWithMeta,
) ([]rerank.RankResult, error) {
passages := make([]string, len(results))
for i, result := range results {
passages[i] = t.getEnrichedPassage(ctx, result.SearchResult)
}
rerankResp, err := t.rerankModel.Rerank(ctx, query, passages)
if err != nil {
return nil, fmt.Errorf("rerank call failed: %w", err)
}
return rerankResp, nil
}
func (t *KnowledgeSearchTool) rerankThreshold() float64 {
if t.config != nil && t.config.Conversation != nil && t.config.Conversation.RerankThreshold > 0 {
return t.config.Conversation.RerankThreshold
}
return 0.3
}
const agentRerankFallbackMinScore = 0.15
func filterRerankRankResults(
rankResults []rerank.RankResult,
threshold float64,
preserveTop bool,
) []rerank.RankResult {View on GitHub (pinned to 988cbb0330)
Solutions
- Inspect the wrapped cause (%w) via errors.Unwrap or %v of the returned error for the provider-level reason
- Verify rerank provider credentials and endpoint configuration
- Check provider status/rate limits; retry with backoff on transient failures
- Shrink the number/size of passages sent to the reranker
- Disable rerank or add a fallback path that returns un-reranked results when reranking fails
Example fix
// before
rerankResp, err := t.rerankModel.Rerank(ctx, query, passages)
if err != nil { return nil, fmt.Errorf("rerank call failed: %w", err) }
// after
rerankResp, err := t.rerankModel.Rerank(ctx, query, passages)
if err != nil {
logger.Warnf(ctx, "rerank failed, falling back to unranked results: %v", err)
return results, nil // graceful degradation
} Defensive patterns
Strategy: fallback
Validate before calling
if rerankEnabled && (rerankEndpoint == "" || rerankAPIKey == "") {
return errors.New("rerank configured but endpoint/key missing")
} Try / catch
res, err := tool.Execute(ctx, input)
if err != nil && strings.Contains(err.Error(), "rerank call failed") {
log.Printf("rerank unavailable: %v", err) // error wraps provider cause
return executeWithoutRerank(ctx, input) // graceful degradation
} Prevention
- Verify rerank credentials and endpoint at startup
- Set rerank call timeouts and retry transient failures with backoff
- Cap passage count/size sent to the reranker
- Implement a code path that returns un-reranked results on rerank failure
- Monitor provider status/rate limits
When it happens
Trigger: t.rerankModel.Rerank returns an error: rerank provider HTTP failure, auth rejection, timeout, oversized payload (too many/long passages), or rerank model misconfigured while rerank is enabled.
Common situations: Rerank API key expired or missing; provider outage or rate limiting; passage list exceeds provider limits; network egress blocked in the deployment environment.
Related errors
- rerank model is not configured: please set rerank_model_id o
- no search targets available
- no queries provided
- failed to do bulk: %w
- failed to delete by query: %w
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/0835918a5aee3259.
Report an issue: GitHub.