{"record":{"id":"b622bd480a2504c0","repo":"github/copilot-sdk","slug":"workingdirectory-is-not-supported-with-inprocessco","errorCode":null,"errorMessage":"WorkingDirectory is not supported with InProcessConnection: the native runtime shares the host process working directory. Use a child-process transport, or set the process working directory before creating the client.","messagePattern":"WorkingDirectory is not supported with InProcessConnection: the native runtime shares the host process working directory\\. Use a child-process transport, or set the process working directory before creating the client\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/client.go","lineNumber":114,"sourceCode":"}\n\n// validateEnvironmentOptions enforces the transport-specific rules for\n// per-client environment, working directory, and telemetry. It panics (fails\n// loud) on a misconfiguration, matching the other SDKs.\n//\n// The in-process transport loads the native runtime into this process, whose\n// single environment block and process-global working directory cannot carry\n// per-client values, and whose telemetry lowers to shared process-global env\n// vars — so options that depend on them are rejected there. Child-process\n// transports each own their OS process, so per-connection env is allowed, but\n// setting it in both the client-level option and the connection is rejected.\nfunc validateEnvironmentOptions(connection RuntimeConnection, opts *ClientOptions) {\n\tif _, ok := connection.(InProcessConnection); ok {\n\t\tif opts.Env != nil {\n\t\t\tpanic(\"Env is not supported with InProcessConnection: 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.\")\n\t\t}\n\t\tif opts.WorkingDirectory != \"\" {\n\t\t\tpanic(\"WorkingDirectory is not supported with InProcessConnection: the native runtime shares the host process working directory. Use a child-process transport, or set the process working directory before creating the client.\")\n\t\t}\n\t\tif opts.Telemetry != nil {\n\t\t\tpanic(\"Telemetry is not supported with InProcessConnection: 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.\")\n\t\t}\n\t\treturn\n\t}\n\n\tif cp, ok := connection.(childProcessConnection); ok {\n\t\tif cp.connEnv() != nil && opts.Env != nil {\n\t\t\tpanic(\"Set environment variables via either the client-level Env option or the connection's Env, not both. Prefer the connection-level Env for child-process transports.\")\n\t\t}\n\t}\n}\n\n// Client manages the connection to the Copilot CLI server and provides session management.\n//\n// The Client can either spawn a CLI server process or connect to an existing server.\n// It handles JSON-RPC communication, session lifecycle, tool execution, and permission requests.","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/go/client.go#L96-L132","documentation":"NewClient panics when ClientOptions.WorkingDirectory is set while using InProcessConnection. The in-process transport loads the native runtime into the shared host process, so the runtime necessarily shares the host's working directory; a per-client working directory cannot be honored. The library fails loud at client construction instead of silently ignoring the option.","triggerScenarios":"Calling NewClient with Options.Connection set to InProcessConnection{} (or COPILOT_CLI_CONNECTION=inprocess) while ClientOptions.WorkingDirectory is a non-empty string. Panics inside validateEnvironmentOptions (go/client.go:114), reached via NewClient.","commonSituations":"Code that previously used the default stdio child-process transport and set WorkingDirectory for the child is switched to the in-process transport for startup performance; the stale WorkingDirectory option now trips the guard.","solutions":["Remove the WorkingDirectory option when using InProcessConnection.","If an isolated working directory is required, switch the connection to StdioConnection{} (child-process transport).","Set os.Chdir on the host process before creating the client if you truly need a different working directory in-process (note this is process-global)."],"exampleFix":"// before\nclient := clientpkg.NewClient(&clientpkg.Options{\n    Connection:      clientpkg.InProcessConnection{},\n    WorkingDirectory: \"/tmp/agent-work\",\n})\n// after\nclient := clientpkg.NewClient(&clientpkg.Options{\n    Connection: clientpkg.InProcessConnection{},\n})\n// or, keep the working directory by using the child-process transport:\nclient := clientpkg.NewClient(&clientpkg.Options{\n    Connection:      clientpkg.StdioConnection{},\n    WorkingDirectory: \"/tmp/agent-work\",\n})","handlingStrategy":"validation","validationCode":"if _, isInProc := opts.Connection.(clientpkg.InProcessConnection); isInProc && opts.WorkingDirectory != \"\" {\n    return fmt.Errorf(\"WorkingDirectory is unsupported with InProcessConnection\")\n}","typeGuard":"func isInProcess(c clientpkg.RuntimeConnection) bool { _, ok := c.(clientpkg.InProcessConnection); return ok }","tryCatchPattern":null,"preventionTips":["Keep transport-specific options grouped per transport in your config layer.","Audit option structs when switching transports between stdio and in-process.","Wrap NewClient in a small constructor that validates options for the chosen connection type first."],"tags":["go","panic","in-process-transport","configuration"],"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"}