#20207: fix(browser): use profile driver instead of hardcoded name
agents
size: S
Cluster:
Browser Enhancements and Fixes
## Summary
Fixes a browser tool regression where extension-specific behavior was keyed off profile **name** (`"chrome"`) instead of profile **driver** (`"extension"`).
This caused false positives/negatives:
- non-extension profiles named `chrome` were treated like Browser Relay extension profiles
- extension profiles with custom names were not treated as extension profiles
## What changed
### 1) Browser tool now uses driver-based checks
In `src/agents/tools/browser-tool.ts`:
- Added `resolveConfiguredProfileDriver(profileName)`
- Replaced hardcoded checks:
- `profile === "chrome"` → `profileDriver === "extension"` for target defaulting
- `profile === "chrome"` → `profileDriver === "extension"` for tab-not-found relay guidance
- Added safe fallback (`try/catch`) in profile driver resolution to avoid throwing from config reads
### 2) Expose profile driver in browser API/status payloads
- `src/browser/client.ts`
- `BrowserStatus.driver?: "openclaw" | "extension"`
- `ProfileStatus.driver: "openclaw" | "extension"`
- `src/browser/server-context.types.ts`
- Added `driver` to `ProfileStatus`
- `src/browser/server-context.ts`
- `listProfiles()` now includes `driver`
- `src/browser/routes/basic.ts`
- `/` status response now includes `driver`
### 3) Regression tests
- `src/agents/tools/browser-tool.e2e.test.ts`
- extension custom profile defaults to host
- non-extension profile named `chrome` keeps sandbox path
- extension custom profile gets relay-specific tab guidance
- non-extension `chrome` profile does not get relay guidance
- `src/browser/server.post-tabs-open-profile-unknown-returns-404.test.ts`
- verifies `driver` is present in `/` status and `/profiles` responses
## Why this fix
The server-side browser layer already uses `profile.driver` semantics. This PR aligns the agent browser tool with that same contract, removing brittle name-coupling and fixing issue behavior reported in #11926.
Fixes #11926
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR fixes a browser tool regression where extension-specific behavior was keyed off profile **name** (`"chrome"`) instead of profile **driver** (`"extension"`). A new `resolveConfiguredProfileDriver()` helper reads the driver from config and the two checks in `browser-tool.ts` now use `profileDriver === "extension"` instead of `profile === "chrome"`. The server-side API (`/` status and `/profiles`) now also exposes the `driver` field, with corresponding type updates in both client and server types.
- The core fix correctly decouples extension detection from profile naming, aligning the agent tool with the server-side `profile.driver` contract
- `resolveConfiguredProfileDriver` is safely wrapped in try/catch with proper input trimming
- `driver` field added to `BrowserStatus` (optional for backward compat), `ProfileStatus` (required), and both API responses
- Four targeted regression tests in `browser-tool.e2e.test.ts` cover the key scenarios (custom extension profile → host, non-extension "chrome" → sandbox, extension guidance, non-extension no guidance)
- One remaining issue: an error message on line 837 of `browser-tool.ts` still hardcodes `profile="chrome"` instead of using the actual profile name variable — this is the same name-coupling bug this PR aims to fix
<h3>Confidence Score: 4/5</h3>
- This PR is safe to merge with one minor hardcoded string to fix in an error message
- The core logic change is correct and well-tested. Types are consistent across client/server boundaries. The only issue is a leftover hardcoded `profile="chrome"` in an error message that contradicts the PR's goal of removing name-coupling. This won't cause runtime failures but will show incorrect guidance to users with custom-named extension profiles.
- `src/agents/tools/browser-tool.ts` — hardcoded `profile="chrome"` in error message at line 837
<sub>Last reviewed commit: d4fc659</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#15304: feat(browser): add browser-use no-relay profile driver
by rajanrengasamy · 2026-02-13
83.6%
#14944: fix(browser): prefer openclaw profile in headless/noSandbox environ...
by BenediktSchackenberg · 2026-02-12
81.0%
#6193: fix(browser): default to openclaw profile instead of chrome extensi...
by mikezaoldyeck · 2026-02-01
80.8%
#22952: fix(browser): suggest remote profile when local Chrome is not insta...
by dashed · 2026-02-21
80.5%
#16030: fix(browser): extend single-tab fallback to remote CDP profiles
by lailoo · 2026-02-14
79.0%
#9728: fix(gateway): browser.snapshot ignores profile parameter (#9723)
by divol89 · 2026-02-05
76.9%
#7589: Tests: accept browser profiles auth option
by justinhuangcode · 2026-02-03
74.2%
#18907: Fix: Improve browser error messages to avoid misleading agents
by jriff · 2026-02-17
74.0%
#9020: fix(browser): skip port ownership and WS reachability checks for re...
by yepack · 2026-02-04
74.0%
#23363: Browser: fallback to managed profile and improve runtime diagnostics
by isdoho · 2026-02-22
72.6%