Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/bcode-browser/test/fetch-use.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Unit: layer is constructible, `enabled` reflects BROWSER_USE_API_KEY presence.
// Live: when the key is set, end-to-end POST to fetch.browser-use.com returns
// body bytes + content-type. Skipped without the key. Config-based
// opt-out (experimental.fetch_use=false) is enforced in webfetch.ts,
// opt-in (experimental.fetch_use=true) is enforced in webfetch.ts,
// not here.

import { expect, test } from "bun:test"
Expand Down
2 changes: 1 addition & 1 deletion packages/opencode/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ export const Info = Schema.Struct({
}),
fetch_use: Schema.optional(Schema.Boolean).annotate({
description:
"Route webfetch through the Browser Use fetch-use proxy when BROWSER_USE_API_KEY is set. Defaults to true; set false to opt out (still costs but uses native HttpClient instead).",
"Route webfetch through the Browser Use fetch-use proxy when BROWSER_USE_API_KEY is set. Defaults to false; set true to opt in (adds Chrome TLS fingerprint + residential proxy at the cost of extra latency).",
}),
}),
),
Expand Down
7 changes: 4 additions & 3 deletions packages/opencode/src/tool/webfetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ export const WebFetchTool = Tool.define(

const timeout = Math.min((params.timeout ?? DEFAULT_TIMEOUT / 1000) * 1000, MAX_TIMEOUT)

// BrowserCode: route through fetch-use when BROWSER_USE_API_KEY is
// set and the user hasn't opted out via experimental.fetch_use=false.
const useFu = fetchUse.enabled && (yield* config.get()).experimental?.fetch_use !== false
// BrowserCode: route through fetch-use only when BROWSER_USE_API_KEY
// is set AND the user has opted in via experimental.fetch_use=true.
// Default is off: enabling adds latency without measurable accuracy gains.
const useFu = fetchUse.enabled && (yield* config.get()).experimental?.fetch_use === true
const { arrayBuffer, contentType } = yield* (useFu
? fetchUse
.fetch(params.url, { timeoutMs: timeout })
Expand Down
Loading