My AI Testers Aren't Allowed to Touch the Browser. That's Why Their Bugs Are Reproducible
Ask an LLM agent to explore a web application and it will happily come back with a list of bugs. Then try to reproduce them. Which page was it on? Which button did it click, and with which selector? Was that error real,
Ask an LLM agent to explore a web application and it will happily come back with a list of bugs. Then try to reproduce them.
Which page was it on? Which button did it click, and with which selector? Was that error real, or a misread of the DOM? Without answers, a bug report written by an AI is just an opinion, and developers are right to ignore opinions.
That is the real problem with AI-driven testing. Finding "bugs" is easy. Finding bugs a developer will believe is hard.
So I built Agentic Test Explorer around one rule: the agents think, but they never touch the browser. Everything they do goes through a deterministic engine that records it, and every bug ends up as a Playwright test you can run on your machine.
TL;DR
- Eight LangGraph agents, each playing a different kind of user, explore any web app configured with a small
config.yaml. - Agents emit JSON intents. A Playwright engine validates them, executes them and appends them to an immutable Action Tape.
- When an agent finds a bug, the tape is translated into a runnable
reproduction_*.spec.ts. - The engine rejects brittle selectors (XPath,
nth-child, positional chains) before they reach the browser. - A SQLite-backed memory remembers pages, flaky selectors and known bugs between runs, and can generate regression missions from them.
- Point it at a GitHub pull request and it writes test missions for the UI areas the diff touches.
The architecture in one picture
flowchart TD
M[Mission YAML or PR URL] --> S{Supervisor<br/>routing LLM}
S -->|next agent| A1[Persona agents<br/>ReAct loop]
A1 -->|JSON intent| E[Browser engine<br/>validate + execute]
E -->|DOM snapshot| A1
E --> T[(Action Tape<br/>JSONL)]
A1 --> SUM[Summarizer<br/>compacts history]
SUM --> S
S -->|FINISH| R[Report + .spec.ts + screenshots]
T --> R
It is a supervisor-worker swarm built with LangGraph. A supervisor decides which persona acts next; the persona runs a ReAct loop with its tools; a summarizer keeps the conversation bounded; control goes back to the supervisor until it decides the mission is done.
This is the actual graph for the standard swarm. I didn't draw it by hand: it is the Mermaid diagram that the tool's own Visual Mode generates, with the active agent highlighted.
stateDiagram-v2
new_user_agent : New User
power_user_agent : Power User
adversarial_user_agent : Adversarial
[*] --> Supervisor
Supervisor --> new_user_agent
Supervisor --> power_user_agent
Supervisor --> adversarial_user_agent
Supervisor --> FINISH
new_user_agent --> Summarizer
power_user_agent --> Summarizer
adversarial_user_agent --> Summarizer
Summarizer --> Supervisor
FINISH --> [*]
classDef active fill:#10b981,stroke:#047857,stroke-width:4px,color:#000
class power_user_agent active
Rule #1: the brain is not the hands
Agents get exactly one way to act on the page: the execute_browser_command tool, which takes a strict JSON object:
{"action": "fill", "selector": "input[aria-label='Search']", "value": "hello"}
Eleven actions are allowed: navigate, click, fill, press, select_option, hover, wait_for, scroll, extract_text, snapshot and check_page_health. Anything else is rejected with an error the agent can read. The raw Playwright toolkit tools are explicitly filtered out of every agent's tool list, so there is no back door.
For every command, the engine:
- Parses and validates the JSON.
- Checks the selector against the resilience policy (more on that below).
- Executes it with Playwright.
- Takes a fresh DOM snapshot.
- Appends an entry to the per-mission Action Tape, in memory and in
action_tape.jsonl. - Returns a plain-text block to the agent:
STATUS: ERROR
ACTION: click {"selector": "[data-test-subj='checkout']"}
DURATION_MS: 5012
ERROR: TimeoutError: ... (Recoverable — try a different selector or action.)
DOM_SNAPSHOT:
URL: https://app.example.com/cart
TITLE: Cart
SOURCE: accessibility_tree
* [0] role=button name='Update'
- [1] role=heading name='Your cart'
...
Errors are returned as text, not raised. That is what makes the agents self-healing: a failed click is just another observation, and the agent can try a different selector on its next step.
The check_page_health action deserves a mention: it scans the live DOM for visible error banners, role="alert" elements and spinners that never stop (aria-busy="true"), so "the page is quietly broken" becomes something an agent can detect.
What the agent actually "sees"
Feeding raw HTML to an LLM is slow, expensive and noisy. The engine builds a compact digest instead:
-
Primary: Playwright's accessibility tree. It already excludes scripts, styles and hidden nodes, so it is the smallest faithful picture of what a user can perceive. It is flattened to at most 150 elements, and the agent receives up to 80 of them, with interactive roles marked with
*. -
Fallback: a pruned JavaScript DOM walk that skips
script,style,svginternals and invisible elements, and keeps buttons, links, inputs,data-test-subjattributes and short visible text.
flowchart TD
P[Page] --> AX{Accessibility tree<br/>available?}
AX -->|yes| F1[Flatten tree<br/>max 150 nodes]
AX -->|no| JS[Pruned JS DOM walk]
F1 --> D[Digest for the LLM<br/>max 80 elements]
JS --> D
Rule #2: no brittle selectors, ever
LLMs love selectors like div > div:nth-child(3) > button. They work once and break with the next CSS change, and a reproduction script full of them is useless a week later.
So the engine refuses them before touching the browser. A regular expression catches XPath, :nth-child, :nth-of-type and bare positional div/span/li chains. These are real results from the validator:
| Selector | Verdict |
|---|---|
//div[@id='x']/button |
rejected |
div > div:nth-child(3) > button |
rejected |
ul > li:nth-of-type(2) |
rejected |
main > div > span |
rejected |
[data-test-subj='saveButton'] |
accepted |
button:has-text('Save') |
accepted |
role=button[name='Submit'] |
accepted |
The rejection message tells the agent what to use instead, in order of preference: data-test-subj, then aria-label, then visible text, then semantic role, and suggests taking a DOM snapshot to find a stable attribute.
From Action Tape to a runnable test
When an agent decides something is wrong, its instructions are to call two tools immediately: capture_bug_screenshot and generate_reproduction_spec. The second one translates the tape into Playwright code. For a tape like this one:
navigate https://app.example.com/cart
fill input[aria-label='Quantity'] = "-1"
click button:has-text('Update')
click [data-test-subj='checkout'] -> TimeoutError
the generator writes:
import { test, expect } from '@playwright/test';
test.use({ storageState: 'auth.json' });
test('reproduce: Checkout button disappears after negative quantity', async ({ page }) => {
test.setTimeout(120_000);
await page.goto('https://app.example.com/cart');
await page.fill('input[aria-label=\'Quantity\']', '-1');
await page.click('button:has-text(\'Update\')');
// FAILED AT RECORD TIME (kept to reproduce error): click {"selector": "[data-test-subj='checkout']"}
// Error: TimeoutError: locator not visible
await page.click('[data-test-subj=\'checkout\']');
});
(The URL and steps are an example; the generated lines are the real output of the translator for that tape.)
My favourite detail is the comment: failed steps are kept, annotated with the error seen at record time. The failure is the reproduction, so dropping it would defeat the purpose.
Eight ways to use (and abuse) your app
Each agent is the same ReAct loop with a different system prompt. The mission's thread_id decides which swarm runs:
| Swarm | Persona | What it tries |
|---|---|---|
| Standard | New User | Onboarding, discoverability, default and empty states |
| Standard | Power User | Keyboard shortcuts, bulk operations, advanced filters, chained workflows |
| Standard | Adversarial User | Invalid input, injection-like strings, rapid clicks, back-button abuse |
| Advanced | Accessibility | Keyboard-only navigation, labels, WCAG issues |
| Advanced | Data Heavy | Large inputs, long strings, many records |
| Advanced | Impatient | Cancelling mid-flight, refreshing during submissions, double clicks |
| Advanced | Returning User | Stale sessions, cached pages, old bookmarks |
| Advanced | Explorer | Open-ended exploration and cross-feature regressions |
A mission is just YAML:
missions:
- thread_id: test_adversarial_user_01
prompt: 'Persona: adversarial_user_agent
Test <APP_URL> adversarially. Enter malformed strings, manipulate the URL parameters
manually, abuse the browser back/forward buttons constantly, and check if the
app degrades securely without exposing sensitive info.'
Keeping a swarm on a leash
Multi-agent systems fail in boring ways: they loop, they forget the goal, or they blow up the context window. Most of the code in the orchestration layer is about preventing that.
Routing is structured. The supervisor doesn't free-text its decision. It uses structured output with a JSON schema whose next field is an enum of the agent names plus FINISH, so it cannot route to an agent that doesn't exist.
The supervisor reads a brief, not the whole transcript. Before each decision it gets a bounded summary: the mission, the last 12 progress lines, the last 10 browser actions, up to 8 bugs found and up to 8 explored URLs. That is enough to pick the next worker, and it doesn't grow with the length of the mission.
A step limit forces diversity. After --max-steps cycles (30 by default), the supervisor injects a reset directive: "Navigate back to {app URL}, reset state, and pick a COMPLETELY DIFFERENT area of the application. Do not repeat any interaction already tried." It includes the list of areas already explored.
History is compacted without an LLM call. After every agent turn, a Summarizer node keeps the original mission and the 20 most recent messages, and replaces everything in between with a one-message textual digest. The state also keeps only the last 50 tape entries; the full tape lives in the JSONL file.
flowchart TD
A[Agent turn ends] --> B{More than 21 messages?}
B -->|no| S[Supervisor]
B -->|yes| C[Keep mission + last 20 messages]
C --> D[Replace the middle with<br/>a compact text summary]
D --> S
S --> E{Step limit reached?}
E -->|yes| F[Inject reset directive:<br/>go home, explore a new area]
E -->|no| G[Route to next agent or FINISH]
F --> G
Counting bugs is harder than finding them
An unexpected amount of work went into a question that sounds trivial: how many bugs did we find?
Agents describe the same finding in three different shapes: a snake_case slug in the screenshot tool, a structured entry in their closing message, and prose like "BUG FOUND: Empty cart lacks messaging." Counting all three triples the number.
The fix has two parts. First, a contract in the system prompt: every agent must finish its turn with a <bugs_found> block containing one JSON object per issue (title, summary, location, severity), or an explicit empty list. Second, a deduplication step that normalises each entry to a lowercase title key and treats two entries as the same bug when one key is a prefix of the other and the shorter one has at least 12 characters. "Login error" and "Login redirect" stay separate; three phrasings of the empty cart issue collapse into one.
Memory: the second run is smarter than the first
Exploration without memory is groundhog day: every run rediscovers the same pages and trips over the same flaky selectors. The framework keeps a LangGraph store in SQLite, namespaced by a hash of the app URL:
flowchart TD
R[Mission run] --> SEM[Semantic memory<br/>pages, selector reliability, quirks]
R --> EPI[Episodic memory<br/>session summaries, bug catalog]
EPI --> PRO[Procedural memory<br/>LangMem prompt optimizer]
SEM --> RISK[Risk-ranked pages<br/>for the supervisor]
EPI --> RISK
EPI --> REG[--regression<br/>missions from known bugs]
PRO --> NEXT[Prompt supplements<br/>for the next run]
- Semantic memory tracks every page visited, the success and failure count of every selector, and application quirks.
- Episodic memory stores a summary of each session and a bug catalog, deduplicated with a fingerprint of page plus summary, that counts how many sessions have seen each bug.
- Procedural memory runs after a batch of missions: LangMem's prompt optimizer reviews the session trajectories and writes prompt supplements for the agents and routing rules for the supervisor, which are injected on the next run.
The supervisor also receives a list of high-risk pages, scored with a simple formula: twice the number of times a bug was seen there, plus confirmed quirks, plus 1.5 times the selector failures. And --regression turns the bug catalog into missions, one per page with open or recurring bugs: "Verify whether these bugs still exist and look for related regressions."
Test what the pull request changed
Exploring a whole application on every PR is wasteful. With --pr-url, the framework fetches the PR (through the GitHub MCP server if configured, otherwise the gh CLI) and asks the LLM to act as a test architect and write 3 to 8 missions for the UI areas the diff is likely to affect.
agent-explorer --pr-url https://github.com/org/repo/pull/123 --execute --headed
Two details keep this from turning into a prompt-size problem or a hallucination problem:
- Diff budgeting. The prompt gets at most 40,000 characters of diff. For large PRs, each file gets its own slice with its headers and changed lines, so one huge generated file can't eat the whole budget. If the memory store has historical bugs for the app, they are added to the prompt.
-
Output validation. The generated YAML is rejected unless every mission has a
thread_idnamespaced to the PR (pr_123_...), targets an existing persona, and keeps its prompt under 1,200 characters.
Watching it work
Running with --visual launches a Streamlit dashboard that polls the agent state every second. It shows the live browser screenshot, the stream of agent thoughts, the bugs found so far and the swarm diagram above with the active node highlighted, which makes it easy to see where a mission is spending its time.
Every mission also leaves a report folder:
report_<thread_id>/
├── traces.log # every thought, plan and tool call
├── test_report.md # executive summary: objective, actions, bugs, PASS/FAIL
├── action_tape.jsonl # every browser command, in order
├── reproduction_*.spec.ts # one Playwright test per bug
└── screenshots/ # evidence for each bug
Bring your own app, model and knowledge
-
Any web app. A
config.yamlwith the app name, URL, description and auth settings, plusagent-authto save a logged-in session. -
Claude or Gemini. The provider is detected from the credentials available, or forced with
--provider. -
MCP servers listed in
mcp_servers.jsonbecome tools the agents can query for domain knowledge, such as API specs or documentation. -
Agent Skills under
AGENT_SKILLS_ROOTare exposed automatically, including running their scripts with a timeout.
The agents are told to use all of this with progressive disclosure: start with the mission and the current page, and only fetch extra context for the specific feature under test.
Lessons from building it
- Separate deciding from doing. The LLM chooses; deterministic code executes and records. Every trustworthy property of the system (reproducible specs, selector policy, audit trail) comes from that split.
- Make errors observations. Returning failures as text lets agents recover on their own, and keeps the failure on the tape for the reproduction.
- Bound everything. Snapshots, history, routing context, diffs, the tape kept in state. Long missions fail because context grows, not only because models make mistakes.
-
Specify the output of agents like an API. The
<bugs_found>contract and the PR mission validator turn free text into data the rest of the system can trust. - Test the framework itself. The repository has 115 unit tests covering the engine, bug extraction, PR analysis, config and the dashboard state.
Try it
git clone https://github.com/srbarrios/agentic-test-explorer.git
cd agentic-test-explorer
pip install -e .
playwright install chromium
cp config.yaml.example config.yaml # point it at your app
agent-auth # save an authenticated session
agent-explorer --missions missions/new_user_agent.yaml --headed
There is a demo video in the README, and the architecture guide walks through the LangGraph concepts behind every part of the code.
👉 Code (MIT): github.com/srbarrios/agentic-test-explorer
If you are an SDET or a QE engineer experimenting with agents: what would make you trust a bug report written by an AI? I'd love to hear it in the comments, and issues and pull requests are welcome.
Originally published at oscarbarrios.tech.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.