Skip to main content
This guide explains how dynamic User Interface (UI) tools work in MeshAgent. These elements are client-side tools that run on a user’s browser, desktop, or mobile app. Dynamic UIs enable agents to interact directly with users by presenting responsive, on-demand interfaces as needed. They allow agents to do things like:
  • Collect a document from the user in the middle of a task
  • Pop up a one-off approval dialog
  • Fan out a survey to multiple participants in the room

Why Dynamic UI Tools Matter

How MeshAgent Safely Routes UI Tool calls

Behind the scenes MeshAgent supports private tool registrations. This ensures that dialogues only appear on the intended user’s screen even if several clients register toolkits with the same name. For example, you might have multiple ui toolkits: one with an ask_user tool that shows dialogues on a mobile app, and another with an ask_user tool that shows a dialogue in the browser. When a user interface registers a private tool, that tool is accessible only to the registering user. An agent can then invoke this private tool by including the unique identifier of the user (the participant ID) in its call. This ensures that the interface is displayed solely to the intended recipient.

Example: Survey Room Participants

Let’s create a tool that surveys participants in the Room. The tool will conduct a survey of the participants, summarize the results, and store both the raw results and the summary to the Room storage. The survey fields are dynamically generated so that we can gather a variety of information using the same UI tools. This means we can use the same tool to conduct a survey where participants respond yes/no to a question, or to provide more detailed feedback on their experience, etc.
Copy this code, activate your virtual environment, and run the toolkit in the gettingstarted room. Leave this room connect process running; it is the process that hosts survey-toolkit and watches for messaging-enabled user participants.
bash
Next go to studio.meshagent.com and click into the gettingstarted room. You can also use a Powerboards room page. The survey toolkit looks for messaging-enabled room participants with the user role and then invokes that participant’s private ui.ask_user tool. Before invoking the survey, confirm the room sees a user participant. This command joins the room as a temporary CLI participant, enables messaging for that CLI participant, and lists the other messaging-enabled participants it discovers:
bash
Copy the id for the user participant from that output. Then confirm the room sees the public survey-toolkit and, for that user participant, a private ui toolkit:
bash
If meshagent room messaging list returns only agents or [], the toolkit host does not currently see a user participant it can survey. Make sure the Studio or Powerboards room page is open in the same MeshAgent project and room. In that state no browser UI will appear, even if the survey tool itself is reachable. Invoke the survey tool from a separate terminal:
bash
Connected user participants will be prompted to fill out the survey in their UI client. Once the results are captured, the tool summarizes the responses and saves both the raw results and summary to Room storage.

Next Steps: Using Dynamic Tools in Your Own App

MeshAgent UI client libraries include a private ui toolkit pattern with tools such as ask_user and ask_user_for_file. A connected UI client must register that toolkit for its participant before another agent can invoke it. If you want custom dialogs in your own web or mobile client, register a private toolkit named ui with the same tool names and schemas. When an agent invokes the tool with that participant’s ID, MeshAgent routes the call to your application’s client-side UI implementation.