Reranker errors
Common error signatures
Errors in LLMReranker fall into two categories: failures calling the Claude Haiku API, and failures parsing its response. When an API call fails, LLMReranker.rerank() falls back to the original keyword-retrieval order rather than raising — so if you're seeing no re-ranking effect, the root cause is often a silent API error rather than an exception. Errors that do propagate typically look like:
anthropic.APIConnectionErrororanthropic.APITimeoutError— the Claude API did not respond within the configuredtimeout(default60.0seconds).anthropic.AuthenticationError— theapi_keypassed toLLMReranker.__init__()is missing or invalid.json.JSONDecodeError— Claude returned a response that could not be parsed as a JSON array of indices. This can happen if the model ignored theReturn ONLY the JSON arrayinstruction in the system prompt.IndexErrororValueError— the parsed JSON array contained indices outside the range of the candidate list, or did not include every index exactly once.
Where errors originate
All re-ranking logic runs through a single method:
LLMReranker.rerank(query, hits)insrc/attune_rag/reranker.py— sends the query and the top-K candidate documents (path + summary) to Claude Haiku, receives a ranked JSON array of 0-based indices, and returns the re-orderedhits. This is the only method that calls the Claude API, so every API-related error originates here.
How to diagnose
-
Confirm whether re-ranking is actually running. If
rerank()silently fell back to keyword order, the return value will match the originalhitslist. Add a log statement or assertion after callingrerank()to check whether the returned order differs from the input order. -
Check your API key and model name.
LLMRerankerdefaults tomodel='claude-haiku-4-5-20251001'. AnAuthenticationErrormeans the key passed viaapi_key(or inferred from the environment) is wrong or absent. ANotFoundErrorfrom the Anthropic SDK means the model string does not match a deployed model name. -
Reproduce with a minimal candidate list. Call
rerank()directly with a singleRetrievalHitand a short query. If the error reproduces, capture the raw response text from the SDK before JSON parsing to see exactly what Claude returned. A response containing explanation text alongside the array means the system prompt'sReturn ONLY the JSON arrayconstraint was not followed. -
Check the timeout. If you're hitting
APITimeoutErrorunder normal load, constructLLMRerankerwith a largertimeoutvalue. If the timeout fires consistently, check whethercandidate_multiplier(default3) is producing a candidate list that's too large for Claude to rank within the budget. -
Validate the returned index array. If you see
IndexErroror an unexpected re-ordering, log the raw JSON array returned by Claude and compare it againstlen(hits). Every index from0tolen(hits) - 1must appear exactly once; anything else indicates a malformed response.
Source files
src/attune_rag/reranker.py
Tags: reranker, hybrid-retrieval, precision, claude, haiku