Skip to content

Python: Add core session tests and Windows emulator repair script - #7457

Draft
HASSanHASSgit wants to merge 4 commits into
microsoft:mainfrom
HASSanHASSgit:hassanhassgit-animated-journey
Draft

Python: Add core session tests and Windows emulator repair script#7457
HASSanHASSgit wants to merge 4 commits into
microsoft:mainfrom
HASSanHASSgit:hassanhassgit-animated-journey

Conversation

@HASSanHASSgit

Copy link
Copy Markdown

Motivation & Context

Add missing edge-case tests for core session utilities and provide a convenience PowerShell script to repair common Windows virtualization components. These changes improve test coverage for session serialization/filename logic and add an admin script to help Windows developers recover corrupted virtualization features.

Description & Review Guide

  • What are the major changes?

    • Add tests: python/packages/core/tests/core/test_sessions_additional.py covering _session_file_stem encoding, _contains_non_finite_float nested detection, and default state encoder/decoder edge cases.
    • Add script: tools/windows/repair-emulators.ps1 — PowerShell script to disable and re-enable Hyper-V, VirtualMachinePlatform, HypervisorPlatform, WSL, and Containers (requires admin).
  • What is the impact of these changes?

    • Tests only: increases unit test coverage for core session logic.
    • Script: developer tooling only (no runtime code changes); requires administrator privileges to run. No production behavior changed.
  • What do you want reviewers to focus on?

    • Test correctness and whether the new assertions align with intended serialization behavior.
    • Safety and messaging in repair-emulators.ps1 (it requires admin and prompts for restart). Please flag any security/user-experience concerns (e.g., better safeguards before running Restart-Computer).

Related Issue

Fixes #

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 (https://github.com/microsoft/agent-framework/blob/main/CONTRIBUTING.md)
  • 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 title prefix in sync automatically.

Repo Automation and others added 2 commits July 31, 2026 15:07
…e tests

- Add tests for _session_file_stem encoding and edge cases
- Add tests for _contains_non_finite_float nested detection
- Add tests for default state encoder/decoder error and pydantic decoder

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

- Add admin PowerShell script to re-install/repair Hyper-V, WSL, VirtualMachinePlatform, Containers

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 31, 2026 12:10
@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Jul 31, 2026
@github-actions github-actions Bot changed the title Add core session tests and Windows emulator repair script Python: Add core session tests and Windows emulator repair script Jul 31, 2026
@HASSanHASSgit

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

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.

Pull request overview

Adds additional Python unit tests for core session helper behavior (filename-safe session IDs, nested non-finite float detection, and default state codec edge cases) and introduces a Windows-only PowerShell convenience script intended to “repair” common virtualization/emulator optional features by disabling and re-enabling them.

Changes:

  • Added new core session edge-case tests covering _session_file_stem, _contains_non_finite_float, and default state encoder/decoder paths.
  • Added a Windows PowerShell script to toggle key virtualization-related optional Windows features and optionally restart the machine.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
python/packages/core/tests/core/test_sessions_additional.py New unit tests to improve coverage for session filename/serialization helper edge cases.
tools/windows/repair-emulators.ps1 New admin PowerShell script to disable/re-enable virtualization features commonly needed for emulators/WSL.

Comment thread python/packages/core/tests/core/test_sessions_additional.py Outdated
Comment thread tools/windows/repair-emulators.ps1 Outdated
Comment on lines +60 to +61
# 5. إنهاء العملية وإشعار المستخدم بإعادة التشغيل
Write-Host "`n=== اكتملت العملية بنجاح! ===" -ForegroundColor Green
Comment thread tools/windows/repair-emulators.ps1 Outdated
Comment on lines +3 to +6
Professional Script to Reinstall and Repair All Core Windows Emulators & Virtualization Capabilities.
.DESCRIPTION
This script runs with Administrator privileges to safely remove and clean-reinstall
Hyper-V, Virtual Machine Platform, Windows Sandbox, and WSL Components.
Comment thread tools/windows/repair-emulators.ps1 Outdated
Comment on lines +11 to +13
if (-not $isAdmin) {
Write-Error "خطأ: يجب تشغيل هذا السكربت كمسؤول (Run as Administrator)!"
Exit
Comment on lines +25 to +26
Write-Host "`n=== بدء عملية إعادة تثبيت وإصلاح المحاكيات وأنظمة الافتراضية ===`n" -ForegroundColor Cyan

…ators.ps1 error reporting, bilingual messages, and admin exit code

- Remove unused 'math' import from tests
- Repair script: exit non-zero when not admin, track failed features and report them, make messages bilingual (Arabic/English), fix docstring to reflect toggled features

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

Copy link
Copy Markdown
Author

Automated: I attempted to reply-and-resolve inline review threads but the helper failed for comment IDs: 3690334805, 3690334839, 3690334855, 3690334881, 3690334899. The code fixes are committed and pushed to HASSanHASSgit:hassanhassgit-animated-journey. Please review the updated changes; if you need me to retry the helper, I will. (Automated note)

@HASSanHASSgit
HASSanHASSgit marked this pull request as draft July 31, 2026 12:20
@HASSanHASSgit

Copy link
Copy Markdown
Author

Thanks — pushed fixes addressing the review threads on tools/windows/repair-emulators.ps1:

  • Tracked failed feature enables and exit non-zero when any feature fails (addresses "completed successfully" mismatch).
  • Updated script header to list the exact features toggled (Windows Sandbox not included intentionally).
  • Exit code 1 when not run as Administrator so callers can detect failures.
  • Made user-facing messages bilingual (Arabic/English).

Attempted to run the repo's reply-and-resolve helper to post per-thread replies and mark threads resolved, but the helper failed here with a WSL mount error (HCS ERROR_PATH_NOT_FOUND). I prepared and attempted replies; helper could not complete in this environment. Please re-check the four review threads — the fixes are in branch HASSanHASSgit:hassanhassgit-animated-journey.

If desired, I can retry the helper once more here, or you can run the bundled reply-and-resolve helper from a machine with working WSL to mark threads resolved automatically.

@HASSanHASSgit

Copy link
Copy Markdown
Author

Reply to review thread PRRT_kwDOOhTcGM6VaUjq:\n\nThanks — updated the script to track failed features, report failures, and exit non-zero when features fail to enable. Changes pushed to HASSanHASSgit:hassanhassgit-animated-journey; please re-check.

@HASSanHASSgit

Copy link
Copy Markdown
Author

Reply to review thread PRRT_kwDOOhTcGM6VaUj4:\n\nUpdated the script header to list the exact features toggled. Windows Sandbox was not included intentionally; let me know if you want it added.

@HASSanHASSgit

Copy link
Copy Markdown
Author

Reply to review thread PRRT_kwDOOhTcGM6VaUkK:\n\nNow exits with code 1 when not run as Administrator so callers can detect failure.

@HASSanHASSgit

Copy link
Copy Markdown
Author

Reply to review thread PRRT_kwDOOhTcGM6VaUkZ:\n\nMade user-facing messages bilingual (Arabic/English) so broader contributors can understand prompts and results.

@HASSanHASSgit

Copy link
Copy Markdown
Author

Summary of fixes and request for thread resolution:

  • Addressed all inline review feedback on the Windows script and tests: added bilingual (Arabic/English) user messages, exit with non-zero when not run as Administrator, track and report failed feature enables and return non-zero on failures, and clarified the header to list only the features actually toggled. Removed the unused import from the new test file.

  • Attempted to run the repository's reply-and-resolve helper from this runner, but it cannot complete here due to a WSL attach/mount limitation in this environment. I have posted per-thread replies on the PR documenting the changes.

Request: Please re-check the updated files and, if satisfied, either run the repo's reply-and-resolve helper from a WSL-capable machine to mark inline threads resolved, or confirm in a comment so I can proceed. If you prefer, I can retry the helper here (low chance of success) — tell me which you prefer.

Thanks!

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