gather_evidence tool response filtering irrelevant Context, with updated threshold of 0#1106
Merged
jamesbraza merged 4 commits intomainfrom Sep 26, 2025
Merged
gather_evidence tool response filtering irrelevant Context, with updated threshold of 0#1106jamesbraza merged 4 commits intomainfrom
gather_evidence tool response filtering irrelevant Context, with updated threshold of 0#1106jamesbraza merged 4 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR improves the gather_evidence tool by filtering out irrelevant context entries and updating the relevance threshold from 5 to 0. The changes address issues where the tool was reporting evidence that wasn't actually useful.
- Updated relevance scoring threshold from 5 to 0 to better identify useful evidence
- Enhanced context filtering to exclude zero-scored (irrelevant) contexts from tool responses
- Added documentation and validation for empty context strings
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/paperqa/agents/tools.py | Updated evidence gathering logic to filter contexts with score > 0 and removed relevance counting |
| src/paperqa/types.py | Added string constraints and documentation for empty context handling |
| src/paperqa/core.py | Fixed conditional logic for parser usage |
| tests/test_paperqa.py | Added type annotation and updated assertion to handle whitespace |
| tests/test_agents.py | Adjusted test assertion to allow tolerance for whitespace in chunks |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
jamesbraza
commented
Sep 25, 2025
Comment on lines
-279
to
-280
| try: | ||
| result_data = parser(context) if parser else {} |
Collaborator
Author
There was a problem hiding this comment.
This little refactor removes the extra if parser else {}, making the code slightly less stateful
…from gather_evidence tool response
2ea6835 to
e9517b2
Compare
whitead
approved these changes
Sep 26, 2025
Collaborator
whitead
left a comment
There was a problem hiding this comment.
Nice work getting all these cleaned-up
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.
We were seeing
gather_evidenceresponses like this:There's more to the story here, but this PR at least:
Context.context5to0gather_evidencetool response for zero-scoredContext