{{ message }}
fix(mcp): expose unknown search totals - #1069
Merged
Merged
Conversation
Signed-off-by: phernandez <paul@basicmachines.co>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1a89dfb437
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Signed-off-by: phernandez <paul@basicmachines.co>
14 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Why
Semantic and hybrid search intentionally use a probe row instead of a second vector retrieval, so
total: 0means unknown rather than no matches. Structured clients could not distinguish that sentinel from an exact zero, which made working pagination look broken.Closes #1068.
What Changed
total_is_exactmetadata to structured search responses.total: 0compatibility value for semantic modes.Implementation Details
SearchResponsedefaultstotal_is_exactto true for compatibility with existing exact-count constructors. The HTTP router sets it from the retrieval mode. Multi-project MCP search only claims an exact aggregate when every project supplied an exact total; otherwise its aggregate is explicitly unknown. When an older API omits the new field, the typed client infers exactness from the outbound retrieval mode so legacy semantic responses remain unknown. No additional vector or hybrid retrieval is performed.Testing
uv run pytest tests/mcp/clients/test_clients.py tests/schemas/test_search.py tests/api/v2/test_search_router.py tests/mcp/test_search_total_exactness.py tests/mcp/tools/test_search_notes_multi_project.py tests/cli/test_cli_tool_rich_output.py -q— 109 passed.just fast-check— passed; type checking reported only the existing Python 3.14 asyncio deprecation warnings.just doctor— passed.just test-smoke— passed.just fast-test— 4,278 passed and 41 skipped; one unrelated live OpenAI semantic-quality case failed because the configured provider returned HTTP 429insufficient_quota.Risks / Follow-ups
The response change is additive, existing clients can ignore the new field, and semantic retrieval cost and pagination behavior are unchanged. No follow-up is required.