docs · tools

How tools work

You know what a tool is and how it reaches your agent. This page is the operating manual: what a run actually does, what it assumes about your session, and what the four ways it can go wrong mean.

Calling one

A tool is invoked by name, with a params object. What comes back is JSON shaped like the fields that tool declares — the agent reasons over those, not over a screenshot:

run a tool
run("linkedin-get-profile", { slug: "gastonfrancois" })

In practice you never type that. The model picks the tool and fills the params from what you asked for in plain language; the shape above is just what it ends up sending.

A run is deterministic

This is the property everything else hangs off, so it is worth stating plainly: there is no model inside a run. The tool already contains the requests to make and the code to read the answer. Calling it twice with the same params does the same thing twice.

That is what you get from it:

A composite keeps the property: it runs its steps in order and the glue between them is stable data — an id, a URL, a resolved region — never live browser state. Each step would work just as well on its own.

Side effects

Every tool declares what running it does to the world. This is the one field to read before calling something you have not called before:

LevelMeaningExamples
readChanges nothing — safe to run and retry freelysearch people, read a product, list orders
write · reversibleChanges state, and the change can be undoneadd to cart, react to a post, repost
write · irreversibleSends or publishes for real. There is no undosend a DM, post a comment, submit a connection request
There is no confirmation gate

A run of a write-irreversible tool executes immediately — nothing pauses to ask. The message is sent, the comment is public. Treat the level as the gate: build the confirmation into your own flow before calling one.

Sessions, not API keys

Most tools assume you are already logged in on the site. There are no tokens to configure and no credentials in a tool definition by design: the session lives in the browser profile the agent drives, exactly as it would if you were clicking around yourself.

Each tool declares what it assumes about the environment, and for the vast majority that is a single line: a live session on its site. Which browser holds that session, and why it is a separate one, is on the MCP server page.

Three ways a tool executes

Each tool records how it does its work. You rarely have to act on it, but it explains why some tools are quicker and sturdier than others:

KindHow it runsTrade-off
fetch-replayA request issued inside the page, from the site’s own origin, so the browser attaches the session itselfThe common case on signed-in sites, and the cheapest — the tab is usually already there
playwrightReal UI steps — navigate, click, type, wait for an elementWorks where nothing else does; slower, and more sensitive to a redesign
httpA direct HTTP call, made outside the browserCarries no cookies, so it only fits public endpoints that need no session

When a tool fails

Failures are typed, so an agent can recover by rule instead of guessing. Three cases cover almost everything:

ErrorWhat happenedWhat to do
re-authThe session expired or was never thereLog in manually in the tab that was left open, then retry. Retryable
not-applicableThe action does not apply — no permission, the thing does not exist, the state is wrongStop. Retrying changes nothing
tool-brokenThe site moved: a selector or an endpoint changedThe tool has to be re-learned. This is what the requestsave loop is for

Beyond those, a tool can return an error field of its own for conditions it knows about — a bad input, a rate limit, a product that is out of stock. Those are part of its declared result, not failures of the tool.

The distinction that earns its keep is re-auth versus tool-broken. One is your environment’s fault and is fixed by logging in; the other is the tool’s fault and is fixed by re-learning it. Collapsing them into “it didn’t work” makes every stale login look like breakage.

When a site changes underneath

It will. Sites ship redesigns, rename endpoints and rotate internal ids — a tool frozen against yesterday’s version eventually stops matching reality, and says so with tool-broken.

The fix is not a patch you write. It is the same loop that created the tool: the agent falls back to the browser, does the action the slow way, and requestsave replaces the recipe with one that matches the site as it is now. The tool keeps its name and its params, so nothing that calls it has to change — it just gets a new version underneath.

Each tool carries that version and a small health record — when it last succeeded, how many times it has failed — which is what makes a genuine breakage visible instead of showing up as an agent that quietly got worse.

Next