Skip to content

Add ranking_instructions to Search Mode#96

Open
CShorten wants to merge 1 commit into
mainfrom
add-ranking-instructions
Open

Add ranking_instructions to Search Mode#96
CShorten wants to merge 1 commit into
mainfrom
add-ranking-instructions

Conversation

@CShorten

@CShorten CShorten commented Jul 8, 2026

Copy link
Copy Markdown
Member

Add ranking_instructions argument to Search Mode

What's changed

Adds a new optional ranking_instructions argument to the Query Agent's search-only mode, on both QueryAgent.search() and AsyncQueryAgent.search().

response = agent.search(
    "Find NDAs signed in 2024",
    collections=["FinancialContracts"],
    ranking_instructions="Prioritize recently signed documents over older ones.",
)

How it works

  • The instructions are passed to the instruction-following reranker to guide relevance prioritization. They only affect the ordering of results, not which results are retrieved.
  • The field is added to SearchModeRequestBase, so it applies to both the initial request (server-side query generation) and paginated requests via response.next(...) (direct search execution), and persists across pages — consistent with filtering and diversity_weight.
  • Defaults to None and serializes as JSON null when not provided.

Tests

  • Sync + async tests asserting that omitting the argument sends null in the request payload.
  • Sync + async tests asserting that a provided string is sent verbatim and persists across pagination.

@orca-security-eu orca-security-eu Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Infrastructure as Code high 0   medium 0   low 0   info 0 View in Orca
Passed Passed SAST high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Vulnerabilities high 0   medium 0   low 0   info 0 View in Orca

@CShorten CShorten self-assigned this Jul 9, 2026
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.

1 participant