Skip to content

.NET: [BREAKING] CodeAct: redact host-tool diagnostics by default - #9973

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 3 commits into
microsoft:mainfrom
eavanvalkenburg:dotnet-codeact-error-redaction
Nov 3, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 3 commits into
microsoft:mainfrom
eavanvalkenburg:dotnet-codeact-error-redaction

Conversation

@eavanvalkenburg

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

Copy link
Copy Markdown
Member

Motivation & Context

Give .NET Hyperlight and LocalCodeAct a consistent, host-controlled policy for diagnostic details. Registered tool failures should remain failures without making backend exception text available to generated code unless the application explicitly opts in for a trusted channel.

This PR contains only the .NET implementation, tests, documentation, and .NET consumer guidance split from #9971. It targets main independently and does not depend on the Python PR.

Description & Review Guide

  • What are the major changes? Add default-off IncludeDetailedErrors options to .NET Hyperlight and LocalCodeAct. Redact guest-facing host failures while preserving JSON/subprocess error protocols, capture the policy in provider and standalone snapshots, and include it in Hyperlight configuration fingerprints. Apply the policy to the complete Hyperlight lifecycle and include stack traces and inner exceptions only with trusted opt-in. Update .NET regression coverage and integration guidance.
  • What is the impact of these changes? Successful results and failure signaling are unchanged. Full exception diagnostics require explicit trusted opt-in; default failures remain generic and argument-validation errors retain safe messages without stack traces. The policy remains separate from outer-client error handling and sensitive-data logging. Existing uncaught-error propagation in LocalCodeAct is preserved.
  • What do you want reviewers to focus on? Review policy propagation, safe argument-error diagnostics, cache isolation, and caught/uncaught error paths. Native Hyperlight backend verification remains required before release; the new backend tests compiled but could not execute in this environment.

Targeted checks for the latest diagnostic-detail changes, run from dotnet/:

  • dotnet test --project tests/Microsoft.Agents.AI.Hyperlight.UnitTests -f net10.0 --no-restore -p:TargetFrameworks=net10.0 -p:WarningsNotAsErrors=NU1510 — 58 passed.
  • dotnet test --project tests/Microsoft.Agents.AI.LocalCodeAct.UnitTests -f net10.0 --no-restore -p:TargetFrameworks=net10.0 -p:WarningsNotAsErrors=NU1510 --filter-query "/*/*/LocalExecuteCodeFunctionIntegrationTests/*HostErrors*" — 6 passed with real Python subprocesses.
  • Scoped .NET whitespace verification — passed.

Checks used SDK 10.0.401 in a Linux source export, retaining the existing NU1510 package-pruning diagnostic as a warning. SourceLink warnings reflect the Git-free export. The full LocalCodeAct suite previously passed 273 tests; only the 6 affected cases were rerun for this follow-up. Five native Hyperlight cases previously compiled but skipped because the guest/hypervisor environment was unavailable; they were not rerun for this follow-up. These skips are not native verification.

Related Issue

N/A — maintainer-directed consistency update. Companion to #9971, which contains only the Python changes.

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 implementation, tests, documentation, this description, and the language-only PR split.

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 the title prefix in sync automatically.

Copilot AI balanced review requested due to automatic review settings November 2, 2026 13:19
@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 2, 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.

🔵 Needs a closer look

Security-sensitive Hyperlight redaction and callback/cache isolation remain unverified across the host/guest boundary because all three native backend tests were skipped due to an unavailable guest/hypervisor environment.

No open issues 🎉

What changed in this PR

Adds default-off diagnostic disclosure to .NET Hyperlight and LocalCodeAct, aligning their host-tool error handling while preserving failure signaling. This is the independent .NET companion to Python PR #9971.

Changes:

  • Introduces IncludeDetailedErrors options, with generic host-error messages unless explicitly enabled.
  • Captures the policy in execution snapshots and includes it in Hyperlight cache fingerprints.
  • Adds regression coverage and documents trusted opt-in behavior separately from outer-client error handling.

Native Hyperlight backend verification remains outstanding, as noted in the PR description.

File Description
skills/​agent-framework-builder-dotnet/​references/​integrations.md Documents default redaction and trusted opt-in.
dotnet/​tests/​Microsoft.Agents.AI.LocalCodeAct.UnitTests/​LocalExecuteCodeFunctionIntegrationTests.cs Tests caught and uncaught errors and provider policy capture.
dotnet/​tests/​Microsoft.Agents.AI.Hyperlight.UnitTests/​ToolBridgeTests.cs Tests redacted and detailed errors for synchronous and asynchronous tools.
dotnet/​tests/​Microsoft.Agents.AI.Hyperlight.UnitTests/​SandboxExecutorTests.cs Tests policy capture and fingerprint isolation.
dotnet/​tests/​Microsoft.Agents.AI.Hyperlight.IntegrationTests/​CodeActEndToEndTests.cs Adds backend coverage for diagnostic opt-in.
dotnet/​src/​Microsoft.Agents.AI.LocalCodeAct/​README.md Explains LocalCodeAct diagnostic policy and failure behavior.
dotnet/​src/​Microsoft.Agents.AI.LocalCodeAct/​LocalExecuteCodeFunction.cs Captures the standalone function’s diagnostic policy.
dotnet/​src/​Microsoft.Agents.AI.LocalCodeAct/​LocalCodeActProviderOptions.cs Adds the default-off diagnostic option.
dotnet/​src/​Microsoft.Agents.AI.LocalCodeAct/​LocalCodeActProvider.cs Captures provider policy and passes it into run snapshots.
dotnet/​src/​Microsoft.Agents.AI.LocalCodeAct/​Internal/​ProcessBridge.cs Redacts host exception types and messages by default.
dotnet/​src/​Microsoft.Agents.AI.LocalCodeAct/​Internal/​CodeExecutor.cs Carries snapshot policy into the subprocess bridge.
dotnet/​src/​Microsoft.Agents.AI.Hyperlight/​README.md Documents Hyperlight redaction and cache isolation.
dotnet/​src/​Microsoft.Agents.AI.Hyperlight/​Internal/​ToolBridge.cs Redacts tool failures while retaining argument-parse diagnostics.
dotnet/​src/​Microsoft.Agents.AI.Hyperlight/​Internal/​SandboxExecutor.cs Propagates policy, isolates cached configurations, and redacts execution exceptions.
dotnet/​src/​Microsoft.Agents.AI.Hyperlight/​HyperlightCodeActProviderOptions.cs Adds the default-off diagnostic option.

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)): 2cc859732ba4
Model: gpt-5.6-sol

Overview

The PR introduces a default-off detailed-error policy and consistently carries it through LocalCodeAct snapshots, Hyperlight tool callbacks, and Hyperlight cache fingerprints. Its tests cover sync and async tool failures, caught and uncaught LocalCodeAct errors, policy capture, and cache isolation. One residual Hyperlight path remains: initialization and snapshot-restore exceptions bypass the new redaction policy and can still expose backend diagnostics.

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.Hyperlight/Internal/SandboxExecutor.cs

Merged via the queue into microsoft:main with commit d6e8373 Nov 3, 2026
36 checks passed
@eavanvalkenburg
Eduard van Valkenburg (eavanvalkenburg) deleted the dotnet-codeact-error-redaction branch November 3, 2026 17:04

This branch was previously deployed

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

Labels

breaking change Usage: [PRs], Target: all PRs that introduce changes that are not backward compatible 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.

3 participants