- 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
| Problem in multi-user agent apps | How a Dynamic UI Tool solves it |
|---|---|
| Mid-task input: An agent needs extra input during a task (e.g. “Which PDF should I summarise?”). | Pop a file-picker on only the requester’s screen, collect the answer, continue the run. |
| Room wide polls/surveys: You want a one-off survey of everyone currently in the Room. | Allow the agent to fan-out an ask_user dialog to each participant and gather the responses asynchronously. |
| Targeted notifications: Agents must present notifications, approvals, or error messages only to the relevant user—not the whole Room. | Each UI toolkit is automatically scoped to the participant who registered it, so dialogs can’t leak across screens. |
| Security / Phishing: Users should not be able to show dialogs on another user’s screen just because a tool to show dialogs is exposed. | Toolkits are scoped to the participant that registers them. An agent must pass participant_id when it calls invoke_tool, so dialogs can’t leak to other users. |
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 multipleui 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.gettingstarted room. Leave this room connect process running; it is the process that hosts survey-toolkit and watches for messaging-enabled user participants.
bash
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
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
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
Next Steps: Using Dynamic Tools in Your Own App
MeshAgent UI client libraries include a privateui 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.