Skip to content

Conversation

@icecrasher321
Copy link
Collaborator

Summary

Add way to pass in profile id to browser use run task. Must stop session manually after it succeeds.

Type of Change

  • New feature

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Jan 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Skipped Skipped Jan 20, 2026 7:03pm

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 20, 2026

Greptile Summary

This PR adds profile ID support to Browser Use, allowing persistent browser sessions across multiple task executions. When a profile_id is provided, the code creates a session with that profile, runs the task using the session, and then stops the session.

Key changes:

  • Added profile_id optional parameter to the Browser Use block UI and types
  • Refactored run_task.ts to use directExecution with session management functions
  • Sessions are automatically stopped after task completion (lines 322-324)

Issues identified:

  • Obsolete request and transformResponse config remains in the tool definition (lines 258-265) - already flagged in previous review
  • The automatic session cleanup behavior has been clarified by the developer as intentional manual control within code

Confidence Score: 4/5

  • Safe to merge with one cleanup opportunity (removing obsolete config)
  • The implementation is solid with proper error handling, session management, and polling logic. The main concern is the obsolete request/transformResponse config that should be removed for code clarity, but this doesn't affect functionality since directExecution takes precedence.
  • apps/sim/tools/browser_use/run_task.ts should have obsolete config removed (lines 258-265)

Important Files Changed

Filename Overview
apps/sim/tools/browser_use/types.ts Added profile_id optional string parameter to BrowserUseRunTaskParams interface
apps/sim/blocks/blocks/browser_use.ts Added Profile ID UI field (short-input) and corresponding input/output type definitions
apps/sim/tools/browser_use/run_task.ts Refactored to support profile-based sessions with session creation, cleanup, and direct execution; obsolete config remains

Sequence Diagram

sequenceDiagram
    participant User
    participant Block as Browser Use Block
    participant Tool as runTaskTool
    participant Session as BrowserUse Sessions API
    participant Tasks as BrowserUse Tasks API

    User->>Block: Provide task + profile_id (optional)
    Block->>Tool: directExecution(params)
    
    alt profile_id provided
        Tool->>Session: POST /v2/sessions {profileId}
        Session-->>Tool: {id: sessionId}
        Note over Tool: Session created for profile
    end
    
    Tool->>Tool: buildRequestBody(params, sessionId)
    Tool->>Tasks: POST /v2/tasks {task, sessionId?, secrets}
    Tasks-->>Tool: {id: taskId}
    
    loop Poll until complete (max 3 min)
        Tool->>Tasks: GET /v2/tasks/{taskId}
        Tasks-->>Tool: {status, output, steps}
        alt status in [finished, failed, stopped]
            Note over Tool: Exit polling loop
        end
    end
    
    alt sessionId exists
        Tool->>Session: PATCH /v2/sessions/{sessionId} {action: stop}
        Session-->>Tool: Session stopped
    end
    
    Tool-->>Block: {success, output, steps, error?}
    Block-->>User: Task result
Loading

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, 3 comments

Edit Code Review Agent Settings | Greptile

@icecrasher321
Copy link
Collaborator Author

@greptile

@icecrasher321 icecrasher321 merged commit 8344d68 into staging Jan 20, 2026
11 checks passed
@waleedlatif1 waleedlatif1 deleted the improvement/browser-use branch January 20, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants