Skip to content

[feat]: forward ignoreDefaultArgs to chrome-launcher#2127

Merged
seanmcguire12 merged 4 commits into
mainfrom
evals/external-CalebBarnes-ignore-default-args
May 15, 2026
Merged

[feat]: forward ignoreDefaultArgs to chrome-launcher#2127
seanmcguire12 merged 4 commits into
mainfrom
evals/external-CalebBarnes-ignore-default-args

Conversation

@seanmcguire12
Copy link
Copy Markdown
Member

@seanmcguire12 seanmcguire12 commented May 15, 2026

thanks @CalebBarnes for the contribution! (original PR: #2074)

why

When running Stagehand locally, chrome-launcher adds its own set of default flags (e.g. --disable-extensions). There's currently no way for consumers to selectively remove these flags —
localBrowserLaunchOptions.chromeFlags can only add flags, not remove chrome-launcher's built-in defaults.

This is needed when users want to run Chrome with extensions enabled, or need to remove other chrome-launcher defaults for their use case.

what changed

  • Added ignoreDefaultArgs option to LaunchLocalOptions in local.ts
  • Forwarded localBrowserLaunchOptions.ignoreDefaultArgs from v3.ts through to launchLocalChrome()
  • When true: drops all chrome-launcher defaults (only Stagehand's own flags and user-supplied chromeFlags are used)
  • When string[]: selectively removes only the listed flags from chrome-launcher defaults, keeping the rest

This mirrors the behavior of Playwright's
ignoreDefaultArgs option.

test plan

  • Verified locally that setting ignoreDefaultArgs: ["--disable-extensions"] successfully removes the flag from the launched Chrome instance (confirmed via chrome://version/)
  • Verified that other chrome-launcher defaults are preserved when using the array form
  • Verified that ignoreDefaultArgs: true drops all chrome-launcher defaults

Summary by cubic

Adds ignoreDefaultArgs to local Chrome launch so you can drop all or selected default flags from chrome-launcher with exact-match control (including Stagehand defaults), while keeping your own args.

  • New Features
    • Added ignoreDefaultArgs to LaunchLocalOptions and moved flag assembly into launchLocalChrome(), forwarding to chrome-launcher via ignoreDefaultFlags.
    • true drops all chrome-launcher defaults; string[] removes only exact-matched defaults and re-adds the rest from Launcher.defaultFlags(). Stagehand defaults and user args stay unless explicitly listed.

Written for commit e04da99. Summary will update on new commits. Review in cubic


# why

When running Stagehand locally, chrome-launcher adds its own set of
default flags (e.g. `--disable-extensions`). There's currently no way
for consumers to selectively remove these flags —
`localBrowserLaunchOptions.chromeFlags` can only *add* flags, not remove
chrome-launcher's built-in defaults.

This is needed when users want to run Chrome with extensions enabled, or
need to remove other chrome-launcher defaults for their use case.

# what changed

- Added `ignoreDefaultArgs` option to `LaunchLocalOptions` in `local.ts`
- Forwarded `localBrowserLaunchOptions.ignoreDefaultArgs` from `v3.ts`
through to `launchLocalChrome()`
- When `true`: drops all chrome-launcher defaults (only Stagehand's own
flags and user-supplied `chromeFlags` are used)
- When `string[]`: selectively removes only the listed flags from
chrome-launcher defaults, keeping the rest

This mirrors the behavior of Playwright's
[`ignoreDefaultArgs`](https://playwright.dev/docs/api/class-browsertype#browser-type-launch-option-ignore-default-args)
option.

# test plan

- Verified locally that setting `ignoreDefaultArgs:
["--disable-extensions"]` successfully removes the flag from the
launched Chrome instance (confirmed via `chrome://version/`)
- Verified that other chrome-launcher defaults are preserved when using
the array form
- Verified that `ignoreDefaultArgs: true` drops all chrome-launcher
defaults

<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Adds `ignoreDefaultArgs` to local Chrome launch and forwards it to
`chrome-launcher` so users can drop all or selected default flags while
keeping Stagehand and user flags.

- **New Features**
- Added `ignoreDefaultArgs` to `LaunchLocalOptions` and wired it through
V3 to `launchLocalChrome()`, mapping to `chrome-launcher`’s
`ignoreDefaultFlags`.
- `true` drops all `chrome-launcher` defaults; `string[]` removes only
exact-matched defaults and re-adds the rest from
`Launcher.defaultFlags()`, preserving Stagehand defaults and user
`chromeFlags`.

<sup>Written for commit 1426616.
Summary will update on new commits.</sup>

<!-- End of auto-generated description by cubic. -->

---------

Co-authored-by: Caleb Barnes <CalebBarnes@users.noreply.github.com>
Co-authored-by: Mastra Code (anthropic/claude-opus-4-6) <noreply@mastra.ai>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 15, 2026

🦋 Changeset detected

Latest commit: e04da99

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@browserbasehq/stagehand Minor
@browserbasehq/stagehand-evals Patch
@browserbasehq/stagehand-server-v3 Patch
@browserbasehq/stagehand-server-v4 Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@mintlify
Copy link
Copy Markdown
Contributor

mintlify Bot commented May 15, 2026

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
stagehand 🟢 Ready View Preview May 15, 2026, 8:23 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 5 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.
Architecture diagram
sequenceDiagram
    participant User as Consumer Code
    participant V3 as V3 Class
    participant Local as launchLocalChrome()
    participant ChromeL as chrome-launcher
    participant Chrome as Chrome Browser

    Note over User,Chrome: New: ignoreDefaultArgs forwarding flow

    User->>V3: new Stagehand({ localBrowserLaunchOptions: { ignoreDefaultArgs } })
    V3->>V3: Store localBrowserLaunchOptions

    User->>V3: stagehand.init()
    V3->>V3: Read localBrowserLaunchOptions

    alt ignoreDefaultArgs is true
        V3->>Local: launchLocalChrome({ ignoreDefaultArgs: true })
        Local->>Local: Set ignoreDefaultFlags = true
        Local->>ChromeL: launch({ ignoreDefaultFlags: true })
        ChromeL->>Chrome: Start with NO default flags
    else ignoreDefaultArgs is string[]
        V3->>Local: launchLocalChrome({ ignoreDefaultArgs: ["--disable-extensions"] })
        Local->>Local: Set ignoreDefaultFlags = true
        Local->>Local: Get Launcher.defaultFlags()
        Local->>Local: Filter out excluded flags
        Local->>Local: Prepend kept defaults to chromeFlags
        Local->>ChromeL: launch({ chromeFlags, ignoreDefaultFlags: true })
        ChromeL->>Chrome: Start with filtered defaults + Stagehand flags
    else ignoreDefaultArgs is false/undefined
        V3->>Local: launchLocalChrome({ ignoreDefaultArgs: undefined })
        Local->>ChromeL: launch({ ignoreDefaultFlags: false })
        ChromeL->>Chrome: Start with ALL default flags
    end

    Chrome-->>ChromeL: Browser instance
    ChromeL-->>Local: LaunchedChrome
    Local-->>V3: Chrome instance with WS endpoint
    V3-->>User: Stagehand initialized
Loading

Re-trigger cubic

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 3 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/core/lib/v3/launch/local.ts">

<violation number="1" location="packages/core/lib/v3/launch/local.ts:32">
P1: `ignoreDefaultArgs` currently strips Stagehand default flags, but it should only affect chrome-launcher defaults. This can silently remove required Stagehand launch flags when `ignoreDefaultArgs` is set.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.
Re-trigger cubic

Comment thread packages/core/lib/v3/launch/local.ts
@seanmcguire12 seanmcguire12 merged commit 78bcde8 into main May 15, 2026
421 of 422 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants