Toolkit allows you to group related Tools together so that they can be used seamlessly by any person or agent in the Room.
In this quickstart we’ll walk through how to:
- Write custom tools
- Create a toolkit to group your related tools
- Call a toolkit into a MeshAgent Room
- Invoke tools using the MeshAgent Studio UI, MeshAgent CLI, and code
- Discover available tools in a Room
Creating a custom toolkit
Step 1: Writing custom tools
Let’s create a simple toolkit with two tools, one that can add two numbers, and one that can subtract two numbers. First we’ll write the logic for the Add and Subtract tools. Next, we’ll bundle them into aRemoteToolkit that the ServiceHost can register for room calls.
When we call the tools into the room either with meshagent call tool or meshagent service run, the ser
Step 2: Calling custom tools into a MeshAgent Room
From the terminal inside our activated virtual environment we’ll use the MeshAgent CLI to call the toolkit into the room./math. If you are running multiple agents or tools, you can use the same ServiceHost and set different paths for each of the agents and toolkits. The service run command automatically detects the different paths and identities (this is the recommended way to test your agents and tools).
As an alternative to the service run command you can also run the service locally by running python main.py in one tab in your terminal, then from another tab you can call individual toolkits into the room using the meshagent call tool command. If you do this, be sure you’ve also stored a MESHAGENT_API_KEY in your environment. You can create and activate a key from the MeshAgent CLI by running mehsagent api-key create <your-key-name> activate then export the result. For example:
/math path with the name math-toolkit. Once the toolkit joins the room, you can invoke it directly from the MeshAgent Studio UI, the MeshAgent CLI, or through code.
Step 3: Invoking a MeshAgent Tool
Invoking tools in MeshAgent Studio
- Go to studio.meshagent.com and login
- From the Sessions tab enter the
toolsroom - From the Menu in the upper left you can either invoke the tool directly through Toolkits or add it to a TaskRunner through Run Task
- Using the Toolkit directly: Click Toolkits…, find the tool you want to run then click Invoke. This will collect the parameters needed from you (if any) and display a dialogue for you to enter any required values. Once finished click Ok. The tool will execute and display the result in the Studio UI.
- Using A TaskRunner: Click Run Task…, then select the Generic Task Runner as the agent, next click the “Add Tools” button. Now you’ll see our math-toolkit with both the “add” and “subtract” tools. On both of the tools you will see an info button, an invoke button, and an add button. The info button will display the JSON schema we created to define the tool, the invoke button will invoke the tool directly, and the add button will add the tool(s) to the TaskRunner. Select either the “Invoke” or “Add Tool” option for either the “add” or “subtract” tool and an agent will collect the required values and execute the tool.
Invoking tools from the MeshAgent CLI
While the service is running, from a new tab in your terminal invoke the tool. The result will print to the terminal.bash
Invoking tools from code
You can also call the tool directly from code. Assuming your service is still running, we can also invoke the tool using the MeshAgentRoomClient. This code will create a ParticipantToken will the required permissions to invoke the tools, connect to the room with the token, then invoke both the add and subtract tools.
Discovering tools
At any time, you can use the MeshAgent CLI or connect to the room with aRoomClient to discover what tools are connected to a given room. This can be useful if you want to allow your users to grant additional capabilities to your agents at runtime or verify a tool is present in the room.
Discovering tools from the CLI
Discovering tools from code
Running this snippet will show any tool available as a MeshAgent service as well as tools that are currently connected to the Room. Again we construct theParticipantToken with the appropriate permissions, connect to the room with the RoomClient, then list the available toolkits.
Next Steps
If you want your tools to be available in all the Rooms inside your Project you will need to deploy the tool as a MeshAgent service. You can also define a tool while you define an agent and just deploy your agent as a MeshAgent service. This will make the agent available in all of the MeshAgent Rooms in your Project, but your tool won’t be directly invokable by anyone other than the agent you defined the tool with.- Dynamic UI Tools: Learn what Dynamic UI tools are and how to build and use them in your applications
- Learn how to use custom tools inside a Chat Agent or Voice Agent
- Services & Containers: Understand different options for running, deploying, and managing agents and tools with MeshAgent