Repository navigation
fix(forge): keep ArxivSearchTool results inside the requested category - #316
Merged
Merged
Conversation
The category was appended as '<query> AND cat:<category>'. arXiv binds all: to the first word only and gives AND precedence, so for a multi-word query the filter only applied to the last word and papers from other categories came back (9 of 50 results for 'diffusion model' in cs.CV). Group the query in parentheses before adding the category.
Eigenwise
approved these changes
Oct 19, 2026
Eigenwise
left a comment
Owner
There was a problem hiding this comment.
Grouping the full query before AND applies the category to both OR branches. Verified the regression failures on main and all 10 arXiv tool tests pass with this change. No live API request was needed. Thanks.
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.
The
categoryfilter of the ForgeArxivSearchToolleaks results from other categories whenever the query has more than one word.The tool builds
all:<query> AND cat:<category>. arXiv only applies theall:prefix to the first word, andANDbinds tighter than the implicit operator between words. Soall:diffusion model AND cat:cs.CVeffectively means "diffusion anywhere, or model in cs.CV". The same happens with prefixed queries liketi:RAG OR abs:agents.Searching
"diffusion model"withcategory="cs.CV"and 50 results:Over 100 results against the raw API, 26 fall outside cs.CV with the current query and none with the grouped one.
The fix wraps the query in parentheses before appending the category, producing
(all:diffusion model) AND cat:cs.CV. Queries without a category are unchanged. I updated the two existing expectations and added a test for multi-word and prefixed queries; both fail onmain. The tool's tests pass, andblack --checkandflake8are clean.