Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use persistent browser session in runnables #1510

Merged

Conversation

satansdeer
Copy link
Contributor

@satansdeer satansdeer commented Jan 7, 2025

Depends on #1497

Testing

Run python scripts/test_persistent_browsers.py it will launch testing CLI.

In the testing CLI:

> create_browser_session
> create_task --browser_session_id <session_id>

> create_cruise --browser_session_id <session_id>

> create_workflow_run --browser_session_id <session_id>

The task should run with browser session id and occupy/release the browser session


Important

Introduces persistent browser sessions for tasks and workflows, enabling session reuse across runs by updating session management and execution logic.

  • Behavior:
    • Introduces persistent browser sessions in test_persistent_browsers.py, allowing tasks and workflows to reuse browser sessions.
    • Adds browser_session_id parameter to functions in agent.py, async_executor.py, and agent_protocol.py to support session reuse.
  • Session Management:
    • Updates BrowserManager and PersistentSessionsManager to handle session creation, occupation, and release.
    • Adds session management logic to get_or_create_for_task() and get_or_create_for_workflow_run() in browser_manager.py.
    • Implements session cleanup in cleanup_for_task() and cleanup_for_workflow_run() in browser_manager.py.
  • Task and Workflow Execution:
    • Modifies execute_task(), execute_workflow(), and execute_cruise() in async_executor.py to use browser_session_id.
    • Updates execute_step() in agent.py to handle browser_session_id for task execution.
    • Adjusts create_agent_task() and execute_workflow() in agent_protocol.py to pass browser_session_id.
  • Schema Changes:
    • Adds browser_session_id to TaskRequest in tasks.py and CruiseRequest in observers.py.

This description was created by Ellipsis for 265c9b1. It will automatically update as commits are pushed.

@satansdeer satansdeer changed the title maksimi/use persistent browser session Use persistent browser session in runnables Jan 7, 2025
@satansdeer satansdeer marked this pull request as ready for review January 9, 2025 17:01
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good to me! Reviewed everything up to 265c9b1 in 1 minute and 38 seconds

More details
  • Looked at 1152 lines of code in 12 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. skyvern/webeye/browser_manager.py:70
  • Draft comment:
    Consider refactoring the logic for handling browser sessions to reduce duplication. The code for creating, occupying, and releasing sessions is repeated in multiple places, which can be consolidated for better maintainability.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The code in browser_manager.py and persistent_sessions_manager.py has a lot of repeated logic for handling browser sessions, especially around creating, occupying, and releasing sessions. This could be refactored to reduce duplication and improve maintainability.
2. skyvern/webeye/browser_manager.py:126
  • Draft comment:
    The logic for handling browser sessions in get_or_create_for_task and get_or_create_for_workflow_run is similar. Consider refactoring to reduce code duplication.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The get_or_create_for_task and get_or_create_for_workflow_run methods in browser_manager.py have similar logic for handling browser sessions. This could be refactored to reduce code duplication.
3. skyvern/webeye/persistent_sessions_manager.py:165
  • Draft comment:
    The try-except block in close_session handles TargetClosedError and generic exceptions. Consider adding more context to the log messages to aid in debugging.
  • Reason this comment was not posted:
    Confidence changes required: 33%
    The close_session method in persistent_sessions_manager.py has a try-except block that handles TargetClosedError and a generic exception. This is good for robustness, but the logging could be improved to provide more context about the error.

Workflow ID: wflow_HJezITDQvZAjZrEA


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@wintonzheng wintonzheng merged commit a4744ed into Skyvern-AI:main Jan 9, 2025
2 checks passed
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