Action Context
Enriched write command responses that show what changed — URL, title, tabs, dialogs, console errors — eliminating expensive snapshot calls between steps.
Overview
Action context appends a compact [context] line to write command responses showing what changed on the page. Instead of calling snapshot after every action, agents can read the context line to know if a navigation occurred, the title changed, a dialog appeared, or console errors were logged.
$ browse --context goto https://example.com/cart
Navigated to https://example.com/cart (200)
[context] -> /cart | title: "Shopping Cart" | errors: +1When nothing changes (e.g., filling an input), no context line is added:
$ browse --context fill @e4 "test@example.com"
Filled @e4Activation
There are three ways to enable action context:
1. CLI Flag
browse --context goto https://example.com
browse --context click @e32. Session Toggle
Enable per-session at runtime — stays on until you turn it off or the session closes:
browse set context on # Enable for this session
browse goto https://... # Now includes [context] without --context flag
browse set context off # Disable3. Environment Variable or Config
# Environment variable
export BROWSE_CONTEXT=1
browse goto https://example.com # Context enabled{
"context": true
}MCP Mode
In MCP mode (browse --mcp), action context is always enabled for write commands. No opt-in needed — MCP clients always benefit from knowing what changed.
What's Reported
The context line includes only fields that changed:
| Field | Example | When Reported |
|---|---|---|
| URL change | -> /checkout | URL pathname changed (query params stripped for privacy) |
| Title change | title: "Order Summary" | document.title changed |
| Tab count | tabs: 3 | A tab was opened or closed |
| Dialog appeared | dialog: [confirm] "Delete item?" | A dialog (alert, confirm, prompt) appeared |
| Dialog dismissed | dialog dismissed | A previously visible dialog was dismissed |
| Console errors | errors: +2 | New console.error calls since last capture |
Multiple changes in one action are combined:
[context] -> /checkout | title: "Checkout" | errors: +1How It Works
- Before the write command executes: capture page state (URL, title, tab count, dialog, error count)
- Execute the write command (
click,goto,fill, etc.) - After execution: capture state again and diff against the before-snapshot
- If anything changed, format and append the
[context]line
State capture is O(1) — it reads running counters, not scanning buffers. Zero overhead when context is disabled.
Interaction with Other Modes
JSON Mode
Context is included in the data field before JSON wrapping:
$ browse --context --json goto https://example.com
{"success":true,"data":"Navigated to https://example.com (200)\n[context] -> / | title: \"Example\"","command":"goto"}Max Output
The --max-output truncation is applied to the base result before the context line is appended. This means the context line is never truncated — you always see what changed even on large outputs.
Content Boundaries
Context is appended outside content boundaries (write commands don't produce page content).
Best Practices
- Enable for multi-step workflows where you'd otherwise call
snapshotorurlbetween actions - Disable for simple single-command usage where you don't need the extra output
- Use the session toggle (
set context on) when entering a complex workflow, thenset context offwhen done - In MCP mode, it's always on — no action needed