fix: handle missing highlightScores from Exa API#253
Open
TejNadkarni wants to merge 2 commits intoMetaculus:mainfrom
Open
fix: handle missing highlightScores from Exa API#253TejNadkarni wants to merge 2 commits intoMetaculus:mainfrom
TejNadkarni wants to merge 2 commits intoMetaculus:mainfrom
Conversation
The Exa API has stopped returning highlightScores in some responses, causing zip(highlights, highlight_scores) to silently yield nothing and all highlights to be dropped (0 quotes found despite 10+ sources). Default to a score of 1.0 per highlight when the scores array is empty.
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes an Exa API response-shape regression where highlightScores may be missing/empty even when highlights is present, which previously caused all highlights to be dropped due to zip() truncation.
Changes:
- Default
highlight_scoresto1.0per highlight when the scores list is empty. - Preserve highlight extraction and relevance-order sorting even when Exa returns
highlightScores: [].
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+147
to
+148
| scores = source.highlight_scores or [1.0] * len(source.highlights) | ||
| for highlight, score in zip(source.highlights, scores): |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
The Exa API has stopped returning
highlightScoresalongsidehighlightsin some responses. The current code iterates usingzip(source.highlights, source.highlight_scores), which silently yields nothing whenhighlight_scoresis an empty list — causing all highlights to be dropped even when the API returns valid content.Observed behavior: 10 sources returned, 0 quotes collected, final output:
"No search results found for the query using the search filter chosen".Fix: Default missing scores to
1.0per highlight when the scores array is empty.I verified the fix by inspecting raw Exa API responses and confirming
highlightScoresis returned as[]whilehighlightscontains valid content. A test case covering the emptyhighlightScoresfallback has been added totest_exa_model.py.