Skip to content

feat: add --no-rerank flag to serve and search commands#93

Open
Aetherall wants to merge 1 commit intoRyandonofrio3:mainfrom
Aetherall:feat/no-rerank-flag
Open

feat: add --no-rerank flag to serve and search commands#93
Aetherall wants to merge 1 commit intoRyandonofrio3:mainfrom
Aetherall:feat/no-rerank-flag

Conversation

@Aetherall
Copy link
Copy Markdown

@Aetherall Aetherall commented Mar 28, 2026

Summary

  • Add --no-rerank flag to osgrep serve and osgrep search
  • The serve /search endpoint now respects a rerank field in the request body, with the CLI flag as the default

Problem

The serve command hardcodes { rerank: true } when calling searcher.search(). On the first search query, this triggers loading of the ~2GB ColBERT neural reranking ONNX model, which takes >2 minutes before the first response is returned. This makes osgrep serve impractical for interactive use cases (e.g., Neovim pickers, editor integrations) where sub-second latency is expected.

Solution

Both serve and search commands now accept --no-rerank which passes { rerank: false } to searcher.search(). The searcher already handles this case gracefully (line 258 of searcher.ts: const doRerank = _search_options?.rerank ?? true) by falling back to fusion scoring.

For serve, the /search endpoint also reads rerank from the JSON request body, allowing per-request control. The CLI flag sets the server-wide default.

Performance

Benchmarked on a small project (~35 files):

Mode First query Warm queries
serve (default, rerank=true) >120s ~60ms
serve --no-rerank 321ms 66ms
search --no-rerank (CLI) ~1.0s ~1.0s

The quality difference is minimal — fusion scoring (BM25 + vector similarity) produces good results; neural reranking adds marginal improvement primarily for ambiguous queries.

Usage

osgrep serve --no-rerank          # fast server startup, no reranking model loaded
osgrep search "auth" --no-rerank  # fast CLI search without reranking

# Per-request control via the HTTP API:
curl -X POST http://localhost:4444/search \
  -H 'Content-Type: application/json' \
  -d '{"query": "authentication", "limit": 10, "rerank": false}'

Changes

  • src/commands/serve.ts: Add --no-rerank option, read rerank from request body with CLI default fallback
  • src/commands/search.ts: Add --no-rerank option, pass to searcher.search(), forward to server when using HTTP client path

Summary by CodeRabbit

  • New Features
    • Added --no-rerank CLI option to disable neural reranking
    • Reranking behavior is now configurable for both search and serve commands
    • HTTP server endpoints support per-request reranking overrides

Add --no-rerank option to both 'osgrep serve' and 'osgrep search' to
disable the neural reranking stage. This uses the existing fusion
scoring (BM25 + vector similarity) instead of loading the ~2GB
ColBERT reranking model.

The serve command's /search endpoint now also respects a 'rerank'
field in the request body, allowing per-request control. The CLI
flag sets the default, and the request body can override it.

Performance impact on 'osgrep serve':
  First query with rerank:    >120s (loads reranking ONNX model)
  First query --no-rerank:    321ms
  Warm queries --no-rerank:   66ms

The quality tradeoff is minimal — fusion scoring already produces
good results; neural reranking only adds marginal improvement for
ambiguous queries.

Usage:
  osgrep serve --no-rerank     # fast server, no reranking
  osgrep search 'auth' --no-rerank  # fast CLI search
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: daec859d-e583-4b5a-9ced-cf193ca0a2ec

📥 Commits

Reviewing files that changed from the base of the PR and between 9f2faf7 and ed816aa.

📒 Files selected for processing (2)
  • src/commands/search.ts
  • src/commands/serve.ts

Walkthrough

Added --no-rerank CLI option to both search and serve commands, enabling neural reranking behavior control. The flag is threaded through request payloads and command execution paths, replacing previously hardcoded reranking defaults with configurable values.

Changes

Cohort / File(s) Summary
Reranking Option Control
src/commands/search.ts, src/commands/serve.ts
Introduces --no-rerank CLI option to both commands. Adds rerank boolean to parsed options and threads it through server requests and local search execution. Serve command implements per-request override logic where body.rerank takes precedence over CLI-derived defaults.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A rerank toggle hops into view,
Per request or command, we choose what's true,
No more hardcoded ways—now flexible and bright,
The neural engine dances left and right! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add --no-rerank flag to serve and search commands' directly and clearly summarizes the main change—adding a CLI flag to two commands to control neural reranking behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Aetherall
Copy link
Copy Markdown
Author

This PR was made with opencode, im using this patch in my shell quick navigation tool. in this scenario, i value the tradeoff of lesser quality result for startup speed. might be out of scope for the mcp usage, but its quite handy in the shell too !
If you want to i can redo this PR using my unassisted raw biological neurons ;)

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