feat: reuse running sandboxes before starting new ones #11922
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary of PR
This PR modifies the
_wait_for_sandbox_startmethod in theLiveStatusAppConversationServiceclass to query for existing running sandboxes before starting a new one. When no specificsandbox_idis provided, the system now:Key Changes:
_find_running_sandbox_for_user()method: Searches through all sandboxes with pagination, filtering for running sandboxes owned by the current user_wait_for_sandbox_start()method: Now queries for existing sandboxes before creating new onessandbox_idis providedTechnical Details:
RUNNING) and user ownershipChange Type
Checklist
Fixes
This addresses the issue mentioned in the original request where the system would always start a new sandbox instead of reusing existing running ones, leading to inefficient resource utilization.
Release Notes
Improved sandbox resource utilization: The system now reuses existing running sandboxes for users before starting new ones, reducing resource consumption and improving conversation startup times.
@tofarr can click here to continue refining the PR
To run this PR locally, use the following command:
GUI with Docker: