Utility · for debugging with an agent

Agent Log

Record what a web page does in your browser, then hand the log to Claude or another agent so it can see what went wrong.

Stays in your browser until you share it

  1. Turn it onwith the bookmarklet, on any page
  2. Use the page until the bug showsconsole, errors, requests and the elements you pick are recorded
  3. Hand the log to your agentDownload or Copy from the red Logging badge

Get it

Three ways in; the bookmarklet works on most pages.

Agent Log Drag it to your bookmarks bar. On the page you want to debug, click it: a red Logging badge appears. Click it again to open the panel.

Does nothing on a page with a strict Content Security Policy (GitHub, many banks and web mail). Use the Console tab there.

Try it on this page

Use the controls; the records appear on the right.

Logging is off

Make some records

Watch elements

Or open the panel, press Watch an element and click anything on this page.

Live log, this page load

Logging is off. Press Start logging here, or any button on the left.

Give your agent the skill

So it knows how to ask for a log and how to read one.

The capturing-browser-logs skill tells an agent how to have you turn logging on, which elements to watch, how to add structured console.log calls, and how to read the export. Add it to Claude as a skill or paste it into a project's instructions.

The log stays in your browser until you share it.

Agent Log makes no network requests of its own: no server, no analytics, no upload. Download and Copy hand the log to you, and nothing else. Once you paste or attach it in a chat with Claude or another agent, it goes to that agent's provider like anything else you send there, so read it first and cut what you would not send. Logger beware.

Reference

What is recorded, the file format, and the limits.

Recorded events

Each record is an OpenTelemetry log record. Its eventName says where it came from:

eventNameRecorded whenSeverity
console.log, .info, .debug, .warn, .error, .trace, .assertthe page calls the console method (assert only when it fails)DEBUG to ERROR, by method
error.uncaughtan exception reaches windowERROR
error.rejectiona promise rejects with no handlerERROR
error.resourcean image, script or stylesheet fails to loadERROR
csp.violationthe page's CSP blocks somethingWARN
http.fetch, http.xhra request finishes or fails: method, URL, status, durationINFO; WARN at 400 and up; ERROR when it fails
page.navigation, page.visibilityin-page navigation; the tab is hidden or shownINFO
dom.click, .dblclick, .input, .change, .submit, .focus, .blur, .keydownan event on a watched elementINFO
dom.mutationa watched element's attributes, text or children change (at most 20 records a second per watch)INFO
dom.watcha watch is added or removed, or the number of elements it matches changesINFO; WARN at zero
agentlog.start, agentlog.stoplogging starts or stopsINFO

Objects passed to the console become attributes, so a structured call is the cheapest way to get state into the log:

console.log("bot tick", { tic, pos: { x, y }, sector, target: t.kind, action });

That record has the body bot tick and the attributes tic, pos, sector, target and action. Strings and numbers in the call form the body; errors become exception.type, exception.message and exception.stacktrace; arrays, maps and DOM nodes become arg0, arg1 and so on. Values are copied when they are logged, nested four levels deep at most, with long strings and long arrays cut short.

Watching elements

Watched elements record clicks, double clicks, typing (one record per pause, with the value), changes, form submits, focus, keys other than text typed into a field, and changes to the element's own content and attributes. In the panel, Watch an element starts a picker: hover highlights, click or Enter picks, ↑ and ↓ move to the parent or first child, Esc cancels. The click that picks never reaches the page. Each watch shows in the panel with the number of elements it matches; × removes it.

A watch is a CSS selector, built from an id or test attribute where the element has one. Agent Log keeps the watches for each site until they are removed, so they survive reloads and apps that redraw the element. An agent can name the elements itself: ?logging=true&watch=%23checkout (repeat watch= for more) on a page that includes the script, or AgentLog.watch("#checkout", { label: "checkout button" }) in the console on any page.

Values of password, email and phone fields, and of fields whose name, id, autocomplete hint, label or placeholder points to a credential or personal data (card numbers, one-time codes, addresses, birth dates, names), are recorded as [hidden] with their length.

The export format

Download and Copy produce an OTLP/JSON ExportLogsServiceRequest, the format an OpenTelemetry collector accepts at /v1/logs. Every page load is one resourceLogs entry; its resource attributes hold the page URL, title, user agent, viewport and a session.id:

{"resourceLogs": [{
  "resource": {"attributes": [{"key": "service.name", "value": {"stringValue": "austegard.com"}}, …]},
  "scopeLogs": [{"scope": {"name": "agent-log", "version": "1.0.0"}, "logRecords": [
    {"timeUnixNano": "1763164800123456000", "severityNumber": 9, "severityText": "INFO",
     "eventName": "console.log", "body": {"stringValue": "bot tick"},
     "attributes": [{"key": "tic", "value": {"intValue": "412"}}, …]}
  ]}]
}]}

Integers are strings and timestamps are nanoseconds, as the OTLP/JSON encoding requires. The skill has a short Python reader that flattens the file into one line per record and filters it.

Loading the script, and strict pages

The bookmarklet and the console snippet add agent-log.js from austegard.com to the page. A page with a strict Content Security Policy blocks that; the bookmarklet then shows an alert, and the console shows a CSP error. Code typed into the console is not subject to the page's CSP, which is why pasting the whole script works there.

The script is also served from GitHub through jsDelivr at https://cdn.jsdelivr.net/gh/oaustegard/oaustegard.github.io@main/web-utilities/agent-log.js, which caches branch files and can lag the site. A <script> tag cannot load it from raw.githubusercontent.com, because GitHub serves raw files as text/plain with nosniff.

Limits and privacy
  • Recording, storing and exporting all happen in this browser. The log leaves it only when you send the downloaded or copied file somewhere, and sending it to an agent means sending it to that agent's provider.
  • The log is stored per site: a log recorded on example.com can only be viewed and exported from a page on example.com. Clear deletes it.
  • It keeps the newest 20,000 records and drops the oldest. AgentLog.start({ max: 50000 }) raises the cap.
  • Console output and errors are recorded from the moment it starts. Started from the bookmarklet, it misses whatever the page logged while loading; reload a page that includes the script with ?logging=true to catch that. Requests are the exception: the browser keeps a list of the page's recent requests, so those made before the bookmarklet was clicked are recorded too, marked agentlog.before_start.
  • Some apps keep their own reference to fetch or console.log from when they started (Bluesky's API client does). Started late, Agent Log still records their requests from the browser's request list, with URL, duration and usually the status but not the method (agentlog.source is resource-timing), and it does not see console calls made through such a reference.
  • Recorded URLs have credentials replaced with REDACTED: query parameters named key, code, auth, sig, state or nonce, names containing token, secret, password, api_key, session or signature (so auth_token and x-api-key too), and names ending in _key or _code. The same rule applies to key=value pairs in the #fragment, where OAuth's implicit flow and share links put tokens, and a fragment that is one long token is replaced whole; hash routes such as #/settings stay readable. Request and response bodies and headers are not recorded.
  • Console arguments, the text of watched elements and the values of ordinary fields are recorded as given, so read the export before you share it if the page shows or logs anything private.
  • It covers the page itself: not its iframes, workers or service workers.
Console API and source

AgentLog.download(), .copy(), .export() (the OTLP object), .stop() and .clear() do what the panel's buttons do. AgentLog.watch(selector, { label }), .unwatch(selector), .watches() and .pick() manage watches; .start({ max, network }) starts logging with options.

The source is agent-log.js, one file with no dependencies, under the Apache License 2.0 like the rest of this site's repository.