-
Notifications
You must be signed in to change notification settings - Fork 302
Stabilize the behavior and reliability of ExternalProcessService #1212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
5d83e62 to
fce5e08
Compare
anuchandy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adding notes
core/Azure.Mcp.Core/src/Services/ProcessExecution/ExternalProcessService.cs
Show resolved
Hide resolved
core/Azure.Mcp.Core/src/Services/ProcessExecution/ExternalProcessService.cs
Show resolved
Hide resolved
core/Azure.Mcp.Core/src/Services/ProcessExecution/ExternalProcessService.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the ExternalProcessService to improve reliability, thread safety, and cancellation handling. The service now properly distinguishes between timeouts and cancellations, uses event-driven asynchronous stream reading, and provides comprehensive diagnostic information on failures.
Key Changes
- Refactored
ExecuteAsyncto use Task.WaitAsync for timeout handling instead of synchronous waits with AutoResetEvents - Changed API signature: removed
SetEnvironmentVariablesmethod, replacedcustomPathsparameter withenvironmentVariablesparameter passed directly toExecuteAsync - Implemented
ProcessStreamReaderfor proper async stream capture with event-driven reading - Added extensive documentation and diagnostic information to exceptions via the
Datadictionary
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| IExternalProcessService.cs | Updated interface: renamed parameters, removed SetEnvironmentVariables method, added comprehensive XML documentation |
| ExternalProcessService.cs | Complete rewrite: async stream readers, timeout vs cancellation distinction, safe process inspection utilities, extensive exception diagnostics |
| CommandMetadataSyncTests.cs | Updated to pass NullLogger to ExternalProcessService constructor (now required) |
| AzqrCommand.cs | Updated call to ExecuteAsync with null for environmentVariables parameter |
| AzCommand.cs | Updated calls to ExecuteAsync with null for environmentVariables parameter |
| AzqrCommandTests.cs | Updated mock setup to match new ExecuteAsync signature |
Comments suppressed due to low confidence (1)
servers/Azure.Mcp.Server/tests/Azure.Mcp.Server.UnitTests/Infrastructure/CommandMetadataSyncTests.cs:39
- Missing required parameter in method call. The new
ExecuteAsyncsignature requiresenvironmentVariablesandoperationTimeoutSecondsparameters betweenargumentsandcancellationToken. The call should be:await processService.ExecuteAsync(pwshPath, arguments, null, 300, cancellationToken: TestContext.Current.CancellationToken)or use named arguments for clarity.
var updateResult = await processService.ExecuteAsync(pwshPath, arguments, cancellationToken: TestContext.Current.CancellationToken);
core/Azure.Mcp.Core/src/Services/ProcessExecution/ExternalProcessService.cs
Show resolved
Hide resolved
core/Azure.Mcp.Core/src/Services/ProcessExecution/ExternalProcessService.cs
Outdated
Show resolved
Hide resolved
core/Azure.Mcp.Core/src/Services/ProcessExecution/ExternalProcessService.cs
Show resolved
Hide resolved
core/Azure.Mcp.Core/src/Services/ProcessExecution/ExternalProcessService.cs
Show resolved
Hide resolved
core/Azure.Mcp.Core/src/Services/ProcessExecution/ExternalProcessService.cs
Show resolved
Hide resolved
core/Azure.Mcp.Core/src/Services/ProcessExecution/ExternalProcessService.cs
Show resolved
Hide resolved
core/Azure.Mcp.Core/src/Services/ProcessExecution/ExternalProcessService.cs
Show resolved
Hide resolved
core/Azure.Mcp.Core/src/Services/ProcessExecution/ExternalProcessService.cs
Outdated
Show resolved
Hide resolved
core/Azure.Mcp.Core/src/Services/ProcessExecution/ExternalProcessService.cs
Outdated
Show resolved
Hide resolved
core/Azure.Mcp.Core/src/Services/ProcessExecution/ExternalProcessService.cs
Outdated
Show resolved
Hide resolved
core/Azure.Mcp.Core/src/Services/ProcessExecution/ExternalProcessService.cs
Outdated
Show resolved
Hide resolved
core/Azure.Mcp.Core/src/Services/ProcessExecution/ExternalProcessService.cs
Outdated
Show resolved
Hide resolved
core/Azure.Mcp.Core/src/Services/ProcessExecution/ExternalProcessService.cs
Outdated
Show resolved
Hide resolved
core/Azure.Mcp.Core/src/Services/ProcessExecution/ExternalProcessService.cs
Outdated
Show resolved
Hide resolved
core/Azure.Mcp.Core/src/Services/ProcessExecution/ExternalProcessService.cs
Outdated
Show resolved
Hide resolved
core/Azure.Mcp.Core/src/Services/ProcessExecution/ExternalProcessService.cs
Outdated
Show resolved
Hide resolved
7584df2 to
80955f4
Compare
core/Azure.Mcp.Core/src/Services/ProcessExecution/ExternalProcessService.cs
Show resolved
Hide resolved
core/Azure.Mcp.Core/src/Services/ProcessExecution/ExternalProcessService.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Patrick Hallisey <hallipr@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
80955f4 to
abb8ae1
Compare
What does this PR do?
[Provide a clear, concise description of the changes][Any additional context, screenshots, or information that helps reviewers]GitHub issue number?
[Link to the GitHub issue this PR addresses]Pre-merge Checklist
servers/Azure.Mcp.Server/CHANGELOG.mdand/orservers/Fabric.Mcp.Server/CHANGELOG.mdfor product changes (features, bug fixes, UI/UX, updated dependencies)servers/Azure.Mcp.Server/README.mdand/orservers/Fabric.Mcp.Server/README.mddocumentationeng/scripts/Process-PackageReadMe.ps1. See Package README/servers/Azure.Mcp.Server/docs/azmcp-commands.mdand/or/docs/fabric-commands.md.\eng\scripts\Update-AzCommandsMetadata.ps1to update tool metadata in azmcp-commands.md (required for CI)ToolDescriptionEvaluatorand obtained a score of0.4or more and a top 3 ranking for all related test promptsconsolidated-tools.json/servers/Azure.Mcp.Server/docs/e2eTestPrompts.mdcrypto mining, spam, data exfiltration, etc.)/azp run mcp - pullrequest - liveto run Live Test Pipeline