Server tools vs runtime tools

A tool can run in two places. In your backend, while the model writes its answer, so the values end up written into the UI as a snapshot. Or in the browser, after the UI renders, so the data stays live and changes without asking the model again. Same tool, very different interface.

By the end of this lesson you can

  • trace a server tool call and a runtime tool call from the user's question to the pixels;
  • say which one gives a snapshot and which one gives live data, and what a refresh costs in each;
  • explain how the model learns about each kind of tool, and which prompt wording each setup needs;
  • choose server tools, runtime tools or both for a given screen.

One tool, two places it can run

Take one tool, get_weather, defined once in your backend. A server tool runs during the model's turn: the model asks for it, your API runs it, the result goes back to the model, and the model writes OpenUI Lang with the numbers typed in. A runtime tool runs after the model has finished: the model writes a Query statement that names the tool, and the browser's Renderer calls it through its toolProvider. OpenUI's docs call these agent-side and UI-side tools.

The same question, two places to run the tool

  1. The user asks for the weather in Pune. In both setups the browser sends the question to your API, which calls the model with the system prompt. On the left the request also carries tool definitions the model can call; on the right the prompt carries an ## Available Tools section the model can write calls for.
  2. Server tool: the model stops mid-turn and asks for get_weather({city: "Pune"}). Your API runs it and hands the result back. Runtime tool: the model never sees any weather. It writes Query("get_weather", {city: $city}, defaults) and finishes.
  3. Server tool: the model writes the UI with 31 and "Thunderstorm" typed into it. Runtime tool: the Renderer reaches the Query, calls get_weather through its toolProvider, which POSTs to your API, and draws the result.
  4. The user wants Tokyo instead. On the left nothing on screen can change: the user asks again, and the whole turn repeats (model call, tool call, a new program). On the right $city changes, the Query's arguments change, and the browser fetches again. The model is idle.
  5. The difference in one line: a server tool gives a snapshot fixed at answer time; a runtime tool gives live data that follows the UI's state. You can use both in one answer.
Server tool (agent-side)Runtime tool (UI-side)
Who runs itYour backend, during the model's turnThe browser's Renderer, through toolProvider, after the program arrives
How the model learns it existsYour agent framework's tool definitions (for example AI SDK tools)The ## Available Tools section of the OpenUI system prompt, built from ToolSpecs
What the response containsThe values, written into the programA Query or Mutation statement, plus defaults
Fresh data costsA new model turnOne function call, no model
Where the implementation and keys liveYour serverYour server too: the browser only calls your API
OpenUI-specific setupNoneTool specs in the prompt, and a toolProvider on the Renderer

Both kinds can come from one registry. This repo's reference code defines each tool once and derives three consumers from it: the prompt's tool list, the endpoint the browser calls, and the server-side tool the model can call mid-turn.

Step through three setups

Pick a scenario and step through it. The bottom panel keeps a running tally: how many model turns, how many tool runs on the server, how many tool calls from the browser, and whether what is on screen is a snapshot or live. The weather values come from this course's simulated get_weather.

Things to look for

A baked card and a live card

Two recorded answers to the same question, rendered side by side by the course's simulator. The left one was written after a server tool call, so the weather is part of the program text. The right one was written with a runtime tool, so the program holds a Query bound to $city. Type a city below. The field sets $city in the live card, exactly as an Input bound to $city would; this page waits until you pause typing.

Baked: server tool

Model turns: 1 · server tool runs: 1 · browser tool calls: 0


      

Live: runtime tool

Model turns: 1 · server tool runs: 0 · browser tool calls: 0


      

Simulated: no model is called and the tool is an in-page function with a short delay. The cards are drawn by a teaching subset of @openuidev/react-lang; the real Renderer draws them with React.

Break it

Predict first. Tick Render the live card with toolProvider={null}. What does the live card show, and which error do you get?

What should happen

The card shows its defaults (an empty city and 0°) and there is no error at all. With no provider, the query manager never fetches: Query keeps its defaults and Mutation does nothing, silently. That is the real behaviour of @openuidev/lang-core 1.0.1, and it is the trap the chat lesson fixes: the stock chat message renders without a toolProvider. A provider that exists but lacks the tool is different: then you get tool-not-found. Now untick it and clear the city field: the tool rejects an empty city, and the live card reports a tool-error while the baked card, which never calls anything, stays as it was.

What the prompt has to say

The model learns about the two kinds of tool from two different places, and the system prompt has to describe the setup you actually have. When you pass tools to library.prompt({ tools }), the generated prompt gains the Query, Mutation and Available Tools sections. It also gains a ## Data Workflow section whose first step is:

1. FIRST: Call the most relevant tool to inspect the real data shape before generating code

That step assumes the model can call tools during its turn, which is only true when you also give it server tools. So each setup needs a sentence or two of its own, added with additionalRules in PromptOptions (they are appended after ## Final Verification). In plain terms:

Key idea

Server tools are invisible to OpenUI: they are ordinary agent tools, declared and run by your framework, and the model sees their results. Runtime tools are visible only to OpenUI: the model sees their name and schemas in the prompt, never their results, and the browser does the calling.

OpenUI rule

Treat a runtime tool's arguments as untrusted. The model chose them and the call comes from the browser, so your tool endpoint validates them like any other client request.

Choosing

OpenUI's docs boil it down to one question: does the user need the data to change without asking the agent again? If a snapshot is enough (an answer, a summary, a one-off lookup) use a server tool. If the user will filter, refresh or edit in place (a dashboard, a filterable table, a form that writes) use a runtime tool. Most agents start with server tools and add runtime tools for the screens people keep working in. Sort these:

  • "Summarise last quarter's revenue" answered with one chart. A snapshot is the answer. Nobody will change the quarter in place; a follow-up question is fine.
  • A ticket table the user filters by priority. Each filter change should be one function call, not a model turn: Query bound to a $variable.
  • A form that creates a calendar event. A write the user triggers: a Mutation fired by @Run when they click.
  • "How is the Acme account doing?" The agent must first work out which account is meant, then show its metrics with a changeable date range. Server tool to resolve the account while deciding what to say; a Query on that account's id for the live dashboard. This is the docs' own example of using both.
  • Check which columns a dataset has before deciding what chart to draw. The model needs the data to decide what to write. Only a server tool puts data in front of the model.
  • "Is it warmer in Pune or Tokyo?", and the user wants to try other cities afterwards. The comparison sentence needs the data now (server tool); the card for further cities should be live (runtime tool).

Common misconception

"Runtime tools put my API keys in the browser." They do not. The browser calls your endpoint, which holds the keys and calls the upstream API. What runtime tools do expose is that endpoint: anyone with the page can call it with any arguments, so it needs the same authentication, authorization and rate limits as the rest of your API.

Quick check

The model answered with a weather card after calling get_weather on the server. The user wants the same card for Tokyo. What has to happen?

  • The Renderer re-runs the tool with the new city
  • Nothing: the card re-fetches when the city changes
  • A new model turn: the model calls the tool again and writes a new program
With a server tool, the values are text inside the program. Nothing in the browser knows a tool was involved, so fresh data means asking the model again.

How does the model learn that a runtime tool exists?

  • From the agent framework's tool definitions, like any other tool
  • From the ## Available Tools section that library.prompt({ tools }) writes into the system prompt
  • The Renderer tells it after the first render
Runtime tools reach the model only as text in the OpenUI prompt: name, input and output signature, description and default shapes. The model writes calls to them; it never runs them or sees their results.

A generated dashboard uses Query, but the Renderer was given no toolProvider. What does the user see?

  • The query defaults, with no error
  • A tool-not-found error on each query
  • Nothing renders until a provider is set
With a null provider the query manager simply never fetches, so the UI shows the defaults the model wrote, silently. tool-not-found appears only when a provider exists and lacks that tool.

Recap