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
- Turn it onwith the bookmarklet, on any page
- Use the page until the bug showsconsole, errors, requests and the elements you pick are recorded
- Hand the log to your agentDownload or Copy from the red Logging badge
Get it
Three ways in; the bookmarklet works on most pages.
Does nothing on a page with a strict Content Security Policy (GitHub, many banks and web mail). Use the Console tab there.
Open the browser's developer console (F12, then Console) on the page to debug and paste this:
The snippet loads the script from this site, which a strict CSP blocks. Pasting the whole script (about 40 KB) works on any page.
Add the script to a page you build. It does nothing until the page is opened with ?logging=true; then it stays on in that tab until Stop logging or ?logging=false.
Add data-start to the tag to log on every load, and &watch=<selector> to the URL to watch an element.
Try it on this page
Use the controls; the records appear on the right.
Make some records
Watch elements
Or open the panel, press Watch an element and click anything on this page.
Live log, this page load
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:
| eventName | Recorded when | Severity |
|---|---|---|
console.log, .info, .debug, .warn, .error, .trace, .assert | the page calls the console method (assert only when it fails) | DEBUG to ERROR, by method |
error.uncaught | an exception reaches window | ERROR |
error.rejection | a promise rejects with no handler | ERROR |
error.resource | an image, script or stylesheet fails to load | ERROR |
csp.violation | the page's CSP blocks something | WARN |
http.fetch, http.xhr | a request finishes or fails: method, URL, status, duration | INFO; WARN at 400 and up; ERROR when it fails |
page.navigation, page.visibility | in-page navigation; the tab is hidden or shown | INFO |
dom.click, .dblclick, .input, .change, .submit, .focus, .blur, .keydown | an event on a watched element | INFO |
dom.mutation | a watched element's attributes, text or children change (at most 20 records a second per watch) | INFO |
dom.watch | a watch is added or removed, or the number of elements it matches changes | INFO; WARN at zero |
agentlog.start, agentlog.stop | logging starts or stops | INFO |
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.comcan only be viewed and exported from a page onexample.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=trueto 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, markedagentlog.before_start. - Some apps keep their own reference to
fetchorconsole.logfrom 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.sourceisresource-timing), and it does not see console calls made through such a reference. - Recorded URLs have credentials replaced with
REDACTED: query parameters namedkey,code,auth,sig,stateornonce, names containingtoken,secret,password,api_key,sessionorsignature(soauth_tokenandx-api-keytoo), and names ending in_keyor_code. The same rule applies tokey=valuepairs 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#/settingsstay 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.