Skip to content

Commit 1f6bdd8

Browse files
committed
feat(browser): add compatibility helper for browser capability; use in Task and webview; add tests covering supportsImages vs legacy supportsComputerUse
1 parent ce387b1 commit 1f6bdd8

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/core/task/Task.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ import { ClineApiReqCancelReason, ClineApiReqInfo } from "../../shared/Extension
5353
import { getApiMetrics, hasTokenUsageChanged } from "../../shared/getApiMetrics"
5454
import { ClineAskResponse } from "../../shared/WebviewMessage"
5555
import { defaultModeSlug, getModeBySlug, getGroupName } from "../../shared/modes"
56+
import { modelSupportsBrowserCapability } from "../../shared/browserCapability"
5657
import { DiffStrategy } from "../../shared/tools"
5758
import { EXPERIMENT_IDS, experiments } from "../../shared/experiments"
5859
import { getModelMaxOutputTokens } from "../../shared/api"
@@ -2420,7 +2421,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
24202421
const modeSupportsBrowser = modeConfig?.groups.some((group) => getGroupName(group) === "browser") ?? false
24212422

24222423
const canUseBrowserTool =
2423-
(this.api.getModel().info.supportsImages ?? false) &&
2424+
modelSupportsBrowserCapability(this.api.getModel().info, apiConfiguration) &&
24242425
modeSupportsBrowser &&
24252426
(browserToolEnabled ?? true)
24262427

src/core/webview/generateSystemPrompt.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { WebviewMessage } from "../../shared/WebviewMessage"
33
import { defaultModeSlug, getModeBySlug, getGroupName } from "../../shared/modes"
44
import { buildApiHandler } from "../../api"
55
import { experiments as experimentsModule, EXPERIMENT_IDS } from "../../shared/experiments"
6+
import { modelSupportsBrowserCapability } from "../../shared/browserCapability"
7+
import { modelSupportsBrowserCapability } from "../../shared/browserCapability"
68

79
import { SYSTEM_PROMPT } from "../prompts/system"
810
import { MultiSearchReplaceDiffStrategy } from "../diff/strategies/multi-search-replace"
@@ -45,15 +47,16 @@ export const generateSystemPrompt = async (provider: ClineProvider, message: Web
4547
const rooIgnoreInstructions = provider.getCurrentTask()?.rooIgnoreController?.getInstructions()
4648

4749
// Determine if browser tools can be used based on model support, mode, and user settings
48-
let modelSupportsImages = false
50+
let modelSupportsBrowser = false
4951

50-
// Create a temporary API handler to check if the model supports images
52+
// Create a temporary API handler to check if the model supports browser capability
5153
// This avoids relying on an active Cline instance which might not exist during preview
5254
try {
5355
const tempApiHandler = buildApiHandler(apiConfiguration)
54-
modelSupportsImages = tempApiHandler.getModel().info.supportsImages ?? false
56+
const info = tempApiHandler.getModel().info
57+
modelSupportsBrowser = modelSupportsBrowserCapability(info, apiConfiguration)
5558
} catch (error) {
56-
console.error("Error checking if model supports images:", error)
59+
console.error("Error checking if model supports browser capability:", error)
5760
}
5861

5962
// Check if the current mode includes the browser tool group
@@ -62,7 +65,7 @@ export const generateSystemPrompt = async (provider: ClineProvider, message: Web
6265

6366
// Only enable browser tools if the model supports it, the mode includes browser tools,
6467
// and browser tools are enabled in settings
65-
const canUseBrowserTool = modelSupportsImages && modeSupportsBrowser && (browserToolEnabled ?? true)
68+
const canUseBrowserTool = modelSupportsBrowser && modeSupportsBrowser && (browserToolEnabled ?? true)
6669

6770
const systemPrompt = await SYSTEM_PROMPT(
6871
provider.context,

0 commit comments

Comments
 (0)