Skip to content

improvement(search): multiple native queries per account with rank fusion and per-provider query guides - #8278

Merged
waleedlatif1 merged 3 commits into
stagingfrom
improvement/live-search-multi-query
Sep 24, 2026
Merged

waleedlatif1 merged 3 commits into
stagingfrom
improvement/live-search-multi-query

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Let one search_workspace call send up to 4 native queries per provider account. Before, a second query for the same account was rejected, which was the most common failed search call. It also pushed the model into sequential single searches for providers that can't join alternatives (e.g. Slack keyword search, Calendar, GitHub code).
    • Each query runs as its own provider search through the account's one session, with one request budget per query. Its status and cursor carry its queryIndex.
    • Results from every query and account merge by reciprocal rank fusion. Each result already scored 1/(RRF_K + rank); a document returned by several queries now sums those scores, following LangChain's MultiQueryRetriever and RRF as used by Elasticsearch, OpenSearch and Weaviate.
    • When a fused result is cut below topK, every query that returned it drops its cursor, so paging can't skip it.
    • GitHub and GitLab keep one query per kind: their languages join alternatives with OR, and each extra query fans out into repository requests against strict search limits.
    • Duplicate searches are rejected (ignoring account and any kind the provider doesn't use).
  • Replace the single static guidance string with a per-provider query card { syntax, scope, example, avoid } on the provider registry. The registry's satisfies Record<LiveSearchProviderId, …> makes every provider define one.
    • liveSearchGuidance renders the shared rules plus cards for the providers in play. Connected accounts get them in the per-turn account inventory, so the model sees them before its first search; each search response carries the cards for the accounts it searched. This follows the precedent of per-tool query descriptions (github-mcp-server) and per-connection descriptions (Microsoft 365 Copilot connectors).
    • Each card was checked against the provider's docs and against the live APIs. The live checks corrected several documented claims:
      • Slack keyword retrieval returns nothing for a OR b.
      • GitHub REST code search has no OR (a OR b → 0 while each term matches).
      • GitHub code search works with only a repo: qualifier.
      • GitLab code and wiki scopes work on project search without advanced search.
  • A GitHub search without a kind now skips code when the query uses AND/OR/NOT, and says why. The existing date-filter exclusion works the same way.
  • The tool description keeps only the structural rules (limit, one query per GitHub/GitLab kind, queryIndex) and points to the live guidance for syntax.

Type of Change

  • Improvement

Testing

  • Contract: the per-account cap, one query per GitHub/GitLab kind, and duplicate detection (with and without accountId, and a kind on a provider that ignores it)
  • Application:
    • one session per account with a status per query
    • fused ranking, where a document several queries return ranks first
    • cursors dropped for every query behind a cut fused result; this test fails on the previous code
    • reconnect statuses carry queryIndex and get no cards
  • Providers: every provider has a complete card, rendering order and filtering, and GitHub skipping code for boolean queries
  • Checked each card's claims live against Drive, Gmail, Calendar, Slack, Jira and Confluence (through Search) and GitHub (REST), and by per-provider doc review
  • Lint, all audits, block registry, docs manifest, tool catalog check, type-check, and the search/contracts/mothership/MCP/home suites pass
  • The paired worker contract sync is in simstudioai/mothership#522

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Sep 24, 2026 11:43pm UTC

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 11 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread apps/sim/lib/sim-search/live/providers.ts Outdated
Comment thread apps/sim/lib/sim-search/live/github.ts Outdated
Comment thread apps/sim/lib/api/contracts/mothership-assistant-tools.ts Outdated
@greptile-apps

greptile-apps Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge; no new actionable issue or outstanding previous finding remains.

Summary

The PR allows multiple native searches per account, fuses their rankings, identifies cursors by query index, and supplies provider-specific query guidance. The latest change prevents a result repeated within one query from receiving multiple rank contributions.

Reviews (3) · Last reviewed commit: "fix(search): score each fused item once ..."

Comment thread apps/sim/lib/api/contracts/mothership-assistant-tools.ts Outdated
Comment thread apps/sim/lib/sim-search/live/github.ts Outdated
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 11 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread apps/sim/lib/sim-search/live/application.ts
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 11 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit 6da76e4 into staging Sep 24, 2026
34 checks passed
@waleedlatif1
waleedlatif1 deleted the improvement/live-search-multi-query branch September 24, 2026 23:55

This branch was previously deployed

1 inactive deployment
Preview — 94f75118 Deployed Sep 24, 2026 by vercel[bot]
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