Skip to content

feat(browser): add extraArgs config for custom Chrome launch args#18443

Merged
steipete merged 4 commits intoopenclaw:mainfrom
JayMishra-source:feat/browser-custom-args
Feb 16, 2026
Merged

feat(browser): add extraArgs config for custom Chrome launch args#18443
steipete merged 4 commits intoopenclaw:mainfrom
JayMishra-source:feat/browser-custom-args

Conversation

@JayMishra-source
Copy link
Contributor

@JayMishra-source JayMishra-source commented Feb 16, 2026

Summary

  • Adds browser.extraArgs config option (string array) for custom Chrome launch arguments
  • Passed through to Chrome's spawn args before the final about:blank argument
  • Enables stealth flags, window sizing, user-agent overrides without source patching

Context

When using OpenClaw's browser for automation tasks (e.g., social media, web scraping), sites often detect default Chrome automation signatures. Currently the only way to add stealth flags like --window-size, --disable-infobars, or custom --user-agent is to patch the compiled source code on every container start.

This config option makes it declarative:

{
  "browser": {
    "extraArgs": [
      "--window-size=1920,1080",
      "--disable-infobars",
      "--user-agent=Mozilla/5.0 ..."
    ]
  }
}

Changes

  • src/config/types.browser.ts: Added extraArgs?: string[] to BrowserConfig
  • src/browser/config.ts: Added extraArgs to ResolvedBrowserConfig, parsed from config
  • src/browser/chrome.ts: Appends extraArgs to Chrome launch args

Test plan

  • Set browser.extraArgs: ["--window-size=1920,1080"] → verify Chrome launches with flag
  • Empty/missing extraArgs → no change in behavior (backward compatible)
  • Invalid entries (non-string) are filtered out

🤖 Generated with Claude Code

Greptile Summary

Adds a new browser.extraArgs configuration option that allows users to pass custom Chrome launch arguments. This enables declarative configuration of stealth flags, window sizing, and user-agent overrides without patching source code. The implementation correctly filters non-string and empty values, uses secure spawn with array arguments, and places extra args before the final about:blank argument. The feature is backward compatible and follows existing config patterns.

Confidence Score: 4/5

  • This PR is safe to merge with minimal risk - it adds a simple, well-scoped configuration option with proper input filtering
  • The implementation is clean and secure (uses spawn with array args, filters inputs properly). Score is 4 rather than 5 due to missing tests for the new functionality and no CHANGELOG entry, which are project conventions per AGENTS.md
  • No files require special attention - the changes are straightforward and follow existing patterns

Last reviewed commit: 1495d95

Adds a `browser.extraArgs` config option (string array) that is appended
to Chrome's launch arguments. This enables users to add stealth flags,
window size overrides, custom user-agent strings, or other Chrome flags
without patching the source code.

Example config:
  browser.extraArgs: ["--window-size=1920,1080", "--disable-infobars"]

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

3 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines +200 to +202
const extraArgs = Array.isArray(cfg?.extraArgs)
? cfg.extraArgs.filter((a): a is string => typeof a === "string" && a.trim().length > 0)
: [];
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding tests for extraArgs filtering logic (empty strings, non-strings, mixed arrays)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/browser/config.ts
Line: 200:202

Comment:
Consider adding tests for `extraArgs` filtering logic (empty strings, non-strings, mixed arrays)

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

How can I resolve this? If you propose a fix, please make it concise.

Add the missing extraArgs property to buildSandboxBrowserResolvedConfig
to satisfy the ResolvedBrowserConfig type, and fix import ordering.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@openclaw-barnacle openclaw-barnacle bot added the agents Agent runtime and tooling label Feb 16, 2026
JayMishra-source and others added 2 commits February 16, 2026 10:38
Address review feedback: add tests covering empty strings,
non-strings, mixed arrays, and non-array inputs for extraArgs.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@steipete steipete merged commit 47f8c92 into openclaw:main Feb 16, 2026
24 checks passed
@sebslight
Copy link
Member

Reverted in d03339a (#18823).

This was an accidental merge; reverting to remove the browser.extraArgs change.

@tha80
Copy link

tha80 commented Feb 18, 2026

Please don't revert as this is a very useful feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants