An agent platform lets users ask research questions that need live web pages: "find the pricing tiers on these twelve vendor sites," "check whether this docs page still mentions the deprecated flag." Each task spins up a full headless Chromium through Playwright. At low volume it feels fine. Then twenty tasks run at once, the host starts swapping, page loads that took two seconds take ten, and a few browser processes are killed by the operating system's out-of-memory handler mid-task. The agents report failures that look like site problems but are really resource exhaustion.
Looking at what those tasks actually do, most of them load a page, wait for JavaScript to populate the content and read text. They never take a screenshot, never need a pixel-accurate layout and never touch a canvas. They are paying for a complete rendering engine to produce output they throw away. This article explains where a browser's cost comes from, what a lightweight text-only engine like Lightpanda removes, what a full engine like Playwright gives you in return for the weight, and how to route work between them without making the system fragile.
1. What a Browser Is Actually Doing for Your Agent
A page load is several jobs bundled together. Seeing them separately makes the trade-off clear.
- Networking and parsing. Fetch the HTML and resources, build the DOM and the CSS object model.
- Script execution. Run JavaScript, which fetches data, mutates the DOM and fires events. This is what turns a single-page application's empty shell into content.
- Style, layout and paint. Compute which rules apply, where every box goes, and draw pixels, usually with GPU or software compositing.
- Input and automation surface. A protocol for a program to click, type, wait, read the DOM and intercept requests.
A person needs all four. An agent reading text typically needs the first, second and fourth, and sometimes not even all of the second. Steps three's output (layout and paint) is where a mainstream browser spends a lot of memory and processes, and it is where an agent that never looks at the screen gets the least value. A full browser also brings multi-process sandboxing, extensive compatibility behaviors, media stacks and a long tail of features that exist for human users.
That framing gives the central question for tool choice: which of the four jobs does this task actually need? If the answer is "everything, including exact rendering," use a full browser. If it is "run the page's scripts and read the resulting DOM," a text-only engine may do the job at a fraction of the footprint.
2. Playwright: What You Get for the Weight
Playwright is a browser automation library that drives real browser engines (Chromium, Firefox and WebKit) through a consistent API. Its value is fidelity and tooling.
Fidelity
Because it drives the same engines users run, pages behave as they do in real life: layout-dependent logic works, CSS-driven visibility is accurate, features like canvas, WebGL, media playback, service workers and modern web APIs are available to the extent the underlying engine supports them. Screenshots and PDFs are real, which matters for visual verification, evidence capture and anything where "what the user sees" is the question.
Waiting and robustness
Flaky automation mostly comes from acting before the page is ready. Playwright's locators auto-wait for elements to be attached, visible, stable and enabled before acting, and its assertions retry until a condition holds or a timeout expires. That removes a large class of sleep-based hacks.
Debugging and control
Isolated browser contexts give each task its own cookies and storage without launching a new browser. Request interception lets you block images, fonts and trackers, which is a cheap way to cut load time and bandwidth even in a full browser. Tracing records a timeline with snapshots and network activity that you can inspect after a failure, which is invaluable when a flow breaks in CI or in an unattended run.
The cost of all that is process weight: a browser process plus renderer processes, memory that grows with page complexity, and a startup that is noticeable when you launch per task. That cost is what drives people toward lighter options.
3. Lightpanda: A Browser Without the Rendering Pipeline
Lightpanda is a headless browser built from scratch for machine use rather than derived from a mainstream desktop engine. Its stated design goal is to execute JavaScript and expose the DOM while skipping graphical rendering entirely, which is why it is described as text-only. It speaks the Chrome DevTools Protocol, so existing automation clients such as Puppeteer and Playwright can connect to it instead of launching their own browser.
What is deliberately missing
- No rendering: no screenshots, no pixel layout, no visual regression.
- No guarantee of full web API coverage. A project of this kind implements the APIs real sites commonly need, but the long tail (some media, some newer or obscure APIs, complex layout-dependent scripts) may be absent or partial.
- Less mature tooling around it. Expect fewer debugging aids than a full browser's ecosystem offers.
What that buys you
Skipping the rendering pipeline and the desktop-oriented feature surface means a smaller process, lower memory per page and faster startup. Those are the properties the project advertises, and they follow logically from the design. How large the gains are on your pages is something to measure, not assume, because a page heavy on scripts and network spends its time there regardless of the engine.
4. Where the Cost Actually Goes: Memory, Startup and Concurrency
Cost shows up in three places, and each pushes differently on an agent fleet.
Memory per concurrent page
Fleet size is usually bounded by memory, not CPU. A full browser's per-page footprint includes the renderer's layout and paint structures, image decoding and compositor state. A text-only engine drops most of that. The practical effect is that a given machine can hold more simultaneous sessions, or the same sessions run on a smaller instance. The exact multiplier depends on the pages, so run both engines against a sample of your real URLs and record peak memory under your target concurrency.
Startup and reuse
Launching a browser per task adds latency to every task. Two mitigations apply to either engine: keep a long-lived browser and open a fresh isolated context per task, and warm a small pool ahead of demand. A lighter engine makes cold starts cheaper, but the pooling pattern is still the right default.
Time spent waiting
Much of a page load is network and script time that no browser can compress. If the target site takes three seconds to respond, a lighter engine will not make it respond faster. The saving is in what happens around it: less CPU spent on layout and paint, and less memory pressure that causes the slowdowns you see at high concurrency. That is why "the lightweight engine is faster" is true at scale and often unremarkable for one page in isolation.
| Property | Full browser via Playwright | Lightpanda (text-only engine) |
|---|---|---|
| Runs page JavaScript | Yes, complete engine | Yes, with coverage that may be partial |
| Screenshots and PDFs | Yes | No |
| Layout-dependent behavior | Accurate | Not available or approximate |
| Memory per concurrent session | Higher | Lower by design |
| Startup cost | Noticeable per launch | Lighter |
| Auto-waiting locators, tracing, test tooling | Rich and mature | Via the protocol, but depends on what the engine implements |
| Site compatibility | Broad, same engines as users | Good for common patterns, verify per site |
| Maturity | Established | Young and fast-moving |
Qualitative comparison. Memory, startup and throughput differences are workload dependent: measure them on your own pages and concurrency.
5. The Read Path and the Write Path: Route by What the Task Needs
The cleanest way to use both engines is to split tasks by the kind of work, not to pick one for everything.
- Read path: fetch content, extract text or structured data, check whether a string appears. No screenshots, no visual checks. Default to the lightweight engine, and for static pages consider a plain HTTP fetch with no browser at all.
- Interaction path: log in, fill multi-step forms, handle file uploads, use drag-and-drop. Layout and event fidelity matter. Default to the full browser.
- Evidence path: screenshots, PDFs, visual regression, reproducing a user-reported rendering bug. Full browser only.
The first rung is often forgotten. Before any browser, ask whether the data is in the initial HTML or available from a documented API. A plain HTTP request with a parser is faster and lighter than any browser, and a browser should be the fallback for pages that genuinely need script execution.
Escalate, do not guess
The robust pattern is escalation. Try the cheapest engine that might work, check that the result is plausible, and only on failure retry with the heavier one. Define "plausible" explicitly: the expected selector is present, the text is longer than a threshold, no "enable JavaScript" or bot-challenge marker appears. Without a plausibility check, the lightweight engine will return an empty page with a successful status, and the agent will happily reason over nothing.
6. A Worked Example: Escalating from Text-Only to Full Browser
The snippet below connects Playwright to a text-only engine over the DevTools protocol, validates what came back, and falls back to a launched Chromium if the cheap path fails. The endpoint is a placeholder. Check the engine's documentation for how to start its server and which address it exposes.
import { chromium, type Browser } from "playwright";
const LIGHT_ENDPOINT = process.env.LIGHT_CDP_URL ?? "ws://127.0.0.1:9222"; // text-only engine, started separately
type Extracted = { title: string; text: string; engine: "light" | "full" };
function looksValid(e: { title: string; text: string }): boolean {
if (e.text.length < 500) return false; // suspiciously empty
if (/enable javascript|verify you are human/i.test(e.text)) return false; // wall or challenge
return true;
}
async function extract(browser: Browser, url: string, engine: "light" | "full"): Promise<Extracted> {
const context = browser.contexts()[0] ?? (await browser.newContext());
const page = await context.newPage();
try {
await page.goto(url, { waitUntil: "domcontentloaded", timeout: 20_000 });
await page.waitForSelector("main, article, body", { timeout: 10_000 });
const title = await page.title();
const text = await page.evaluate(() => document.body.innerText);
return { title, text, engine };
} finally {
await page.close();
}
}
export async function readPage(url: string): Promise<Extracted> {
// Cheap path: connect to the lightweight engine over CDP
try {
const light = await chromium.connectOverCDP(LIGHT_ENDPOINT);
try {
const result = await extract(light, url, "light");
if (looksValid(result)) return result;
} finally {
await light.close();
}
} catch (err) {
console.warn("light path failed, escalating:", (err as Error).message);
}
// Escalation: full browser with heavy assets blocked
const full = await chromium.launch({ headless: true });
try {
const context = await full.newContext();
await context.route("**/*", (route) => {
const type = route.request().resourceType();
return ["image", "font", "media"].includes(type) ? route.abort() : route.continue();
});
const page = await context.newPage();
await page.goto(url, { waitUntil: "networkidle", timeout: 30_000 });
return { title: await page.title(), text: await page.evaluate(() => document.body.innerText), engine: "full" };
} finally {
await full.close();
}
}
Several details here carry weight. The plausibility check is what makes escalation meaningful. Every page is closed in a finally block, because leaked pages are the most common cause of the memory growth people blame on the engine. The full-browser fallback blocks images, fonts and media, since a read task does not need them, which recovers part of the cost the fallback would otherwise add. And the result records which engine produced it, so you can measure the escalation rate over time. If a large fraction of URLs escalate, either the lightweight engine does not suit those sites or the plausibility check is too strict, and the numbers tell you which to investigate.
7. Failure Modes and When Not to Use a Lightweight Engine
- Silent partial rendering. A script depends on an API the engine lacks, throws, and the page ends up half populated. The status is success. Fix with plausibility checks and by logging console errors from the page.
- Layout-dependent logic. Pages that lazy-load on scroll using intersection observers, or that hide content based on measured widths, may behave differently without real layout. If the content you need appears only after a visibility computation, test it explicitly.
- Bot detection. Sites fingerprint browsers. Any non-mainstream engine can look unusual, and a full browser is not a guarantee either. Respect each site's terms and robots rules, rate-limit politely, and do not build automation whose purpose is to evade access controls.
- Interactions that need real events. Drag-and-drop, hover menus driven by pointer geometry, and rich-text editors often rely on layout. Use the full browser.
- Resource leaks in both. Unclosed pages, contexts and listeners accumulate in either engine. Close in
finally, cap pages per browser, and recycle long-lived browsers periodically. - Version drift. A young engine changes behavior between releases. Pin the version in production and run a canary set of URLs after upgrading.
When not to use it
Avoid a text-only engine when the task needs screenshots or visual verification, when you are testing your own web app's rendering across browsers, when the flow involves complex interactions on rich client-side apps, or when you cannot afford to validate compatibility on the target sites. In those cases the memory saving is not worth the risk of subtle breakage.
8. Decision Checklist and Common Mistakes
Answer these in order for each class of task:
- Is the data in the initial HTML or a documented API? Use a plain HTTP client.
- Does the task need screenshots, PDFs or pixel-accurate layout? Use the full browser.
- Does it need complex interaction on a rich client-side app? Use the full browser.
- Does it only need rendered text or structured data after scripts run? Try the lightweight engine first, with a plausibility check and escalation.
- Do you need parallelism that exceeds what a full browser fleet can hold on your hardware? That is the case where the lightweight engine pays for its immaturity.
Common mistakes
- Choosing an engine from a benchmark that measured something else. Published numbers use someone else's pages, hardware and concurrency.
- Launching a fresh browser for every task instead of reusing one with isolated contexts.
- Using fixed sleeps instead of waiting for a condition. Wait on a selector or a state, not a timer.
- Treating a successful navigation as a successful extraction.
- Forgetting to block heavy resources when the task reads text only.
- Giving an agent unrestricted browsing. A browsing tool should have a URL allow-list or at least block private network ranges, to limit the damage when a page contains instructions aimed at the agent.
9. What to Do Monday: Short FAQ
We run everything on full Chromium today. What is the first step? Log which tasks take screenshots or interact with forms and which only read text. Then run a sample of the read-only URLs through both engines and compare extracted content, peak memory at your real concurrency and failure rate.
Do we need to rewrite our scripts? If they use Playwright, probably not for the read path: connect over the DevTools protocol instead of launching. Expect some calls to be unsupported by a text-only engine, so run your suite against it and note which ones.
How do we keep it safe? Run browsers in containers without access to internal networks or credentials, restrict navigation to approved domains where possible, and treat page text as untrusted input to the model.
What should we monitor? Escalation rate, extraction-validity rate, peak memory per host, timeouts and open page counts. A rising escalation rate is the earliest sign that a site or the engine changed.
Is lighter always better? No. A lighter engine is better when it covers what the task needs. When it does not, the failures cost more in debugging time than the memory you saved.