{"record":{"id":"8a61ba1cb7e867c6","repo":"github/copilot-sdk","slug":"env-is-not-supported-with-runtimeconnection-for-in","errorCode":null,"errorMessage":"env is not supported with RuntimeConnection.for_inprocess(): 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.","messagePattern":"env is not supported with RuntimeConnection\\.for_inprocess\\(\\): 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\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/copilot/client.py","lineNumber":1490,"sourceCode":"    raise ValueError(\n        f\"Invalid {_DEFAULT_CONNECTION_ENV_VAR}={value!r}. Expected 'inprocess', 'stdio', or unset.\"\n    )\n\n\ndef _validate_environment_options(\n    options: _CopilotClientOptions, connection: RuntimeConnection\n) -> None:\n    \"\"\"Validate env/telemetry/working-directory options against the transport.\n\n    Per-client environment is only representable for child-process transports\n    (each client owns its own OS process). The in-process (FFI) transport loads\n    the native runtime into the shared host process, whose single environment\n    block and process-global working directory cannot carry per-client values,\n    so options that lower to them are rejected there (fail loud, not silent).\n    \"\"\"\n    if isinstance(connection, InProcessRuntimeConnection):\n        if options.env is not None:\n            raise ValueError(\n                \"env is not supported with RuntimeConnection.for_inprocess(): the \"\n                \"in-process transport loads the native runtime into the shared host \"\n                \"process, whose single environment block cannot carry per-client \"\n                \"values. Set the variables on the host process environment instead.\"\n            )\n        if options.telemetry is not None:\n            raise ValueError(\n                \"telemetry is not supported with RuntimeConnection.for_inprocess(): \"\n                \"telemetry configuration is lowered to environment variables read by \"\n                \"native runtime code running in the shared host process, so per-client \"\n                \"telemetry cannot be honored in-process. Configure telemetry via the \"\n                \"host process environment, or use a child-process transport.\"\n            )\n        if options.working_directory is not None:\n            raise ValueError(\n                \"working_directory is not supported with RuntimeConnection.for_inprocess(): \"\n                \"the native runtime shares the host process working directory, so a \"\n                \"per-client working directory cannot be honored in-process. Use a \"","sourceCodeStart":1472,"sourceCodeEnd":1508,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/python/copilot/client.py#L1472-L1508","documentation":"The in-process transport loads the native runtime into the shared host process, which has a single environment block that cannot carry per-client values. Passing options.env while using RuntimeConnection.for_inprocess() is therefore rejected with ValueError so the misconfiguration fails loud instead of being silently ignored.","triggerScenarios":"Creating CopilotClient with RuntimeConnection.for_inprocess() and a non-None env dict in _CopilotClientOptions.","commonSituations":"Migrating code from a stdio/child-process transport to in-process without removing env customization; trying to inject API keys per-client in embedded hosts.","solutions":["Remove the env option and set the needed variables in the host process environment before creating the client","Switch to a child-process transport (RuntimeConnection.for_stdio()) if per-client env isolation is required"],"exampleFix":"// before\nclient = CopilotClient(connection=RuntimeConnection.for_inprocess(), env={\"GITHUB_TOKEN\": t})\n// after\nos.environ[\"GITHUB_TOKEN\"] = t\nclient = CopilotClient(connection=RuntimeConnection.for_inprocess())","handlingStrategy":"validation","validationCode":"if isinstance(conn, InProcessRuntimeConnection) and opts.env is not None:\n    raise ValueError(\"env is unsupported for in-process; use host process environment\")","typeGuard":"def supports_client_env(conn) -> bool:\n    return not isinstance(conn, InProcessRuntimeConnection)","tryCatchPattern":"try:\n    client = CopilotClient(connection=conn, env=env)\nexcept ValueError as e:\n    if \"env is not supported\" in str(e):\n        os.environ.update(env); env = None\n        client = CopilotClient(connection=conn)","preventionTips":["Keep an options builder that drops per-process options for in-process transports","Document transport choice centrally in one factory function","Test client construction with each transport in CI"],"tags":["python","in-process","environment","configuration"],"backgroundTag":"unsupported-operation","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"}