Skip to main content

Local-first observability for browser agents. Datadog for browser agents.

Project description

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 linkswitness 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

usewitness-0.1.0.tar.gz (2.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

usewitness-0.1.0-py3-none-any.whl (155.6 kB view details)

Uploaded Python 3

File details

Details for the file usewitness-0.1.0.tar.gz.

File metadata

  • Download URL: usewitness-0.1.0.tar.gz
  • Upload date:
  • Size: 2.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for usewitness-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5d39ccfa7019a5998b09b3d9d776134a40162a972c40f955d5afaaa3cccca156
MD5 810707ea8667256805ba0381c3ddb756
BLAKE2b-256 d6aafe68b7257bbe00f9e7f4c6248c490e2b751139294d0fca92cc5f78a69391

See more details on using hashes here.

File details

Details for the file usewitness-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: usewitness-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 155.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for usewitness-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b9d08eaf6891d74d5ab0e50c57f02f4c5819ff136420488f1c7e76d34520a716
MD5 46946fa572a0591132c2a879a0d130f3
BLAKE2b-256 0d9b5fb4b432a8b6d4d7e3658084a519dba763f5d9a46bce4af8772cfd1f5bf8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page