github/copilot-sdk · error · ArgumentException
CopilotClientOptions.Telemetry is not supported with…
Error message
CopilotClientOptions.Telemetry is not supported with RuntimeConnection.ForInProcess(): telemetry configuration is lowered to environment variables read by native runtime code running in the shared host process, so per-client telemetry cannot be honored in-process. Configure telemetry via the host process environment, or use a child-process transport.
What it means
CopilotClient throws this ArgumentException when CopilotClientOptions.Telemetry is set with RuntimeConnection.ForInProcess(). Telemetry configuration is lowered to environment variables read by the native runtime; in-process that native code runs in the shared host process, so per-client telemetry cannot be honored. The constructor rejects the combination instead of silently misapplying settings.
Solutions
- Set options.Telemetry to null when using ForInProcess().
- Configure telemetry via host process environment variables instead.
- Use RuntimeConnection.ForStdio() (child-process transport) if per-client telemetry configuration is required.
Example fix
// before
var options = new CopilotClientOptions { Telemetry = new TelemetryOptions { Enabled = true } };
var client = new CopilotClient(options, RuntimeConnection.ForInProcess());
// after
var options = new CopilotClientOptions { Telemetry = null };
// configure telemetry via host env vars instead
var client = new CopilotClient(options, RuntimeConnection.ForInProcess()); Defensive patterns
Strategy: validation
Validate before calling
if (connection is InProcessRuntimeConnection && options.Telemetry is not null)
throw new InvalidOperationException("Configure telemetry via host process env for in-process transport."); Type guard
static bool AllowsOptionsTelemetry(RuntimeConnection c) => c is not InProcessRuntimeConnection;
Try / catch
try { client = new CopilotClient(options, connection); }
catch (ArgumentException ex) when (ex.Message.Contains("Telemetry")) { options.Telemetry = null; client = new CopilotClient(options, connection); } Prevention
- Null out telemetry settings when switching to in-process
- Centralize telemetry config in host environment
- Document transport restrictions next to options construction
When it happens
Trigger: new CopilotClient(options, RuntimeConnection.ForInProcess()) where options.Telemetry is non-null. Checked by ValidateEnvironmentOptions during CopilotClient construction.
Common situations: Reusing the same options object for stdio and in-process connections; copying configuration that included telemetry settings when migrating to in-process transport.
Understand the failure class
Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.
Related errors
- CopilotClientOptions.Environment is not supported with…
- CopilotClientOptions.WorkingDirectory is not supported with…
- telemetry is not supported with…
- CopilotClientOptions.
- Unsupported RuntimeConnection type
AI-assisted analysis of github/copilot-sdk@cd8cf15dc3 (2026-09-09).
Data as JSON: /api/errors/70e4be71a0fe9cf2.
Report an issue: GitHub.
Appendix: source
Thrown at dotnet/src/Client.cs:242
/// telemetry options that lower to environment variables are rejected there.
/// </summary>
private static void ValidateEnvironmentOptions(CopilotClientOptions options, RuntimeConnection connection)
{
if (connection is InProcessRuntimeConnection)
{
if (options.Environment is not null)
{
throw new ArgumentException(
$"{nameof(CopilotClientOptions)}.{nameof(CopilotClientOptions.Environment)} is not supported with " +
$"{nameof(RuntimeConnection)}.{nameof(RuntimeConnection.ForInProcess)}(): the in-process transport " +
"loads the native runtime into the shared host process, whose single environment block cannot carry " +
"per-client values. Set the variables on the host process environment instead.",
nameof(options));
}
if (options.Telemetry is not null)
{
throw new ArgumentException(
$"{nameof(CopilotClientOptions)}.{nameof(CopilotClientOptions.Telemetry)} is not supported with " +
$"{nameof(RuntimeConnection)}.{nameof(RuntimeConnection.ForInProcess)}(): telemetry configuration is " +
"lowered to environment variables read by native runtime code running in the shared host process, so " +
"per-client telemetry cannot be honored in-process. Configure telemetry via the host process " +
"environment, or use a child-process transport.",
nameof(options));
}
if (options.WorkingDirectory is not null)
{
throw new ArgumentException(
$"{nameof(CopilotClientOptions)}.{nameof(CopilotClientOptions.WorkingDirectory)} is not supported with " +
$"{nameof(RuntimeConnection)}.{nameof(RuntimeConnection.ForInProcess)}(): the in-process transport hosts " +
"the native runtime in the shared host process and spawns the worker without a working-directory " +
"parameter, so a per-client working directory cannot be honored in-process. Use a child-process " +
"transport, or set the process working directory before creating the client.",
nameof(options));
}View on GitHub (pinned to cd8cf15dc3)