Build workflows
Reading web pages
Let an agent read and use a site as Markdown, following links and filling in forms by number, for a fraction of the tokens a browser snapshot costs.
web.* reads web pages as Markdown and acts on them by number. An agent opens a page, reads it, follows a link or fills in a form, and reads the page that comes back. It is the first thing to reach for when a workflow has to read or use a site: searching, working through a form, following a flow from page to page.
The web tools are available to every account with nothing to set up, under the web. prefix. They are meant for an agent's tools list, and they also work in tool steps.
How an agent sees the page
Every call answers with the page as the Markdown you would write by hand. Navigation, footers, cookie banners and anything the page hides are dropped. Links are numbered and form fields carry their current values:
# Sign up
[input: Email][f1]
[select: Plan = Starter (3 options)][f2]
[checkbox: Send me the newsletter][f3]
[button: Create account][f4]
Already have an account? [Sign in][1].
The next call names a number: web.fill with values: { "1": "ada@example.com", "2": "Team" } and submit: 4, or web.follow with link: 1. Numbers belong to the answer they came from, so an agent always acts on the latest one.
steps:
- key: price
kind: agent
model: balanced
tools: [ web.* ]
prompt: |
Open https://example.com, search for "{{ inputs.product }}" and report the first result's price.
Close the session when you are done.
Pages run their JavaScript in a browser engine written in Ruby, so single-page apps and Hotwire sites work, including what a page changes by itself between calls. web.read shows the page as it is now. A page longer than 40,000 characters comes in parts, and page: 2 reads the next one. A feed that loads more as you reach its end, such as a timeline or search results without page links, loads its next batch with web.scroll.
Every answer also lists the links in this part of the page as links: [{ n, text, href }], with each address made absolute, so a later step can use them without a model reading the page.
Reading a page once
web.extract reads a page in one call, with its JavaScript run, and answers with only what you ask for: the page as Markdown, its links, and the text, href and src of everything each CSS selector matches. There is no session to open or close. Use it for a page you only need to read, and to take a list of links or items off a page for a for_each step to work through.
- key: listing
kind: tool
tool: web.extract
args:
url: https://news.example.com/
markdown: false
selectors: { stories: "h2.title a" }
The answer is { url, title, status, markdown, truncated, links, matches, notes }, with matches.stories a list of { text, href }. An element without a link of its own takes the first one inside it, and href or src is left out when there is none. Turn markdown or links off when you don't need them, to keep what the next step reads small. A selector that isn't valid CSS fails the call with the reason.
Web tools or browser tools
Browser sessions drive a real Chromium and answer with an accessibility snapshot of every element. That costs many more tokens per page. Use them for what web.* can't do:
- screenshots along the way, a video or a Playwright trace of the session
- uploading a file
- a page that needs real layout, such as a canvas, a map or infinite scroll
For a page that only needs reading once, with nothing to click, web.extract needs no session, and builtin.fetch_url and builtin.extract are cheaper still for a page that reads fine without its JavaScript.
Signed-in reading
To read a site as an account you own, save a sign-in to a browser profile and pass its slug as profile to web.open or web.extract:
- key: inbox
kind: tool
tool: web.extract
args:
url: https://www.example.com/messages
profile: example-com
markdown: false
selectors: { unread: ".message.unread a" }
The page loads signed in. The profile's cookies and headers go only to the hosts it lists, as they do in a browser session. When a web.open session closes, the cookies the site refreshed are saved back to the profile, unless it's set to Don't save refreshed sign-ins. web.extract reads with the sign-in as it is and saves nothing back. If the sign-in came from a particular browser, pass that browser's user_agent as well, so the site sees the browser it signed in.
What a page can reach
Pages load signed out (unless given a profile), from the public internet, through the same gateway as screenshots and browser sessions. Addresses on a private network are refused, and so is every request a page makes to one. A workflow with egress: vpn or home sends its pages through that route.
A session keeps its cookies until it closes. It names itself as mdbrowse, the reader behind it. For a site that turns away or answers differently to an unfamiliar browser, pass user_agent to web.open and every request in the session, and the page's own navigator.userAgent, use it instead. An account can have 3 sessions open at once. A session closes when its run finishes, after ten idle minutes, or after 30 minutes in all, so have the agent close it when it is done.