Skip to content

.NET: Require full LocalCodeAct interpreter paths - #10225

Open
Eduard van Valkenburg (eavanvalkenburg) wants to merge 3 commits into
microsoft:mainfrom
eavanvalkenburg:localcodeact-interpreter-resolution
Open

Eduard van Valkenburg (eavanvalkenburg) wants to merge 3 commits into
microsoft:mainfrom
eavanvalkenburg:localcodeact-interpreter-resolution

Conversation

@eavanvalkenburg

@eavanvalkenburg Eduard van Valkenburg (eavanvalkenburg) commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Motivation & Context

Make interpreter selection explicit and consistent across LocalCodeAct validation and execution on every platform. Both public entry points now require a fully qualified path to an existing interpreter file.

Description & Review Guide

  • What are the major changes? Add a shared path check to LocalCodeActProvider and LocalExecuteCodeFunction, before embedded scripts are extracted. Apply it on Windows, Linux, and macOS, update both hosted samples and their configuration guidance, and add constructor regression tests.
  • What is the impact of these changes? Callers must replace bare or relative interpreter values with a fully qualified path. Missing files fail at construction. Both hosted samples require LOCAL_CODEACT_PYTHON; the ClawAgent container sets it to its installed /usr/bin/python3, and the source-deploy sample forwards the configured hosted-runtime path through azure.yaml. Validation policy and runner arguments are unchanged.
  • What do you want reviewers to focus on? Consistent path checks across both constructors, including when validation is disabled. ClawAgent.Hosted relies on the provider check. The standalone Hosted-LocalCodeAct sample retains its own startup check because its currently referenced published package does not enforce this contract.

dotnet run --project tests/Microsoft.Agents.AI.LocalCodeAct.UnitTests/Microsoft.Agents.AI.LocalCodeAct.UnitTests.csproj -f net10.0 --no-restore -p:UseSharedCompilation=false (from dotnet/, on macOS with an installed Python interpreter configured): passed, 287 tests succeeded and 2 Windows-specific root-relative path cases were skipped.

dotnet build samples/02-agents/Harness/BuildYourOwnClaw/Claw_Step04_ProductionReady/ClawAgent.Hosted/ClawAgent.Hosted.csproj -f net10.0 --no-restore --tl:off --verbosity minimal --disable-build-servers -p:UseSharedCompilation=false (from dotnet/): passed, with 0 warnings and 0 errors.

dotnet build HostedLocalCodeAct.csproj --tl:off --verbosity minimal --disable-build-servers -p:UseSharedCompilation=false (from a standalone copy of the hosted sample outside the repository): passed, with 0 warnings and 0 errors.

git diff --check: passed. The full .NET solution was not built or tested. Windows/Linux runtime validation and hosted deployments were not run locally.

Related Issue

N/A

AI Assistance

  • No material AI assistance was used.
  • This is an AI-assisted contribution. I reviewed, understood, and verified all submitted content and accept responsibility for it.

AI assistance details: GitHub Copilot assisted with the implementation, tests, documentation, and this PR description.

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 links to an agreed issue with no competing open PR, or the Related Issue section documents a trivial-change or repository-automation exception.
  • 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.

Copilot AI balanced review requested due to automatic review settings November 10, 2026 10:31
@agent-framework-automation agent-framework-automation Bot added documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs .NET Usage: [Issues, PRs], Target: .Net breaking change Usage: [PRs], Target: all PRs that introduce changes that are not backward compatible labels Nov 10, 2026

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.

🟢 Approval recommended

No active review issues remain for the Windows interpreter configuration changes.

No open issues 🎉

What changed in this PR

This PR makes Windows interpreter configuration explicit for .NET LocalCodeAct. Both public constructors require a fully qualified path to an existing interpreter file before extracting scripts, while non-Windows behavior remains unchanged.

Changes:

  • Add shared Windows path validation, including when code validation is disabled.
  • Require explicit Windows interpreter configuration in the hosted sample and document migration guidance.
  • Add constructor regression tests and adapt existing tests to valid Windows paths.
File Description
dotnet/​tests/​Microsoft.Agents.AI.LocalCodeAct.UnitTests/​LocalExecuteCodeFunctionIntegrationTests.cs Filter Windows interpreter discovery to fully qualified paths.
dotnet/​tests/​Microsoft.Agents.AI.LocalCodeAct.UnitTests/​LocalCodeActProviderTests.cs Use an existing executable for constructor-only tests.
dotnet/​tests/​Microsoft.Agents.AI.LocalCodeAct.UnitTests/​InterpreterResolutionTests.cs Cover path rejection, acceptance, and unchanged non-Windows behavior.
dotnet/​tests/​Microsoft.Agents.AI.LocalCodeAct.UnitTests/​FeatureUsageActivationTests.cs Supply a valid executable path for feature-usage testing.
dotnet/​tests/​Microsoft.Agents.AI.LocalCodeAct.UnitTests/​ApprovalPropagationTests.cs Adapt approval tests to the Windows path requirement.
dotnet/​src/​Microsoft.Agents.AI.LocalCodeAct/​README.md Document Windows requirements and trusted-location precautions.
dotnet/​src/​Microsoft.Agents.AI.LocalCodeAct/​LocalExecuteCodeFunction.cs Validate interpreter paths and document constructor exceptions.
dotnet/​src/​Microsoft.Agents.AI.LocalCodeAct/​LocalCodeActProvider.cs Apply the same validation to provider construction.
dotnet/​src/​Microsoft.Agents.AI.LocalCodeAct/​Internal/​PythonExecutablePath.cs Centralize Windows path and file-existence checks.
dotnet/​samples/​04-hosting/​FoundryHostedAgents/​responses/​Hosted-LocalCodeAct/​README.md Explain platform-specific interpreter configuration.
dotnet/​samples/​04-hosting/​FoundryHostedAgents/​responses/​Hosted-LocalCodeAct/​Program.cs Check Windows configuration at startup; retain the Unix fallback.
dotnet/​samples/​04-hosting/​FoundryHostedAgents/​responses/​Hosted-LocalCodeAct/​.env.example Add Windows interpreter configuration guidance.

Review effort: Balanced

@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)): 1a78fd942397
Model: gpt-5.6-sol

Overview

The PR consistently applies an explicit Windows interpreter-path contract to both public constructors before script extraction, with focused tests covering validation modes, path forms, missing files, directories, spaces, and preserved Unix behavior. The hosted LocalCodeAct sample and documentation are updated in parallel. One other first-party sample still relies on the now-invalid bare python3 default for direct Windows runs and must be migrated with the breaking contract.

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

Affected areas: dotnet/src/Microsoft.Agents.AI.LocalCodeAct/LocalCodeActProvider.cs

@eavanvalkenburg Eduard van Valkenburg (eavanvalkenburg) changed the title .NET: [BREAKING] Require full LocalCodeAct interpreter paths on Windows .NET: Require full LocalCodeAct interpreter paths on Windows Nov 10, 2026
@eavanvalkenburg Eduard van Valkenburg (eavanvalkenburg) removed the breaking change Usage: [PRs], Target: all PRs that introduce changes that are not backward compatible label Nov 10, 2026
@eavanvalkenburg Eduard van Valkenburg (eavanvalkenburg) changed the title .NET: Require full LocalCodeAct interpreter paths on Windows .NET: Require full LocalCodeAct interpreter paths Nov 10, 2026

This branch was successfully deployed

1 active deployment
github-app-auth — a753a18d Deployed Nov 10, 2026 by eavanvalkenburg via add_label #27516
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs .NET Usage: [Issues, PRs], Target: .Net

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants