Project Info
Inspiration
I love making my agents do things on the web -- what limits me, however, is just how expensive it is! Browser agents waste context by repeatedly sending full screenshots and page state, even when only one textbox or button changed. BrowserDelta asks whether an agent can keep the next-action signal while seeing only the browser state delta.
What it does
BrowserDelta is an intermediate layer between BrowserBase / Playwright and your agent. It is built with a FastAPI backend and can fit any browser use tool with a run-folder contract. Playwright / Browserbase records screenshots and page state, the codec writes a compaction version of the observations, and the replay eval compares the compact context vs full-state baselines. BrowserDelta behind the scenes uses a few techniques to compact images. DOM diffs noise-filtered pixel diffs region segmentation SSIM / phash metrics OCR Results On the core visual benchmark suite, BrowserDelta matched the vision-full-state baseline on 12/12 next-action predictions while cutting estimated context by about 76%. On imported MiniWoB++ demos, the compact representation reached about 96% token reduction with only a small parity gap against a full-state baseline.
BrowserDelta
BrowserDelta is a semantic compaction layer for Browserbase-style browser agents. Instead of sending an LLM a full screenshot after every browser action, it records the browser state before and after each step, diffs the states, and emits a small observation that says only what changed.
Browserbase session
-> browser action
-> raw before/after state
-> BrowserDelta codec
-> compact observation for the LLM
-> replay eval for next-action parity
What We Are Building
The MVP has three independent workstreams:
- Browserbase recorder: runs browser actions and saves raw step evidence.
- Compaction codec: converts raw step evidence into compact LLM observations.
- Replay evaluator: checks whether compact observations preserve the next action.
The contract between the two teams is the run folder:
runs/<run_id>/
run.json
steps.jsonl
steps/
step_001_before.json
step_001_after.json
step_001_before.png
step_001_after.png
Each steps.jsonl row points to the raw before/after files. The compaction team
can work from those files without needing Browserbase credentials. Pointer paths
and generated crop paths are run-relative, so a copied run folder should still
compact correctly.
Tech Stack
- Backend: Python, FastAPI
- Browser runtime: Browserbase, with local Playwright fallback
- Browser control: Playwright Python
- Screenshot diff: Pillow, NumPy, optional OpenCV
- Visual delta: connected components, DOM-box alignment, SSIM, perceptual hash, optional OCR
- Data format: JSON / JSONL run logs
- Viewer: Vite, React, TypeScript
Quick Start
python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
python -m playwright install chromium
cp .env.example .env
Run the API:
uvicorn browserdelta.main:app --reload --app-dir backend
Record a local demo run:
python scripts/record_demo.py --url https://example.com --run-id smoke
Run the deterministic local BrowserDelta proof:
python scripts/record_demo.py --task tasks/local_checkout.json --run-id local_checkout --headless --compact --runtime local
This opens demo_pages/local_checkout.html, records four real browser actions,
and immediately compacts the run. Expected behavior:
- step 1: validation error ->
text_only - step 2: typed field value ->
text_only - step 3: canvas-only chart update ->
crop_with_context - step 4: checkout modal opens ->
text_only
Compact a run:
python scripts/compact_run.py runs/smoke
Evaluate whether compact observations preserve the next action:
python scripts/eval_run.py runs/local_checkout
The replay evaluator writes eval_report.json and reports next-action parity
for every transition that has a following recorded action.
Run the same replay eval with a real LLM predictor:
python scripts/eval_run.py runs/local_checkout --predictor llm
This uses OPENAI_API_KEY and OPENAI_MODEL from .env. The default
heuristic predictor is still useful for free, deterministic smoke tests; the
llm predictor is the demo proof that a model can choose the same next actions
from compact context only.
Compare compact context against a real vision full-state baseline:
python scripts/eval_run.py runs/local_checkout --predictor llm --compare
This writes:
eval_report.json: compact-only replay report.eval_vision_full_state_report.json: baseline replay report that sends the full captured page state plus the after-action screenshot as aninput_image.eval_comparison.json: machine-readable compact-vs-baseline comparison.eval_summary.md: human-readable result for demos.
The comparison answers the core question directly: did compact context preserve the next browser action, and how many estimated tokens did it save versus sending the full captured state plus screenshot evidence?
For a cheaper text-only baseline that does not attach screenshot bytes, run:
python scripts/eval_run.py runs/local_checkout --predictor llm --compare --baseline-context full_state
Batch replay eval over multiple runs:
python scripts/eval_suite.py runs/local_checkout runs/browserbase_checkout
python scripts/eval_suite.py --json tasks/local_checkout.json
python scripts/eval_suite.py --predictor llm --compare runs/local_checkout runs/browserbase_checkout
python scripts/eval_suite.py --predictor llm --compare --baseline-context full_state runs/local_checkout runs/browserbase_checkout
Task JSON resolves its id to runs/<id>; suite JSON can also pass a runs
list of run folders.
Run the checked-in smoke fixture:
python scripts/compact_run.py examples/runs/login_error
That fixture should produce a text-only compact observation for an Email is required validation error. Use it first when checking whether recorder output
still matches the compaction contract.
The CLI prints demo-facing metrics per step:
step 1: text_only, 91.34% saved, confidence 0.95 - New text appeared: Email is required
total: 1 step(s), 60 compact tokens vs 693 baseline, 91.34% saved
Additional fixtures cover the two main router behaviors:
python scripts/compact_run.py examples/runs/modal_checkout
python scripts/compact_run.py examples/runs/visual_only_change
modal_checkout: checkout dialog and form fields appear, expectedroute=text_only.visual_only_change: canvas-like chart changes without useful DOM evidence, expectedroute=crop_with_contextwith crops undercrops/step_001/.
Visual benchmark tasks stress CV-heavy browser changes:
python scripts/record_demo.py --task tasks/visual_canvas_chart.json --run-id visual_canvas_chart --headless --compact --runtime local
python scripts/record_demo.py --task tasks/visual_progress_toast.json --run-id visual_progress_toast --headless --compact --runtime local
python scripts/record_demo.py --task tasks/visual_swatch_picker.json --run-id visual_swatch_picker --headless --compact --runtime local
python scripts/record_demo.py --task tasks/search_filter.json --run-id search_filter --headless --compact --runtime local
visual_canvas_chart: repeated canvas redraws with no useful DOM text delta.visual_progress_toast: progress bar visual movement plus a completion toast.visual_swatch_picker: radio state plus selected swatch styling.search_filter: table filtering plus add-to-cart and reset state changes.
External Evals
BrowserDelta can import BrowserGym/MiniWoB episodes into the same run-folder contract, then score them with the existing replay evaluator:
PYTHONPATH=$PWD/backend python scripts/record_browsergym.py \
--env browsergym/miniwob.click-button \
--run-id bg_click_button \
--action "click('a12')" \
--headless \
--compact
python scripts/eval_run.py runs/bg_click_button --compare --baseline-context vision_full_state
Important: BrowserGym is intentionally not a default dependency because current
browsergym-core pins an older Playwright than the main recorder uses. Install
and run it in an isolated Python environment, then point PYTHONPATH at this
repo's backend/ package. Also set MINIWOB_URL as required by MiniWoB++.
For multi-episode scripted suites, use:
python scripts/eval_external_suite.py docs/browsergym-miniwob-smoke.example.json --compare
See docs/external-evals.md for the benchmark strategy and caveats.
Run tests:
pytest
Run the shared recorder/codec contract test after changing schemas, recorder output, or compaction path handling:
pytest tests/test_run_contract.py
Browserbase Setup
For local development, BrowserDelta falls back to a local Playwright Chromium browser when no Browserbase connection URL is configured.
To use Browserbase with the normal token flow, set:
BROWSERBASE_API_KEY="..."
BROWSERBASE_PROJECT_ID is optional; Browserbase can infer the project from the
API key. If the event gives you a raw CDP URL instead, set:
BROWSERBASE_CONNECT_URL="wss://..."
Then run the same proof command:
python scripts/record_demo.py --task tasks/local_checkout.json --run-id browserbase_checkout --headless --compact --runtime browserbase
For model-backed replay eval, set:
OPENAI_API_KEY="..."
OPENAI_MODEL="gpt-4.1-mini"
Then run:
python scripts/eval_run.py runs/browserbase_checkout --predictor llm
Project Shape
backend/browserdelta/
api/ FastAPI routes
browserbase/ browser connection, action execution, state capture
compaction/ screenshot + structural diffs and compact observations
eval/ replay evaluation for next-action parity
schemas.py shared Pydantic models
storage.py run folder IO
scripts/
record_demo.py record a raw browser run
compact_run.py compact a saved raw run
eval_run.py score compact observations against recorded next actions
eval_suite.py batch replay eval across run folders or task files
tasks/
local_checkout.json deterministic local proof task
visual_*.json visual benchmark tasks for CV-heavy state changes
demo_pages/
local_checkout.html deterministic browser page for recorder/codec proof
visual_*.html self-contained visual benchmark pages
viewer/
Vite/React shell for viewing runs
docs/
architecture.md
team-todos.md
schemas.md
examples/runs/login_error/
Checked-in raw run fixture for the codec smoke test
examples/runs/modal_checkout/
Checked-in fixture for modal/form semantic routing
examples/runs/visual_only_change/
Checked-in fixture for crop fallback routing
Core Claim
BrowserDelta is not just screenshot compression. It compresses browser state transitions: the action, visual diff, DOM/accessibility changes, errors, and fallback evidence needed for the next agent step.
The visual layer is intentionally hybrid: deterministic DOM/accessibility diffs first, then CV-derived visual regions when page state changes through canvas, images, progress bars, or styling that the DOM alone does not explain.
Analysis
View
Metric
- 16
- 1
Figures cover GitHub contributors during the hackathon window. A co-authored commit counts in full for each author, so per-member totals add up to more than the whole-team figures.
Technology
- CSSIn code
- FastAPIIn code
- HTMLIn code
- PythonIn code
- ReactIn code
- TypeScriptIn code
6 of 6 appear in the indexed code.
AI coding agents
- CodexConfig
Detected from committed agent config files and commit authorship. Absence of a signal is not proof an agent was unused.
Codebase size
Source size
346 KB
Source files
68
Counts recognized source files only; vendored directories, binaries and lockfiles are excluded, so this is smaller than the repository on disk.
Repository
jaykbpark/browser-use-compaction-co
105 files · 584 KB · @ e15038f
Structure
Interface
6 files · 6%Screens, components and styles rendered to the user.
API & routing
2 files · 2%Request entry points: routes, handlers and controllers.
Application logic
38 files · 36%Domain rules, services and shared utilities.
Background jobs
7 files · 7%Work run outside a request: tasks, workers and schedules.
Supporting
Layers are inferred from where files sit in the tree, not from reading the code. A project that names its directories unconventionally will read oddly here — open the file browser to check anything the diagram implies.
Languages
- Python71%
- Markdown12%
- TypeScript7%
- HTML7%
- CSS3%
Share of indexed source by file size. Binary and vendored files are excluded.
Dependencies
pyproject.toml
pypi · 12- browserbase
- fastapi
- numpy
- opencv-python
- pillow
- playwright
- pydantic
- python-dotenv
- uvicorn[standard]
- +3 more
viewer/package.json
npm · 6- @vitejs/plugin-react
- lucide-react
- react
- react-dom
- typescript
- vite
Declared in the repository’s manifests at the indexed commit. A declared package is not proof it is used, and runtime dependencies are listed first.
Feature verification
Browserbase recorder with local Playwright fallbackVerified
Browserbase recorder runs browser actions and saves raw step evidence, with local Playwright fallback when no Browserbase connection is configured
Claimed on readmehigh confidencebackend/browserdelta/browserbase/session.py:14— open_page() connects to Browserbase via CDP when credentials exist, otherwise launches a local Chromium browserbackend/browserdelta/browserbase/session.py:64— _create_browserbase_session() builds a real Browserbase client session
BrowserGym / MiniWoB++ import into run-folder contractVerified
BrowserDelta can import BrowserGym/MiniWoB episodes into the same run-folder contract and score them with the replay evaluator
Claimed on readmehigh confidencebackend/browserdelta/external/browsergym_adapter.py:1— 370-line adapter module converts BrowserGym/MiniWoB episodes into BrowserDelta run foldersscripts/record_browsergym.py— CLI script drives the BrowserGym import path referenced in the README
Compaction codec producing compact LLM observationsVerified
Compaction codec converts raw step evidence into compact LLM observations
Claimed on readmehigh confidencebackend/browserdelta/compaction/codec.py:44— compact_run pipeline builds VisualDiff/StructuralChange into CompactObservation objects
DOM / structural diffsVerified
Techniques include DOM diffs
Claimed on Devposthigh confidencebackend/browserdelta/compaction/structural_diff.py:33— diff_page_state compares before/after PageState, elements, focus, text, and errors
FastAPI backend intermediate layer for run/compaction/evalVerified
BrowserDelta is built with a FastAPI backend, an intermediate layer between Browserbase/Playwright and your agent
Claimed on readmehigh confidencebackend/browserdelta/main.py:6— FastAPI app is created and includes the runs router under /apibackend/browserdelta/api/routes_runs.py:20— Routes expose run listing, run detail, compaction and eval, calling into compaction/eval modules
LLM-backed predictor (gpt-4.1-mini via OpenAI Responses API)Verified
Built with gpt-4.1-mini and openai-responses-api; eval_run.py --predictor llm uses OPENAI_API_KEY/OPENAI_MODEL
Claimed on Devpostmedium confidencebackend/browserdelta/eval/llm_agent.py:1— LLM agent module implements the predictor used by evaluate_run/evaluate_comparison for context_mode-aware prediction
Noise-filtered pixel diffsVerified
Techniques include noise-filtered pixel diffs
Claimed on Devposthigh confidencebackend/browserdelta/compaction/image_diff.py:20— diff_images applies a threshold to the pixel difference mask to filter noise before building regions
OCR on visual regionsVerified
Techniques include OCR
Claimed on Devposthigh confidencebackend/browserdelta/compaction/image_diff.py:130— annotate_regions_with_ocr uses pytesseract.image_to_string on changed crops (best-effort, optional dependency)
React/TypeScript/Vite run viewerVerified
Viewer: Vite/React/TypeScript shell for viewing runs
Claimed on readmehigh confidenceviewer/src/main.tsx:1— React app with typed models for runs/steps renders via createRootviewer/package.json:2— Vite + React + TypeScript dependencies confirm the declared stack
Region segmentationVerified
Techniques include region segmentation
Claimed on Devposthigh confidencebackend/browserdelta/compaction/image_diff.py:49— _regions_from_mask() and align_regions_to_elements() segment the diff mask into regions and align to DOM elements
Replay evaluator for next-action parity, compact vs full-state baselinesVerified
The replay eval compares the compact context vs full-state baselines and reports next-action parity
Claimed on readmehigh confidencebackend/browserdelta/eval/runner.py:34— evaluate_run predicts next action from observations and checks actions_match against the recorded next actionbackend/browserdelta/eval/runner.py:111— evaluate_comparison runs compact vs full_state/vision_full_state and computes accuracy_delta and token_reduction_pct
Run-folder contract (run.json, steps.jsonl, before/after screenshots+state)Verified
The contract between recorder and compaction team is a run folder with run.json, steps.jsonl, and step before/after json/png files
Claimed on readmehigh confidencebackend/browserdelta/storage.py:70— write_json writes run.json manifest; steps.jsonl path is read/written for step pointersexamples/runs/login_error— Checked-in fixture run folder demonstrates the contract on disk
SSIM / perceptual hash (phash) metricsVerified
Techniques include SSIM / phash metrics
Claimed on Devposthigh confidencebackend/browserdelta/compaction/image_diff.py:348— _ssim_score computes structural similarity; _phash_distance/_phash compute a perceptual hash distance
12/12 next-action predictions matched on core visual benchmark suite, ~76-78% context reductionCode-supported
BrowserDelta matched the vision-full-state baseline on 12/12 next-action predictions while cutting estimated context by about 76-78%
Claimed on Devpostlow confidencebackend/browserdelta/eval/runner.py:271— The comparison pipeline that would produce an accuracy/token-savings summary like this exists and is runnabletasks/visual_canvas_chart.json— Visual benchmark task suite referenced by the claim exists as task definitions, but no committed eval_comparison.json/eval_summary.md output substantiates the specific 12/12 or 76-78% figures
MiniWoB++ imported demos: ~96% token reduction with small parity gapCode-supported
On imported MiniWoB++ demos, the compact representation reached about 96% token reduction with only a small parity gap against a full-state baseline
Claimed on Devpostlow confidencereports/demo/miniwob-5seed-summary/summary.md:12— The only checked-in MiniWoB benchmark result shows 84.17% mean token reduction (not ~96%) and a 2.56-point success-rate gap (40.96% vs 43.52%) favoring full_state, so the specific claimed figures are not corroborated by committed benchmark data even though the pipeline itself is real
An AI agent derived these features from the project’s Devpost page and readme, then searched the code for each one. Verified features are backed by cited code; claimed-only features had no supporting code, which is not by itself proof a feature is missing.
Export this project's context (description, README, evidence, key source files) to chat with an AI agent elsewhere.