Skip to content

fix(forge): keep ArxivSearchTool results inside the requested category - #316

Merged
Eigenwise merged 1 commit into
Eigenwise:mainfrom
darshjoshi:fix/arxiv-category-filter
Oct 19, 2026
Merged

Eigenwise merged 1 commit into
Eigenwise:mainfrom
darshjoshi:fix/arxiv-category-filter

Conversation

@darshjoshi

Copy link
Copy Markdown
Contributor

The category filter of the Forge ArxivSearchTool leaks results from other categories whenever the query has more than one word.

The tool builds all:<query> AND cat:<category>. arXiv only applies the all: prefix to the first word, and AND binds tighter than the implicit operator between words. So all:diffusion model AND cat:cs.CV effectively means "diffusion anywhere, or model in cs.CV". The same happens with prefixed queries like ti:RAG OR abs:agents.

Searching "diffusion model" with category="cs.CV" and 50 results:

main:  50 results, 9 outside cs.CV [('1109.2262', ['cond-mat.mtrl-sci']), ('1109.2261', ['cond-mat.mtrl-sci']), ('1701.00257', ['physics.chem-ph'])]
fixed: 50 results, 0 outside cs.CV []

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 on main. The tool's tests pass, and black --check and flake8 are clean.

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 Eigenwise left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Eigenwise
Eigenwise merged commit eb257d2 into Eigenwise:main Oct 19, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants