feat: add Browser Use V4 run operation - #7174
Conversation
|
@MagMueller is attempting to deploy a commit to the Sim Team on Vercel. A member of the Team first needs to authorize it. |
Greptile SummaryThe PR adds a Browser Use V4 operation while retaining V2 as the default for existing workflows.
Confidence Score: 4/5The PR should not merge until Browser Use V4 polling honors workflow cancellation and execution deadlines; the legacy-card presentation regression is non-blocking. A cancelled or timed-out V4 run remains awaited because the new polling implementation ignores the supplied AbortSignal and can continue against a seven-day deadline. Files Needing Attention: apps/sim/tools/browser_use/run_v4.ts, apps/sim/blocks/blocks/browser_use.ts
|
| Filename | Overview |
|---|---|
| apps/sim/tools/browser_use/run_v4.ts | Adds the complete V4 request and polling lifecycle, but fails to propagate the execution signal or current timeout budget. |
| apps/sim/blocks/blocks/browser_use.ts | Adds operation-specific V4 fields and routing; legacy execution remains compatible, although old cards lose their sentence fallback. |
| apps/sim/tools/browser_use/run_v4.test.ts | Covers successful creation/polling and create-time errors but does not cover cancellation or timeout behavior. |
| apps/sim/tools/browser_use/types.ts | Adds distinct V4 parameter and output contracts and expands the block output union. |
| apps/sim/tools/registry.ts | Registers the new Browser Use V4 tool in the executable registry. |
| apps/docs/content/docs/en/integrations/browser_use.mdx | Documents the new V4 inputs and outputs alongside the existing operation. |
Sequence Diagram
sequenceDiagram
participant Workflow
participant Tool as Browser Use V4 Tool
participant API as Browser Use API
Workflow->>Tool: Execute task with AbortSignal
Tool->>API: POST /api/v4/runs
API-->>Tool: Run ID
loop Until terminal status
Tool->>API: "GET /runs/{id}/status"
API-->>Tool: Current status
end
Tool->>API: "GET /runs/{id}"
API-->>Tool: Terminal result
Tool-->>Workflow: ToolResponse
Reviews (1): Last reviewed commit: "feat: add Browser Use V4 run operation" | Re-trigger Greptile
| async function pollForCompletion( | ||
| runId: string, | ||
| apiKey: string | ||
| ): Promise<{ summary?: V4RunSummary; error?: string }> { |
There was a problem hiding this comment.
When a Browser Use V4 run is cancelled or reaches its execution timeout, directExecution and pollForCompletion ignore the supplied abort signal and continue polling against a seven-day deadline, causing the engine to retain the timed-out execution and its worker resources until the provider finishes or that deadline expires.
Knowledge Base Used: Agent execution and sandbox tasks
| canvasPresentation: { | ||
| defaultTitle: 'Browser Use', | ||
| sentences: { | ||
| default: [ | ||
| { text: 'Run the browser task', field: 'task', core: true }, | ||
| { text: ', starting at', field: 'startUrl' }, | ||
| ], | ||
| byOperation: { | ||
| browser_use_run_task: [ | ||
| { text: 'Run the legacy browser task', field: 'task', core: true }, | ||
| { text: ', starting at', field: 'startUrl' }, | ||
| ], | ||
| browser_use_run_v4: [{ text: 'Run the V4 browser agent', field: 'task', core: true }], | ||
| }, | ||
| }, | ||
| }, |
There was a problem hiding this comment.
Legacy sentence fallback removed
Existing Browser Use blocks lack the newly added operation value, so the operation-keyed presentation cannot select a sentence and has no default fallback. Those saved cards consequently regress from the compact sentence to the generic field-row layout.
Knowledge Base Used: Workflow authoring and rendering
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!
What this adds
Verification
bunx vitest run tools/browser_use/run_v4.test.tsfromapps/sim: 2 tests passed.bun run type-checkfromapps/sim: passed.git diff --check: passed.Environment boundaries
isolated-vmuses an incompatible V8 API.bun install --frozen-lockfile --ignore-scriptssucceeded in the private validation run.work/copilot/copilot/contracts/tool-catalog-v1.jsonis not present in this checkout.