Skip to content

fix: updates count tool #254

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 20, 2025
Merged

fix: updates count tool #254

merged 9 commits into from
May 20, 2025

Conversation

blva
Copy link
Collaborator

@blva blva commented May 15, 2025

  • clarifies what is the method used for count in the description. tweaking the optional param didn't do the trick at all, but once I updated the description, cursor started to use the right values.

Tests

Cursor

Screenshot 2025-05-19 at 18 15 05

Claude

Screenshot 2025-05-19 at 19 00 59

Windsurf

Screenshot 2025-05-19 at 19 02 57

query: z
.record(z.string(), z.unknown())
.optional()
.describe("Alternative old name for filter. Will be used in db.collection.countDocuments()"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

is there a reason to keep providing this field?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, since the LLM was already confusing query/filter, I figure that it can get confused the other way around and try to send it as "query" because it thinks we'll use .count() (even though we call out is countDocments, but who knows, it might have outdated data about MDB)

Copy link
Collaborator

Choose a reason for hiding this comment

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

This doesn't make much sense to me. I think we should tweak the description of filter rather than accept two arguments that are doing the same thing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

np, I'll remove and update the description

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we can try that for now and see if it improves, based on the issue I'm not sure the LLM will stop getting confused

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would leave that up to your testing, my (untested) intuition would be to give the LLM less options. I think it was getting confused because filter was the actual MongoDB syntax thing to do for count rather than because it found both equally valid.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok, I think I found a way to keep the changes here minimal. I updated the tool description, clarifying it uses .count(). I think the LLMs were getting confused, more specifically cursor, with the fact that count() is deprecated and assuming it was countDocuments under-the-hood.

@blva blva marked this pull request as ready for review May 15, 2025 11:29
@blva blva requested a review from a team as a code owner May 15, 2025 11:29
@gagik gagik mentioned this pull request May 17, 2025
11 tasks
@blva blva requested review from nirinchev and gagik May 19, 2025 18:03
@blva blva merged commit 5f779a3 into main May 20, 2025
19 of 20 checks passed
@blva blva deleted the count-issue branch May 20, 2025 09:20
nirinchev added a commit that referenced this pull request May 23, 2025
* main: (21 commits)
  fix: updates count tool (#254)
  fix: docker security warnings (#259)
  feat: docker support (#238)
  docs: list alerts docs (#250)
  chore: add hints and update mcp (#249)
  chore: base model SEO change (#248)
  chore(ci): add a PR title check workflow (#247)
  docs: bump node.js version (#246)
  chore: corrects the description of atlas-create-db-user (#240)
  chore: auto-close stale issues (#237)
  chore(deps-dev): bump globals from 16.0.0 to 16.1.0 (#231)
  chore(deps-dev): bump @types/node from 22.15.9 to 22.15.17 (#233)
  chore(deps-dev): bump eslint-config-prettier from 10.1.2 to 10.1.5 (#234)
  feat: Alerts Listing (#230)
  chore(deps-dev): bump @redocly/cli from 1.34.2 to 1.34.3 (#235)
  chore(deps-dev): bump openapi-typescript from 7.6.1 to 7.8.0 (#232)
  chore: release v0.1.1 (#223)
  fix: improve uncaught exception for getAccessToken (#224)
  chore: update issue template (#227)
  chore: switch to `@mongodb-js/device-id` (#196)
  ...
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.

4 participants