Skip to content

Manual tool calls don't work #14

@Stevenic

Description

@Stevenic

I have a scenario where it may take a bit of time to run a tool (I need to make other model calls) so I'm trying to use manual tool calls but they don't work for a number of reasons. One issue I can work around but the other I can't without modifying the client code.

Tool registrations are overwritten
I think you might have been trying to reference this in the note but if you try to register tools before connecting to the server those registrations are overwritten when the connect happens. That's because immediately after the connect an empty updateSession() call is made here. And that results in existing tool registrations being overwritten here. To avoid that you have to re-register your tools with another call to updateSession() after you connect.

Manual tools always throw an error
The bigger issue is that any tool without a handler will result an error because of the call here. There wont be a tool config since the tool wasn't added using addTools() and an exception will be thrown here.

To work around the issue I add this logic in my version of the library:

image

Relay server tries to run tools as well
To add to the confusion, when running a relay server that also tries to call tools. I couldn't understand for a while why the fix above wasn't working and I was still getting an error. That's because the relay server tries to run tools but it doesn't have any handlers so it always throws an error. This sets up a race condition between the clients tool execution and the relay servers exception.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions