Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 27, 2026

Code samples showing CliUrl usage were throwing ArgumentException due to missing UseStdio = false. Since UseStdio defaults to true and is mutually exclusive with CliUrl, the examples failed validation in the CopilotClient constructor.

Changes

  • dotnet/src/Client.cs: Updated XML doc example to include UseStdio = false
  • docs/getting-started.md: Updated .NET example to include UseStdio = false

Example

Before (throws exception):

var client = new CopilotClient(new CopilotClientOptions { CliUrl = "localhost:3000" });

After (correct):

var client = new CopilotClient(new CopilotClientOptions { CliUrl = "localhost:3000", UseStdio = false });
Original prompt

This section details on the original issue you should resolve

<issue_title>.NET Code sample for using CLI server mode is incorrect</issue_title>
<issue_description>I got the following error when using CLI server mode

Unhandled exception. System.ArgumentException: CliUrl is mutually exclusive with UseStdio and CliPath at GitHub.Copilot.SDK.CopilotClient..ctor(CopilotClientOptions options) at Program.<Main>$(String[] args) in C:\Users\zhiyuanliang\Desktop\AI\CopilotDemo\Program.cs:line 44 at Program.<Main>(String[] args)

The correct code should look like:

await using var client = new CopilotClient(new CopilotClientOptions
{
    CliUrl = $"localhost:{port}",
    UseStdio = false
});

</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: friggeri <106686+friggeri@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix .NET CLI server mode code sample Fix .NET CLI server mode code samples - add missing UseStdio = false Jan 27, 2026
Copilot AI requested a review from friggeri January 27, 2026 18:09
@friggeri friggeri marked this pull request as ready for review January 27, 2026 18:55
@friggeri friggeri requested a review from a team as a code owner January 27, 2026 18:55
Copilot AI review requested due to automatic review settings January 27, 2026 18:55
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes broken .NET “CLI server mode” code samples by explicitly setting UseStdio = false when CliUrl is provided, avoiding the ArgumentException thrown by CopilotClient option validation.

Changes:

  • Update .NET XML doc example in CopilotClient to include UseStdio = false when using CliUrl
  • Update .NET snippet in docs/getting-started.md to include UseStdio = false

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
dotnet/src/Client.cs Updates the XML documentation example to provide valid CopilotClientOptions when using CliUrl.
docs/getting-started.md Fixes the .NET getting-started example for connecting to an existing CLI server via CliUrl.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 70 to 75
/// var client = new CopilotClient();
///
/// // Connect to an existing server
/// var client = new CopilotClient(new CopilotClientOptions { CliUrl = "localhost:3000" });
/// var client = new CopilotClient(new CopilotClientOptions { CliUrl = "localhost:3000", UseStdio = false });
///
/// // Custom CLI path with specific log level
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The <example><code> block declares var client multiple times, which won’t compile if a user copies the whole snippet as-is. Consider either splitting these into separate <code> examples or using distinct variable names (e.g., defaultClient, externalClient, etc.).

See below for a potential fix:

    /// var defaultClient = new CopilotClient();
    ///
    /// // Connect to an existing server
    /// var existingServerClient = new CopilotClient(new CopilotClientOptions { CliUrl = "localhost:3000", UseStdio = false });
    ///
    /// // Custom CLI path with specific log level
    /// var customPathClient = new CopilotClient(new CopilotClientOptions

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

✅ Cross-SDK Consistency Review

I've reviewed this PR for consistency across all four SDK implementations (Node.js, Python, Go, and .NET).

Summary

The fix is correct and maintains consistency. The .NET SDK has the same mutually exclusive option enforcement as the other SDKs, and this PR correctly updates the documentation examples.

Analysis

All four SDKs implement identical validation logic:

SDK Default UseStdio Validation Auto-disable when URL provided
Node.js true ✅ Throws error if cliUrl + useStdio: true ✅ Yes (line 150)
Python true ✅ Raises ValueError if conflict ❌ No
Go true ✅ Panics if conflict ✅ Yes (line 124)
.NET true (Types.cs:31) ✅ Throws ArgumentException if conflict ❌ No

Why This PR Was Needed

The .NET SDK throws an ArgumentException when:

  • CliUrl is set (non-empty string)
  • UseStdio is true (the default)

Before this PR: Documentation examples showed only CliUrl, which would fail validation because UseStdio defaults to true.

After this PR: Examples explicitly set UseStdio = false, which:

  1. Passes validation ✅
  2. Makes the mutual exclusivity explicit for developers ✅
  3. Matches the documented behavior ✅

Documentation Consistency

The docs/getting-started.md file now shows all four languages with their respective conventions:

  • Node.js/TypeScript: Auto-sets useStdio: false when cliUrl is provided (no explicit setting needed)
  • Python: Only shows cli_url (relies on default or auto-handling)
  • Go: Auto-sets UseStdio = false when CLIUrl is provided (no explicit setting needed)
  • .NET: Explicitly sets UseStdio = false ✅ (required due to validation)

Recommendation

This PR correctly addresses a documentation bug specific to .NET's stricter validation. The fix maintains cross-SDK consistency while respecting language-specific implementation details. ✅ Approved from consistency perspective.

Optional enhancement: Consider updating Python/Go documentation examples to also explicitly show the use_stdio / UseStdio setting for clarity, even though they auto-handle it.

AI generated by SDK Consistency Review Agent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.NET Code sample for using CLI server mode is incorrect

2 participants