Skip to main content

Witness

PyPI version Python versions License: MIT Twitter Follow

See what your browser agent actually did.

Local-first observability for browser agents. DOM diffs, screenshot scrubbing, LLM cost per step, action replay — all in a viewer that lives on your machine.

demo


Install

pip install usewitness
playwright install chromium
import asyncio
import witness
from browser_use import Agent
from browser_use.llm import ChatAnthropic

async def main():
    agent = Agent(
        task="Find the top story on Hacker News and return its title.",
        llm=ChatAnthropic(model="claude-sonnet-4-5"),
    )
    witness.instrument(agent)
    await agent.run()

asyncio.run(main())
witness view

Opens a viewer at localhost:7842 with every step your agent took.


Why this exists

Browser agents fail. A lot. Browser Use, Claude in Chrome, Operator, Skyvern — they all crash on step 7 of a 12-step workflow and leave you squinting at a stack trace that tells you nothing about why.

You need the DOM at the moment it broke. The screenshot before and after the click that went wrong. The exact prompt Claude saw when it picked the wrong button. The token cost of the retry loop that spiraled.

Witness captures all of it, automatically, with one line of code.


What it captures

For every step an agent takes:

  • DOM before and after — rendered as a side-by-side diff with line-level highlighting
  • Screenshots before and after — with a compare slider so you can see what changed visually
  • The action — structured JSON showing exactly what the agent tried to do
  • LLM calls — model, tokens, cost, latency, full prompt and response
  • Errors — captured with the step they occurred on, not buried in a trace

Everything is stored locally in SQLite + flat files under ~/.witness/. Nothing leaves your machine.


Screenshots

trace list Every run, with cost and step count at a glance.

DOM diff Real side-by-side DOM diff — see exactly what the page did.

LLM call detail Full prompt and response for every LLM call. With cost.


How it works

Witness wraps your agent's step() method with a thin instrumentation layer. Before each step it snapshots the page (DOM + screenshot); after each step it records the action taken, the latency, and any error. LLM calls are captured via OpenLLMetry's OpenTelemetry instrumentation of the Anthropic and OpenAI SDKs — Witness attaches them to the correct step using a ContextVar.

Storage is SQLite (metadata) plus flat files (DOMs and screenshots) under ~/.witness/. The viewer is a static Vite bundle served by a local FastAPI server. No cloud, no auth, no phone-home.

Claude Sonnet 4.5 and Opus 4.5 pricing are built in, as well as OpenAI GPT-4o, GPT-4.1, and the other common models. Unknown models log at $0 and raise a warning so you notice.


Examples

Four recipes in examples/ to copy from:


CLI

witness view              # open the viewer at localhost:7842
witness ls                # list recent traces in the terminal
witness rm <trace_id>     # delete a single trace
witness rm --all          # delete every trace (asks first)
witness config            # show config path and current settings

Telemetry is off by default and there is no toggle to turn it on. Witness never makes a network request you didn't ask for.


Roadmap

Short list of what's coming, roughly in order:

  • Share links — witness share <trace_id> uploads a trace to a hosted viewer so you can paste it into a bug report or a Slack thread
  • More frameworks — Playwright-based agents first, then Claude in Chrome event streams
  • Regression detection — run the same task against two model versions, diff the traces, alert on drift
  • Cost dashboards — aggregate spend across traces and tasks

Full backlog: BACKLOG.md


Contributing

The SDK and viewer are both small enough to read in an afternoon. Good first issues are labeled good first issue — currently around action-type icons, additional model pricing entries, and Playwright-agent instrumentation.

See CONTRIBUTING.md for dev setup.


License

MIT. See LICENSE.

Built by Eric Catalano.

Metadata

Release files for usewitness 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for usewitness 0.1.1
File Size Uploaded
usewitness-0.1.1.tar.gz 2.7 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for usewitness 0.1.1
File Interpreter ABI Platform
usewitness-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 2.9 MB

Release files / usewitness-0.1.1.tar.gz

Download URL usewitness-0.1.1.tar.gz
Size 2.7 MB
Tags Source
SHA-256 checksum
How to use checksums
c45b30538f075a0ea8b01f547d0809fe19b257010827032851757d252cfa3e97
BLAKE2b-256 checksum
How to use checksums
89e2c2c0c2818a881b03549facecd8dbc8665145149fbd3bcd38dd5bad67cc1c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release files / usewitness-0.1.1-py3-none-any.whl

Download URL usewitness-0.1.1-py3-none-any.whl
Size 156.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
05c26e161b878181c846ce01d24b12b57350c536e5e68c35bb26c753b8d86207
BLAKE2b-256 checksum
How to use checksums
4d1aa67fedd2fe9041f7d571f9c03b68c06aea18eff1d3c5e5afb15a8273a7d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page