Raw CDP vs Playwright: What Browser Use Runs on Now
Every browser agent ends in the same place: messages sent to Chrome. The question is how many layers sit in between. browser-use 0.x went through Playwright for a long time. Then the team moved to raw Chrome DevTools Protocol (CDP), and 1.0 is built on it. This part shows what CDP looks like on the wire, measures the layers on this machine and explains the reasons the team gives.
Animation: a cdp('Runtime.evaluate') call travels from the model's Python cell through the REPL and the browser-harness daemon over one websocket to the page and back, next to Playwright's extra Node.js hop.
Problem: you cannot fix what you cannot see
A browser agent hits every sharp edge of a real browser: dialogs, downloads, crashed tabs, iframes, huge pages. When a library hides the protocol, each sharp edge becomes a bug in someone else's code. You wait for a fix, or you work around it.
The Browser Use post "Closer to the Metal" lists the edges that pushed them off Playwright. Among them: full-page screenshots over 16,000 pixels, dialogs, downloads and crashed tabs. The post says there are "at least 10 different ways a tab can crash". It also says Playwright adds a second hop through a Node.js relay, and that state drifts across three places: the browser, the relay and the client.
What CDP looks like on the wire
CDP is JSON over a websocket. You send {"id", "method", "params"}. You get back a reply with the same id, plus events that have no id. That is all.
This script starts headless Chromium with a debugging port, connects with the plain websockets library and drives a local test page. Nothing from browser-use is involved:
pythonimport asyncio, json, subprocess, tempfile, time, urllib.request, statistics, sys import websockets CHROME = '/home/hatch/.cache/ms-playwright/chromium-1248/chrome-linux64/chrome' N = 200 async def main(): prof = tempfile.mkdtemp() p = subprocess.Popen([CHROME, '--headless=new', '--remote-debugging-port=9333', f'--user-data-dir={prof}', '--no-first-run', '--no-sandbox', 'about:blank'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) op = urllib.request.build_opener(urllib.request.ProxyHandler({})) for _ in range(150): try: tabs = json.load(op.open('http://127.0.0.1:9333/json')); break except Exception: time.sleep(0.2) page = [t for t in tabs if t['type'] == 'page'][0] print('websocket:', page['webSocketDebuggerUrl'].split('/devtools')[0] + '/devtools/page/<id>') async with websockets.connect(page['webSocketDebuggerUrl'], max_size=None) as ws: mid = 0 async def send(method, **params): nonlocal mid; mid += 1; my = mid await ws.send(json.dumps({'id': my, 'method': method, 'params': params})) while True: m = json.loads(await ws.recv()) if m.get('id') == my: return m # everything without our id is an event, e.g. Page.loadEventFired print(json.dumps(await send('Page.enable'))) r = await send('Page.navigate', url='http://127.0.0.1:18765/') print('Page.navigate ->', json.dumps(r)[:160]) await asyncio.sleep(1) r = await send('Runtime.evaluate', expression='document.title', returnByValue=True) print('Runtime.evaluate ->', json.dumps(r)) ts = [] for _ in range(N): t = time.perf_counter(); await send('Runtime.evaluate', expression='1+1', returnByValue=True); ts.append((time.perf_counter() - t) * 1000) print(f'raw CDP Runtime.evaluate x{N}: median {statistics.median(ts):.3f} ms, p95 {sorted(ts)[int(N*.95)]:.3f} ms') json.dump({'raw_cdp_ms': ts}, open('exp06_raw.json', 'w')) # same browser, through Playwright's Node relay out = subprocess.run(['/home/hatch/workspace/blogllm-diagnosis/build-your-own-muse/.venv/bin/python', 'exp06_pw.py'], capture_output=True, text=True) print(out.stdout, out.stderr[-500:]) p.terminate() asyncio.run(main())
The Playwright side (exp06_pw.py, Playwright 1.65.2) attaches to the same Chrome:
pythonimport time, statistics, json from playwright.sync_api import sync_playwright N = 200 with sync_playwright() as pw: b = pw.chromium.connect_over_cdp('http://127.0.0.1:9333') page = b.contexts[0].pages[0] print('playwright sees title:', page.title()) ts = [] for _ in range(N): t = time.perf_counter(); page.evaluate('1+1'); ts.append((time.perf_counter() - t) * 1000) print(f'Playwright page.evaluate x{N}: median {statistics.median(ts):.3f} ms, p95 {sorted(ts)[int(N*.95)]:.3f} ms') json.dump({'playwright_ms': ts}, open('exp06_pw.json', 'w'))
Real output, first run:
textwebsocket: ws://127.0.0.1:9333/devtools/page/<id> {"id": 1, "result": {}} Page.navigate -> {"id": 2, "result": {"frameId": "3D1AB0D6B0A95ECBCBF12840F8212C1F", "loaderId": "8DC45C618612F4133DC8A13C30D82734", "isDownload": false}} Runtime.evaluate -> {"id": 3, "result": {"result": {"type": "string", "value": "Trap page"}}} raw CDP Runtime.evaluate x200: median 12.864 ms, p95 114.577 ms playwright sees title: Trap page Playwright page.evaluate x200: median 73.472 ms, p95 107.726 ms
Second run, same script:
textraw CDP Runtime.evaluate x200: median 5.585 ms, p95 81.813 ms Playwright page.evaluate x200: median 46.837 ms, p95 117.872 ms
And the same call through browser-use's own path, cdp() inside the agent REPL, which goes through the browser-harness daemon:
pythonnew_tab('http://127.0.0.1:18765/'); wait_for_load() import time, statistics, json ts = [] for _ in range(200): t = time.perf_counter(); cdp('Runtime.evaluate', expression='1+1', returnByValue=True); ts.append((time.perf_counter() - t) * 1000) json.dump(ts, open('/home/hatch/workspace/blogllm-diagnosis/browser-use-series/runs/exp07_helper.json', 'w')) print(f'browser-harness cdp() x200: median {statistics.median(ts):.3f} ms, p95 {sorted(ts)[190]:.3f} ms')
textbrowser-harness cdp() x200: median 26.895 ms, p95 112.144 ms
Median ms per Runtime.evaluate, 200 calls, one noisy VMData from the sources listed below.
How to read this honestly:
- This is a micro-benchmark on a shared VM with 1.5 CPUs. Runs moved by 2x between tries. The p95 values are all close to 80 to 120 ms, which is mostly machine noise.
- The order held in both runs: raw CDP fastest, Playwright slowest. That fits the extra hop through the Node.js driver.
- browser-harness sits in between. Each
cdp()call crosses from the REPL process to the daemon over a Unix socket before it reaches the websocket. - A few tens of milliseconds per call do not matter when a model request takes seconds. They matter when a cell makes hundreds of CDP calls, like reading every row of a table.

Solution: one websocket, held by a small daemon
Here is how 1.0 reaches Chrome, read from the installed source:
browser_harness/daemon.pydescribes itself as a "CDP WS holder + IPC relay (Unix socket on POSIX)". There is one daemon perBU_NAME. It usescdp_use.client.CDPClient, the team's own typed CDP client.browser_harness/helpers.py(668 lines) holds the functions the model calls:js,cdp,click_at_xy,type_textand the rest. Each is a thin wrapper over CDP calls.repl/worker.pyis the persistent Python child process that runs the model's cells.
The split keeps the browser connection outside the process that runs model-written code. The REPL only ever talks to the daemon, and the daemon owns the one websocket.
sequenceDiagram participant M as Model cell participant W as REPL worker participant D as harness daemon participant C as Chrome page M->>W: cdp('Runtime.evaluate', expression='document.title') W->>D: IPC over Unix socket D->>C: {"id":3,"method":"Runtime.evaluate",...} C-->>D: {"id":3,"result":{"result":{"type":"string","value":"Trap page"}}} D-->>W: result dict W-->>M: 'Trap page'
The team's "Bitter Lesson of Agent Harnesses" post describes how small the first browser-harness was: four files, run.py at 13 lines, helpers.py at 192, daemon.py at 220, plus a SKILL.md, about 600 lines in all. The installed 1.0.9 copy has grown (helpers.py 668 lines, daemon.py 894), but the shape is the same.
sequenceDiagram participant P as Python cell participant H as cdp() helper participant D as Daemon participant C as Chrome P->>H: cdp('Runtime.evaluate', expression='document.title') H->>D: JSON over a Unix socket D->>C: CDP message on the held websocket, with session id C-->>D: result D-->>H: result H-->>P: dict
Problem: raw CDP has its own sharp edges
Dropping Playwright does not make the hard parts go away. You now own them. Two examples from the team's posts:
- Payload size. The harness post says the CDP websocket payload cap is about 10 MB, which broke big file uploads. The fix was a chunked upload.
- Self-healing helpers. The same post says the agent wrote its own
upload_filehelper withDOM.setFileInputFileswhen one was missing. That is the upside of giving the model raw CDP: it can fill gaps in the harness.
Playwright still has strengths: auto-waiting locators, a test runner, cross-browser support (Firefox and WebKit, where CDP does not apply). For tests a human writes, it is a fine choice. The argument in "Closer to the Metal" is narrower: for an agent that needs full control of one Chromium, the extra layer costs more than it gives.
The 1.0 numbers the team reports
The 1.0.0 release notes report that the rewrite deleted 136,866 lines. The launch post reports 136,905 lines removed and 29,601 added across 554 files, from 178 Python files down to 43. (The two counts differ slightly; both are the team's.) In the release notes, LangChain model objects now raise a TypeError: the agent runs on Pydantic AI.
Try this
Start Chrome with --remote-debugging-port=9222, open http://127.0.0.1:9222/json and copy a page's webSocketDebuggerUrl. Send {"id":1,"method":"Runtime.evaluate","params":{"expression":"document.title"}} with any websocket client. You just did what every browser agent does underneath.
Sources
- Closer to the Metal, Playwright to CDP: https://browser-use.com/posts/playwright-to-cdp
- The Bitter Lesson of Agent Harnesses: https://browser-use.com/posts/bitter-lesson-agent-harnesses
- browser-harness repository: https://github.com/browser-use/browser-harness
- browser-use 1.0.0 release notes: https://github.com/browser-use/browser-use/releases/tag/1.0.0
- Browser Use 1.0 launch post: https://browser-use.com/posts/browser-use-1-0
- Chrome DevTools Protocol reference: https://chromedevtools.github.io/devtools-protocol/
- Playwright
connect_over_cdp: https://playwright.dev/python/docs/api/class-browsertype#browser-type-connect-over-cdp
