{"record":{"id":"d9e10ec62c68d474","repo":"github/copilot-sdk","slug":"copilotclientoptions-workingdirectory-is-not-suppo","errorCode":null,"errorMessage":"CopilotClientOptions.WorkingDirectory is not supported with 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.","messagePattern":"CopilotClientOptions\\.WorkingDirectory is not supported with 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\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Client.cs","lineNumber":253,"sourceCode":"                    \"loads the native runtime into the shared host process, whose single environment block cannot carry \" +\n                    \"per-client values. Set the variables on the host process environment instead.\",\n                    nameof(options));\n            }\n\n            if (options.Telemetry is not null)\n            {\n                throw new ArgumentException(\n                    $\"{nameof(CopilotClientOptions)}.{nameof(CopilotClientOptions.Telemetry)} is not supported with \" +\n                    $\"{nameof(RuntimeConnection)}.{nameof(RuntimeConnection.ForInProcess)}(): telemetry configuration is \" +\n                    \"lowered to environment variables read by native runtime code running in the shared host process, so \" +\n                    \"per-client telemetry cannot be honored in-process. Configure telemetry via the host process \" +\n                    \"environment, or use a child-process transport.\",\n                    nameof(options));\n            }\n\n            if (options.WorkingDirectory is not null)\n            {\n                throw new ArgumentException(\n                    $\"{nameof(CopilotClientOptions)}.{nameof(CopilotClientOptions.WorkingDirectory)} is not supported with \" +\n                    $\"{nameof(RuntimeConnection)}.{nameof(RuntimeConnection.ForInProcess)}(): the in-process transport hosts \" +\n                    \"the native runtime in the shared host process and spawns the worker without a working-directory \" +\n                    \"parameter, so a per-client working directory cannot be honored in-process. Use a child-process \" +\n                    \"transport, or set the process working directory before creating the client.\",\n                    nameof(options));\n            }\n\n            return;\n        }\n\n        if (connection is ChildProcessRuntimeConnection { Environment: not null } && options.Environment is not null)\n        {\n            throw new ArgumentException(\n                $\"Set environment variables via either {nameof(CopilotClientOptions)}.{nameof(CopilotClientOptions.Environment)} \" +\n                $\"or {nameof(ChildProcessRuntimeConnection)}.{nameof(ChildProcessRuntimeConnection.Environment)}, not both. \" +\n                $\"Prefer {nameof(ChildProcessRuntimeConnection)}.{nameof(ChildProcessRuntimeConnection.Environment)} for \" +\n                \"child-process transports.\",","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/dotnet/src/Client.cs#L235-L271","documentation":"CopilotClient throws this ArgumentException when CopilotClientOptions.WorkingDirectory is set with 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. The library throws at construction rather than ignoring the value.","triggerScenarios":"new CopilotClient(options, RuntimeConnection.ForInProcess()) where options.WorkingDirectory is a non-null path. Checked by ValidateEnvironmentOptions during CopilotClient construction.","commonSituations":"Pointing the client at a project directory per workspace in a multi-workspace app; reusing options built for a stdio (child-process) transport after switching to in-process.","solutions":["Set options.WorkingDirectory to null when using ForInProcess().","Call Directory.SetCurrentDirectory(path) (or set the process working directory) before creating the client.","Use RuntimeConnection.ForStdio() if a per-client working directory is required."],"exampleFix":"// before\nvar options = new CopilotClientOptions { WorkingDirectory = @\"C:\\repos\\app\" };\nvar client = new CopilotClient(options, RuntimeConnection.ForInProcess());\n// after\nvar options = new CopilotClientOptions();\nDirectory.SetCurrentDirectory(@\"C:\\repos\\app\");\nvar client = new CopilotClient(options, RuntimeConnection.ForInProcess());","handlingStrategy":"validation","validationCode":"if (connection is InProcessRuntimeConnection && options.WorkingDirectory is not null)\n    throw new InvalidOperationException(\"Use Directory.SetCurrentDirectory or ForStdio for a per-client working directory.\");","typeGuard":"static bool AllowsOptionsWorkingDirectory(RuntimeConnection c) => c is not InProcessRuntimeConnection;","tryCatchPattern":"try { client = new CopilotClient(options, connection); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"WorkingDirectory\")) { Directory.SetCurrentDirectory(options.WorkingDirectory); options.WorkingDirectory = null; client = new CopilotClient(options, connection); }","preventionTips":["Clear WorkingDirectory when using in-process transport","Set process current directory before client creation","Prefer ForStdio when per-client working directories matter"],"tags":["dotnet","configuration","in-process","working-directory"],"backgroundTag":"conflicting-config-options","analyzedSha":"cd8cf15dc3f9e762615790aaed0a771a0f392755","analyzedAt":"2026-09-09T18:32:31.973Z","contentChangedAt":"2026-09-09T18:32:31.973Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}