Skip to content

Updating the tool name more than once leads to buggy behavior #414

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

Open
nirinchev opened this issue Apr 26, 2025 · 0 comments
Open

Updating the tool name more than once leads to buggy behavior #414

nirinchev opened this issue Apr 26, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@nirinchev
Copy link

nirinchev commented Apr 26, 2025

Describe the bug
#247 introduced the ability to mutate tools, prompts, and resources, but the way updating by name/uri works is buggy in that it captures the original identifier and continues using it, even if it's no longer the correct one. This means that updating e.g. a tool name more than once leads to incorrect behavior.

To Reproduce
Steps to reproduce the behavior:

  1. Register a tool by name - let's say "Foo"
  2. Call foo.update({ name: "Bar" }). This works well and we remove "Foo" from registered tools and add "Bar".
  3. Call foo.update({ name: "Foo" }) - trying to return to the original name. This has no effect because the check updates.name !== name returns false, since name is the captured original name (Foo) rather than the current tool name (Bar).
  4. Alternatively, if we call foo.update({ name: "Baz" }), we end up with calling delete this._registeredTools[name], which tries to delete Foo, which is anyway no longer present in _registeredTools, and then adds Baz, ending up with both Bar and Baz in the _registeredTools collection.

Expected behavior
Updating a tool/resource/prompt identifier should compare the new identifier to the current one, rather than the original one.

@nirinchev nirinchev added the bug Something isn't working label Apr 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant