Skip to content

Python: Clean Hyperlight output files after execution - #8230

Open
Eduard van Valkenburg (eavanvalkenburg) wants to merge 3 commits into
microsoft:mainfrom
eavanvalkenburg:congenial-robot
Open

Python: Clean Hyperlight output files after execution#8230
Eduard van Valkenburg (eavanvalkenburg) wants to merge 3 commits into
microsoft:mainfrom
eavanvalkenburg:congenial-robot

Conversation

@eavanvalkenburg

@eavanvalkenburg Eduard van Valkenburg (eavanvalkenburg) commented Sep 10, 2026

Copy link
Copy Markdown
Member

Motivation & Context

Hyperlight output files should not remain in the cached temporary output directory after an invocation completes, including when output materialization is rejected.

Description & Review Guide

  • What are the major changes? Clear worker-owned output with bounded entry and depth traversal, preserve primary results when cleanup fails, and replace cleanup-failed cached sandboxes before reuse.
  • What is the impact of these changes? Temporary output is removed without changing configured output limits, and residual output cannot be reused by later invocations. The Hyperlight package tests passed with 76 tests passing, 6 skipped, and 12 deselected; package syntax and type checks also passed.
  • What do you want reviewers to focus on? The bounded cleanup lifecycle and cache invalidation after cleanup failure.

Related Issue

None.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and the title prefix in sync automatically.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

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.

🟡 Changes recommended

Cleanup can mask results and bypass bounded traversal safeguards.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Cleans Hyperlight worker output directories after invocation processing and adds rejection-path coverage.

Changes:

  • Performs post-processing output cleanup.
  • Tests cleanup after rejected output.
  • Adjusts bounded-enumeration tracking for cleanup.
File summaries
File Description
_execute_code_tool.py Adds final output-directory cleanup.
test_hyperlight_codeact.py Adds cleanup regression coverage and updates enumeration tracking.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Balanced

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread python/packages/hyperlight/agent_framework_hyperlight/_execute_code_tool.py Outdated
Comment thread python/packages/hyperlight/tests/hyperlight/test_hyperlight_codeact.py Outdated

@github-actions github-actions Bot left a comment

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.

MAF Automated Review — Iteration 1

Result: Findings reported
Scope: full PR (1 commit(s)): b05e413dbcc7
Model: gpt-5.6-sol-fast

Overview

The PR wraps result processing in a worker-thread finally so accepted and rejected outputs are removed while native-result release remains on the owner thread. Existing bounds protect output materialization, and the added test covers ordinary rejected-output cleanup. However, the new final cleanup recursively traverses sandbox-controlled trees; on supported Python 3.12, sufficiently deep output raises RecursionError and leaves the shared cached entry unusable.

Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
1 verified finding remained after source verification (1 high) across 1 file. Details are attached to the affected lines below.

Affected areas: python/packages/hyperlight/agent_framework_hyperlight/_execute_code_tool.py

Comment thread python/packages/hyperlight/agent_framework_hyperlight/_execute_code_tool.py Outdated
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants