Skip to content

Conversation

@aayush598
Copy link
Contributor

Summary

This PR updates the Milvus.search method to apply a reranker to the search results, ensuring that results are reordered based on relevance after initial vector search.

Key changes:

  • Added a check for self.reranker and non-empty search results.
  • Applied self.reranker.rerank(query=query, documents=search_results) to reorder results.
  • Enforced limit on the final results after reranking.
  • Updated libs/agno/tests/unit/vectordb/test_milvusdb.py with a unit test validating the reranker integration.

This resolves the reported issue: [#5190]

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Improvement
  • Model update
  • Other:

Checklist

  • Code complies with style guidelines
  • Ran format/validation scripts (./scripts/format.sh and ./scripts/validate.sh)
  • Self-review completed
  • Documentation updated (comments, docstrings)
  • Examples and guides: Relevant cookbook examples have been included or updated (if applicable)
  • Tested in clean environment
  • Tests added/updated (if applicable)

Additional Notes

  • The reranker is optional; if self.reranker is not defined, the search behaves as before.
  • The search limit is enforced after reranking to ensure returned results respect the limit parameter.
  • Unit test uses a mocked reranker that reverses results to simulate reranking behavior.

@aayush598 aayush598 requested a review from a team as a code owner October 26, 2025 22:36
@willemcdejongh willemcdejongh merged commit 13084fd into agno-agi:main Oct 31, 2025
@manuhortet
Copy link
Contributor

Thanks for the contribution @aayush598, we really appreciate it! 💪

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.

3 participants