Skip to content

Conversation

@nirinchev
Copy link
Collaborator

Proposed changes

This change adds a previewFeatures config option that users can provide to enable non-GA functionality. For now, the only option is vectorSearch.

@nirinchev nirinchev requested a review from a team as a code owner October 24, 2025 10:42
Copilot AI review requested due to automatic review settings October 24, 2025 10:42
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a new previewFeatures configuration option to enable non-GA functionality, replacing the previous approach of using voyageApiKey presence as a feature flag. Currently, the only preview feature is vectorSearch.

Key changes:

  • New previewFeatures array configuration option that accepts feature flags like "vectorSearch"
  • Refactored feature detection from checking voyageApiKey presence to checking the previewFeatures array
  • Updated tests to use the new configuration approach

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/common/config.ts Adds previewFeatures config option with enum validation and array handling
src/tools/tool.ts Replaces FeatureFlags enum and isFeatureFlagEnabled() with isFeatureEnabled() using string literals
src/common/search/embeddingsProvider.ts Updates vector search configuration check to include previewFeatures
src/tools/mongodb/metadata/collectionIndexes.ts Updates feature check from FeatureFlags.VectorSearch to "vectorSearch"
src/tools/mongodb/create/createIndex.ts Updates feature check from FeatureFlags.VectorSearch to "vectorSearch"
src/tools/mongodb/delete/dropIndex.ts Updates feature check from FeatureFlags.VectorSearch to "vectorSearch"
tests/integration/tools/mongodb/read/aggregate.test.ts Updates test config to use previewFeatures: ["vectorSearch"]
tests/integration/tools/mongodb/metadata/collectionIndexes.test.ts Updates test config to use previewFeatures: ["vectorSearch"]
tests/integration/tools/mongodb/delete/dropIndex.test.ts Updates test config to use previewFeatures: ["vectorSearch"]
tests/integration/tools/mongodb/create/createIndex.test.ts Updates test assertions and config to use previewFeatures
tests/accuracy/aggregate.test.ts Corrects typo from 'sci-fy' to 'sci-fi'
tests/accuracy/createIndex.test.ts Updates test config to use previewFeatures: "vectorSearch"
tests/accuracy/createIndex.vectorSearchDisabled.test.ts Updates test config to use previewFeatures: ""
tests/accuracy/dropIndex.test.ts Updates test config to use previewFeatures: "vectorSearch"
tests/accuracy/dropIndex.vectorSearchDisabled.test.ts Updates test config to use previewFeatures: ""
README.md Adds documentation for the new previewFeatures configuration option

defaults: Partial<UserConfig>;
}): UserConfig {
const userConfig: UserConfig = {
const userConfig = {
Copy link

Copilot AI Oct 24, 2025

Choose a reason for hiding this comment

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

The type annotation was removed from userConfig. This makes the code less maintainable as the return type is no longer explicitly documented at the declaration site. Consider restoring the type annotation: const userConfig: UserConfig = {

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

Choose a reason for hiding this comment

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

[q] why are we removing this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's already type asserted a few lines down, so I figured it's a bit redundant - const foo: Foo = { } as Foo is a bit repetitive. For context, we're not losing on type safety because we have the as UserConfig assertion anyway. That being said, since this is multiline, I can see how it might not be super obvious, so happy to bring it back if it's clearer.

@coveralls
Copy link
Collaborator

coveralls commented Oct 24, 2025

Pull Request Test Coverage Report for Build 18780521612

Details

  • 14 of 15 (93.33%) changed or added relevant lines in 6 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.02%) to 80.155%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/common/search/embeddingsProvider.ts 1 2 50.0%
Files with Coverage Reduction New Missed Lines %
src/common/search/embeddingsProvider.ts 1 45.83%
Totals Coverage Status
Change from base Build 18777096610: 0.02%
Covered Lines: 6293
Relevant Lines: 7713

💛 - Coveralls

Copy link
Collaborator

@gagik gagik left a comment

Choose a reason for hiding this comment

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

Looks good to me.

Copy link
Collaborator

@blva blva left a comment

Choose a reason for hiding this comment

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

non-blocking comments

...DbOperationArgs,
indexName: z.string().nonempty().describe("The name of the index to be dropped."),
type: this.isFeatureFlagEnabled(FeatureFlags.VectorSearch)
type: this.isFeatureEnabled("vectorSearch")
Copy link
Collaborator

Choose a reason for hiding this comment

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

the ultimate nit: why not keep vectorSearch as a const against typos or even maintainisVectorSerachFeatureEnabled at the same level as isFeatureEnabled?

another nit: btw I usually prefer to keeping a tiny file with this logic as it might grow and we could also add some unit tests just while we're here to keep it safe from future changes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

"vectorSearch" is a const in a union type. So when calling isFeatureEnabled you can only provide one of the preview features we've defined in the previewFeatures enum in config.ts.

Not sure I fully understood the second half of your suggestion - what part of the logic would you suggest we move to a separate file? For context, the enum values are currently defined in config.ts along with the PreviewFeatures union type, while isFeatureEnabled is defined on the base tool type. We could move it to config.ts if that makes more sense, but I wanted to keep the user config as close to a data bag as possible, which is why I opted to define the isFeatureEnabled helper in the base tool.

Copy link
Collaborator

@gagik gagik Oct 27, 2025

Choose a reason for hiding this comment

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

To add to this: enums in JavaScript are pretty terrible and it's best to avoid them.
https://jsdevspace.substack.com/p/shrink-typescript-code-replace-enums
Especially because of "erasable syntax" that can allow us to run TypeScript in Node directly:
https://www.totaltypescript.com/erasable-syntax-only
Probably something to introduce as a lint rule soon.

defaults: Partial<UserConfig>;
}): UserConfig {
const userConfig: UserConfig = {
const userConfig = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

[q] why are we removing this?

@nirinchev nirinchev merged commit 34c9c68 into main Oct 27, 2025
19 checks passed
@nirinchev nirinchev deleted the ni/feature-flags branch October 27, 2025 16:03
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.

5 participants