Skip to content

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

Open
@nirinchev

Description

@nirinchev

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions