showcase/shell-docs/src/content/docs/frontend-tools.mdx
Frontend tools let your agent define and invoke client-side functions that run entirely in the user's browser. Because the handler executes on the frontend, it has direct access to component state, browser APIs, and any third-party UI library the page already uses. That's how an agent can "reach into" the app: update React state, trigger animations, read localStorage, pop a toast, or steer the user's view.
This page covers the "agent drives the UI" shape of frontend tools. The same primitive also powers Generative UI and Human-in-the-loop; see those pages for interaction patterns.
<InlineDemo demo="frontend-tools" />Use frontend tools when your agent needs to:
localStorage, sessionStorage, or cookiesRegister a frontend tool with useFrontendTool. Give it a name, a Zod schema for parameters, and a handler. The agent can then call it like any other tool and your frontend runs it in the browser.
The handler receives the parsed, type-safe parameters and can do anything the browser can: update state, call an API, touch the DOM. Its return value is sent back to the agent as the tool result so the model can reason about what happened.
<Snippet region="frontend-tool-handler" title="frontend/src/app/page.tsx — handler body" /> <FeatureIntegrations feature="frontend-tools" /> <IntegrationGrid path="frontend-tools" />