hexr.browser gives your agent access to a headless Chromium instance for tasks that require real-world web interaction — reading news sites, extracting structured data, taking screenshots for vision models, or filling out forms. Each browser session runs in a sandboxed container, destroys its cookies on exit, and is gated by OPA policies that restrict which domains your agent can access. This guide covers the three most common use cases: web research, visual analysis, and form submission.
Steps
Install and import the browser module
The browser module is included with the Hexr SDK. Import
browse from hexr.browser:web_researcher.py
Choose a use case and write your agent
Pick from the three patterns below based on what your agent needs to do:
Available actions
| Action | Description |
|---|---|
extract_text | Extract all visible text content |
extract_links | Get all hyperlinks |
screenshot | Take a PNG screenshot |
fill | Fill a form field by CSS selector |
click | Click an element by CSS selector |
wait | Wait for an element to appear |
scroll | Scroll the page |
Security model
| Protection | Description |
|---|---|
| Isolated browser | Runs in a sandboxed container, separate from the agent process |
| No cookie persistence | Session cookies are destroyed after each browse() call |
| URL allowlisting | OPA policies restrict which domains the agent can access |
| SPIFFE authenticated | Browser access is tied to the agent’s SPIFFE identity |
Next steps
Secure secrets
Store credentials for form submissions with SPIFFE-scoped Vault access.
Code execution
Process browser-extracted data with safely sandboxed code.
LLM observability
Trace vision model calls made with browser screenshots.
SDK reference
Full reference for
hexr.browser.browse and all supported actions.