web agent when you want to create and run an agentic workflow from the terminal. The command gives the agent a managed browser, applies your model profile and boundaries, and returns an inspectable result.
The CLI agent is a one-shot workflow: it creates a managed browser for the run and closes browsers it created when the command finishes. Use SDK web.agent() when the workflow needs to live inside an application, backend process, recurring automation, or custom browser creation path such as proxy.
Configure model access
Save a reusable profile:Write a bounded task
A good CLI agent task names the site, starts from a URL, constrains the domain, and asks for a concrete result.Choose an approval mode
Return data to another program
Use--json for machine-readable run output.
--schema when the final answer must match a JSON schema.
Pass secrets safely
--secret name=ENV_VAR reads the value from your environment and exposes it as a sensitive variable. When --allow-domain is present, the CLI scopes the secret to those domains. When no domain is present, the CLI scopes the secret to the start URL hostname when it can.
Do not paste secret values into the goal text.
Inspect while the run is active
Use--debug-url only when you intentionally want the signed live-browser URL in output.
web.agent() with browser.create.recording: true or direct browser control.
Common failure modes
Reference: SDK quickstart, policies and approvals, secrets and user input, and production blockers.