Skip to content

fix(compass-aggregations): exclude database-level operators from AI prompts and autocomplete COMPASS-10677#8144

Open
ivandevp wants to merge 2 commits into
mainfrom
COMPASS-10677
Open

fix(compass-aggregations): exclude database-level operators from AI prompts and autocomplete COMPASS-10677#8144
ivandevp wants to merge 2 commits into
mainfrom
COMPASS-10677

Conversation

@ivandevp

@ivandevp ivandevp commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Description

When users ask the AI assistant to generate an aggregation pipeline with prompts like "Create a pipeline to generate 20 documents describing different roasted coffee beans", the AI would suggest $documents (and other database-level stages). These fail at runtime because they require {aggregate: 1} (database-level aggregation), not collection-level:

'$documents' can only be run with {aggregate: 1}

The text editor's autocomplete also surfaced these operators, compounding the confusion.

Two fixes:

  1. AI prompt — added an explicit instruction to buildInstructionsForAggregateQuery() prohibiting database-level stages ($documents, $changeStream, $currentOp, $listLocalSessions, etc.) and explaining the pipeline runs against a collection.
Screenshot 2026-06-10 at 09 58 28
  1. Autocomplete — wired the existing stage.namespace filter (already used by the stage wizard) through to createAggregationAutocompleter, so the text editor no longer suggests operators whose namespaces is ['db'].
Screenshot 2026-06-10 at 09 54 39

Checklist

  • New tests and/or benchmarks are included
  • Documentation is changed or added
  • If this change updates the UI, screenshots/videos are added and a design review is requested
  • If this change could impact the load on the MongoDB cluster, please describe the expected and worst case impact
  • I have signed the MongoDB Contributor License Agreement (https://www.mongodb.com/legal/contributor-agreement)

Motivation and Context

  • Bugfix
  • New feature
  • Dependency update
  • Misc

Fixes COMPASS-10677.

Open Questions

N/A

Dependents

N/A

Types of changes

  • Backport Needed
  • Patch (non-breaking change which fixes an issue)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to change)

ivandevp added 2 commits June 9, 2026 09:20
…rompts and autocomplete COMPASS-10677

Prevent the AI from suggesting $documents and other db-level stages in
collection aggregations, and remove them from the text editor autocomplete
by wiring the existing namespace filter through to createAggregationAutocompleter.
@ivandevp ivandevp requested a review from a team as a code owner June 10, 2026 13:00
@ivandevp ivandevp requested a review from paula-stacho June 10, 2026 13:00
@github-actions github-actions Bot added the fix label Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant