Articles

Site search and filters AI agents can use

Usually fixed by: Developer

Ask an AI agent to "find a waterproof trail shoe under $150 in size 10" and, on most stores, it does what a person would: types into the search box, then narrows the results with filters. If the search box is hard to find, the results only exist inside a script, or the filters are custom widgets it can't operate, the agent gives up or picks the wrong thing. This guide covers how to build search and filters that AI agents can use, and that work better for people too.

How agents use search and filters

There are two broad ways an AI agent gets to a list of products:

  • Through the page. Browser agents open your site, find the search box by its label, type, press Enter, and then click filters and sort options, much as a keyboard or screen-reader user would.
  • Through the address. If your search and filtered results have their own URLs, an agent can go straight to /search?q=trail+shoes or a filtered category page. AI assistants that fetch pages rather than click through them can only work this way: they can't type into a box, but they can open a link.

A site that supports both gives every kind of agent a route to the right products. A site that supports neither forces agents to browse category pages one by one, which is slow and often ends with a worse answer.

A search box agents can find and use

The search box should be a real form that works without anything clever. That means a labelled field, a named submit button, and a results page that loads when the form is submitted.

<form role="search" action="/search" method="get">
  <label for="q">Search products</label>
  <input id="q" name="q" type="search" autocomplete="off">
  <button type="submit">Search</button>
</form>
  • Label it. A visible label or an aria-label such as "Search products". A magnifying-glass icon on its own has no name an agent can read.
  • Keep it visible. A search box that only appears after clicking an unlabelled icon is an extra step agents often miss. If space is tight, make the icon a real button named "Search".
  • Make Enter work. Pressing Enter should submit the search and open a results page. Predictive suggestions as you type are fine, but they shouldn't be the only way to get results.
  • Accept the words people use. Product names, product types, brands, SKUs, common misspellings and synonyms ("sneakers" and "trainers"). An agent passes on what the person asked for, in their words.

Give results and filters their own URLs

This is the single most useful change for AI agents, and it's good for people too: results can be bookmarked, shared and reached with the back button.

Every search and every combination of filters should be reflected in the address, using readable parameters:

https://northwind.example/search?q=trail+shoes
https://northwind.example/collections/shoes?waterproof=yes&size=10&max_price=150
https://northwind.example/collections/shoes?sort=price-asc&page=2
  • Update the URL when filters change. If your filters work without reloading the page, update the address as they're applied, so the current view always has a link.
  • Make the URL load the same results. Opening that link fresh, with no history, should show the same filtered list.
  • Put results in the HTML. If results are only drawn by JavaScript, agents that read HTML see an empty page. See why AI agents can't see your JavaScript-only content.
  • Use plain parameter names and values. size=10 and color=black are guessable. f=a8x2k isn't.

Filters as real controls

Filters are where many stores lose agents. They're often built as custom widgets that look good but aren't recognizable as checkboxes, options or buttons. The fix is to use the controls the browser already provides.

FilterHard for agentsEasy for agents
Size, brand, featureClickable boxes made from <div>sCheckboxes with labels, grouped in a <fieldset> with a <legend>
ColorSwatches with no text, only a background colorCheckboxes or buttons named "Black", "Navy", with the swatch as decoration
PriceA drag-only slider"Min" and "Max" number fields, with or without a slider alongside
Sort orderA custom dropdown that opens on hoverA native <select>, or a list of real links
More resultsInfinite scroll onlyNumbered page links, or a "Load more" button backed by a ?page=2 link
<fieldset>
  <legend>Size</legend>
  <label><input type="checkbox" name="size" value="9"> 9 (14)</label>
  <label><input type="checkbox" name="size" value="10"> 10 (22)</label>
</fieldset>
<label for="sort">Sort by</label>
<select id="sort" name="sort">
  <option value="relevance">Most relevant</option>
  <option value="price-asc">Price: low to high</option>
</select>

A few more details that save agents from guessing:

  • Say how many results there are in text ("24 products"), and update it when filters change. An aria-live region lets assistive tech, and agents reading the page structure, notice the change.
  • Show active filters as named buttons that remove them ("Remove filter: Size 10"), plus a "Clear all".
  • Handle no results helpfully. Say plainly that nothing matched, and offer a way out: related categories, or the same search without the last filter.
  • Keep filter panels reachable. On smaller screens, the "Filters" toggle should be a real, named button, not an icon.

Tell agents how your search works

Once your search has a predictable URL, you can describe it so agents don't have to discover it:

  • In llms.txt. A line such as "Search: https://northwind.example/search?q={query}" in your llms.txt file hands the pattern to any AI that reads it.
  • In structured data. schema.org lets a WebSite describe its search with a SearchAction. Google retired the search box it used to show for this in 2024, so don't expect a search result feature from it, but it remains a standard, machine-readable description of your search URL.
  • As a tool. The most direct option is to let agents call your search as a tool, through an MCP server or WebMCP in the browser. Both are newer and still settling; see MCP and WebMCP for websites.

Watch your robots.txt. Many sites stop search engines indexing internal search results, which is sensible. But a blanket Disallow: /search for every bot also tells AI assistants that respect robots.txt not to open those pages when a person asks them to. Decide deliberately which agents that rule should apply to. See robots.txt for AI agents.

What AgentScore and Ghost Agents test

AgentScore doesn't have a separate check for search, but several of its checks cover the building blocks. On the home page, where most search boxes live, it checks that form fields are labelled, that buttons and links have names, and that clickable things are real buttons and links. "Content loads without JavaScript" catches a home page whose content only appears once scripts run, a sign that results and filters may be built the same way. The free scan doesn't run a shopping journey itself; a Ghost Agent test does, and a search box or filter that doesn't work shows up in its step-by-step replay.

Search is also one of the journeys Ghost Agents can test for you. You choose the journey, such as "search for a waterproof trail shoe, filter to size 10 and open the first result", and a Ghost Agent works through it like a customer would, on the schedule you set. When a theme update or a new search app breaks it, you find out before customers do. See how to test your key journeys with AI agents.

A quick checklist

  1. Search box is visible, labelled, and submits with Enter to a results page.
  2. Searches and filtered views have their own readable URLs that load the same results when opened fresh.
  3. Results are in the page HTML, not only drawn by JavaScript.
  4. Filters are checkboxes, selects, number fields and buttons with names, not styled boxes.
  5. Result counts, active filters and "no results" are shown in text.
  6. Pagination uses real links.
  7. Your search URL is described in llms.txt, and robots.txt doesn't shut AI assistants out of it by accident.

For the controls on the rest of the page, see buttons, links and forms agents can use. For getting agents to your categories in the first place, see link your key pages from the home page.

← All articles Test your site with AgentScore →

Can AI agents use your site?

Get your free AgentScore in under a minute. No sign-up needed.