Skip to content

fix: validate SearchableToolset result limits#11822

Draft
onyx679 wants to merge 1 commit into
deepset-ai:mainfrom
onyx679:codex/validate-searchable-toolset-top-k
Draft

fix: validate SearchableToolset result limits#11822
onyx679 wants to merge 1 commit into
deepset-ai:mainfrom
onyx679:codex/validate-searchable-toolset-top-k

Conversation

@onyx679

@onyx679 onyx679 commented Jun 29, 2026

Copy link
Copy Markdown

Summary

  • Validate SearchableToolset(top_k=...) so non-positive default result limits fail early.
  • Guard the runtime search_tools(..., k=...) override against non-positive values.
  • Add regression coverage for both constructor and runtime result-limit handling.

Why

SearchableToolset passes the result limit through to BM25 retrieval. With non-positive limits, Python slicing can produce surprising behavior: top_k=0 loads no tools, while negative values can load all but the last matching tool. Since this controls which tools become visible to an agent, the limit should be explicit and positive.

Tests

  • .\.venv\Scripts\python.exe -m pytest test\tools\test_searchable_toolset.py -q
  • .\.venv\Scripts\python.exe -m ruff check haystack\tools\searchable_toolset.py test\tools\test_searchable_toolset.py
  • git diff --check HEAD~1 HEAD

@vercel

vercel Bot commented Jun 29, 2026

Copy link
Copy Markdown

@onyx679 is attempting to deploy a commit to the deepset Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants