Skip to main content
web.agent() creates a model-backed browser agent. It returns final text, structured output, status, steps, artifacts, browser metadata, and bounded observations from Webcompute browser calls.

Signature

WebAgentConfig

Model config

modelApi accepts chat-completions or responses. SDK web.agent() requires explicit model config. Running web model setup in the CLI configures the CLI profile store, not SDK application code. The SDK exports model-profile helpers for applications that already have profile-shaped config:
  • parseWebAgentModelRoute
  • normalizeWebAgentModelProfile
  • resolveWebAgentModelAccess
  • webAgentModelConfigForAccess
  • inferWebAgentModelRoute
These helpers operate on config supplied by your application. They do not load local CLI config by themselves.

Browser config

Use browser.policy for the default navigation policy. Use browser.create when the agent should create its browser with browser-creation options such as proxy, maxDuration, recording, or a creation-time policy.

Run input

You can pass a string shorthand when only the goal is needed:
Use browserId to run against an existing browser. Use startUrl to create or navigate the run to a starting page. Existing-browser runs should use an agent without browser.policy or browser.create.policy; the explicit browser owns its policy.
When you pass browserId, your application owns lifecycle, policy, files, downloads, recordings, status, and cleanup around the agent run.

Result

transcript is included only when artifacts.retainTranscript is enabled.

Streaming

WebAgentStreamEvent types:

Sessions

Use sessions to run multiple goals against the same browser.

Approvals and confirmations

Approval mode controls how the harness handles sensitive actions: Approval risk values are exported as WEB_AGENT_APPROVAL_RISK_VALUES: auth, account_creation, sensitive_data, external_submit, payment, purchase, legal_acceptance, destructive, permission_change, captcha, file_upload, out_of_scope, ambiguous, unknown.

Variables and secrets

Variables may be raw strings or WebAgentVariable descriptors:

Structured output

outputSchema accepts: Use normalizeOutputSchema when you need the SDK’s schema normalization and validation behavior outside an agent run.

Code policy

WebAgentCodePolicy guides model-generated browser code:
codePolicy is guidance for model-generated code. It is not a security sandbox for untrusted JavaScript. Use browser policy, approval handling, and server-side isolation as the control boundaries.