Skip to content

[sandbox]add task id to sandbox#834

Merged
xiudongxu merged 1 commit intomainfrom
feature/sandbox_bind_task_id
Mar 25, 2026
Merged

[sandbox]add task id to sandbox#834
xiudongxu merged 1 commit intomainfrom
feature/sandbox_bind_task_id

Conversation

@SzekiHou
Copy link
Copy Markdown
Collaborator

No description provided.

@SzekiHou SzekiHou requested a review from xiudongxu March 25, 2026 09:43
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the sandbox management system by introducing task ID tracking. This change ensures that sandboxes are not prematurely terminated if they are shared or utilized by multiple tasks, thereby improving resource longevity and preventing potential issues arising from early cleanup. The update provides a more robust and intelligent lifecycle management for sandboxes within the system.

Highlights

  • Sandbox Task ID Tracking: Implemented functionality to track task IDs within the sandbox's metadata. This allows a sandbox to be associated with one or more root tasks.
  • Conditional Sandbox Cleanup: Modified the sandbox cleanup process to be conditional. Sandboxes are now only cleaned up when no active tasks are referencing them, preventing premature resource release in multi-task scenarios.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new mechanism to manage sandbox cleanup for agents by tracking associated tasks. It adds logic to store root_task_id in a task_list within the agent's sandbox metadata and modifies the event runner to only perform sandbox cleanup when this task_list is empty, preventing premature resource release. Feedback suggests simplifying the task_list initialization using dict.setdefault() and improving the robustness of the task_list check in the event runner to explicitly verify its type, preventing potential TypeError issues.

Comment on lines +296 to +299
task_list = self.sandbox.metadata.get("task_list")
if task_list is None:
task_list = []
self.sandbox.metadata["task_list"] = task_list
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

This block for getting or initializing task_list can be simplified. Using dict.setdefault() is more concise and Pythonic.

Consider replacing lines 296-299 with:

task_list = self.sandbox.metadata.setdefault("task_list", [])

task_list = metadata.get("task_list", [])

# If we can't find/understand task_list, fallback to original behavior.
if not task_list:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The check if not task_list: is not fully robust. If metadata.get("task_list") returns a non-list, non-empty value (e.g., a number or a non-empty string), this check will pass, and the subsequent if task_id in task_list: could raise a TypeError. It's safer to explicitly check if task_list is a list.

Suggested change
if not task_list:
if not isinstance(task_list, list) or not task_list:

@xiudongxu xiudongxu merged commit 4aec667 into main Mar 25, 2026
1 check 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.

3 participants