From 2385effaf3ca44f83f8956d3e318f031788067ae Mon Sep 17 00:00:00 2001 From: MarkXian Date: Sat, 1 Aug 2026 16:52:20 +0800 Subject: [PATCH 1/2] docs(dotnet): clarify working directory fallback --- dotnet/README.md | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/dotnet/README.md b/dotnet/README.md index 1971c2107b..9e5f3e234b 100644 --- a/dotnet/README.md +++ b/dotnet/README.md @@ -84,7 +84,7 @@ new CopilotClient(CopilotClientOptions? options = null) - `Connection` - How to connect to the Copilot runtime. Defaults to `null` (equivalent to `RuntimeConnection.ForStdio()` with the bundled runtime). See "RuntimeConnection" below. - `LogLevel` - Runtime log level. Accepts well-known values `CopilotLogLevel.None`, `Error`, `Warning`, `Info`, `Debug`, `All`. Defaults to null (the runtime's own default). -- `WorkingDirectory` - Working directory for the runtime process. +- `WorkingDirectory` - Working directory for the runtime process. When not set, the spawned runtime inherits the calling application's current working directory. - `BaseDirectory` - Base directory for Copilot data (session state, config, etc.). Sets `COPILOT_HOME` on the spawned runtime process. When not set, the runtime defaults to `~/.copilot`. Useful in restricted environments where only specific directories are writable. Ignored when connecting via `RuntimeConnection.ForUri(...)`. - `EnableRemoteSessions` - Enables remote-session features. - `Environment` - Environment variables to pass to the runtime process. @@ -131,11 +131,34 @@ Create a new conversation session. - `Provider` - Custom API provider configuration (BYOK) - `Streaming` - Enable streaming of response chunks (default: false) - `InfiniteSessions` - Configure automatic context compaction (see below) +- `WorkingDirectory` - Working directory for the session. When not set, the runtime uses its own process working directory. +- `EnableConfigDiscovery` - Enables runtime discovery of supported configuration. Set to `false` to avoid loading project or user configuration for the session. - `EnableSessionStore` - Enables the cross-session store for search and retrieval across sessions. When unset in `CopilotClientMode.CopilotCli`, the runtime default applies (enabled). In `CopilotClientMode.Empty`, defaults to disabled. - `OnPermissionRequest` - Optional handler called before each tool execution to approve or deny it. When omitted, permission requests are emitted as events and left pending for manual resolution. `PermissionHandler.ApproveAll` approves requests when managed settings are disabled and throws when `EnableManagedSettings` is true. Custom handlers can inspect `ManagedApprovalRequired` for human-facing confirmation logic. See [Permission Handling](#permission-handling) section. - `OnUserInputRequest` - Handler for user input requests from the agent (enables ask_user tool). See [User Input Requests](#user-input-requests) section. - `Hooks` - Hook handlers for session lifecycle events. See [Session Hooks](#session-hooks) section. +`CopilotClientOptions.WorkingDirectory` and `SessionConfig.WorkingDirectory` control different working directories. The client option controls the OS working directory for the spawned runtime process. The session option is sent to the runtime as the session working directory. If the session value is `null`, the runtime falls back to its process working directory, so a desktop or debug app may pick up the application's binary directory. + +For a project-neutral chat, set both values to a stable neutral directory and disable config discovery: + +```csharp +var neutralDirectory = Path.GetTempPath(); + +var client = new CopilotClient(new CopilotClientOptions +{ + WorkingDirectory = neutralDirectory +}); + +var session = await client.CreateSessionAsync(new SessionConfig +{ + WorkingDirectory = neutralDirectory, + EnableConfigDiscovery = false +}); +``` + +Use the same `WorkingDirectory` and `EnableConfigDiscovery` values with `ResumeSessionConfig` when resuming the session to keep the context stable. + ##### `ResumeSessionAsync(string sessionId, ResumeSessionConfig? config = null): Task` Resume an existing session. Returns the session with `WorkspacePath` populated if infinite sessions were enabled. From ef95a155837d83dd6d4e6d439c7d0780a13ddb35 Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Tue, 4 Aug 2026 14:05:42 +0000 Subject: [PATCH 2/2] docs: align working directory defaults across SDKs Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- dotnet/README.md | 22 ---------------------- go/README.md | 3 ++- java/README.md | 2 ++ nodejs/README.md | 1 + python/README.md | 1 + rust/README.md | 2 ++ 6 files changed, 8 insertions(+), 23 deletions(-) diff --git a/dotnet/README.md b/dotnet/README.md index 9e5f3e234b..c71ad8fc12 100644 --- a/dotnet/README.md +++ b/dotnet/README.md @@ -132,33 +132,11 @@ Create a new conversation session. - `Streaming` - Enable streaming of response chunks (default: false) - `InfiniteSessions` - Configure automatic context compaction (see below) - `WorkingDirectory` - Working directory for the session. When not set, the runtime uses its own process working directory. -- `EnableConfigDiscovery` - Enables runtime discovery of supported configuration. Set to `false` to avoid loading project or user configuration for the session. - `EnableSessionStore` - Enables the cross-session store for search and retrieval across sessions. When unset in `CopilotClientMode.CopilotCli`, the runtime default applies (enabled). In `CopilotClientMode.Empty`, defaults to disabled. - `OnPermissionRequest` - Optional handler called before each tool execution to approve or deny it. When omitted, permission requests are emitted as events and left pending for manual resolution. `PermissionHandler.ApproveAll` approves requests when managed settings are disabled and throws when `EnableManagedSettings` is true. Custom handlers can inspect `ManagedApprovalRequired` for human-facing confirmation logic. See [Permission Handling](#permission-handling) section. - `OnUserInputRequest` - Handler for user input requests from the agent (enables ask_user tool). See [User Input Requests](#user-input-requests) section. - `Hooks` - Hook handlers for session lifecycle events. See [Session Hooks](#session-hooks) section. -`CopilotClientOptions.WorkingDirectory` and `SessionConfig.WorkingDirectory` control different working directories. The client option controls the OS working directory for the spawned runtime process. The session option is sent to the runtime as the session working directory. If the session value is `null`, the runtime falls back to its process working directory, so a desktop or debug app may pick up the application's binary directory. - -For a project-neutral chat, set both values to a stable neutral directory and disable config discovery: - -```csharp -var neutralDirectory = Path.GetTempPath(); - -var client = new CopilotClient(new CopilotClientOptions -{ - WorkingDirectory = neutralDirectory -}); - -var session = await client.CreateSessionAsync(new SessionConfig -{ - WorkingDirectory = neutralDirectory, - EnableConfigDiscovery = false -}); -``` - -Use the same `WorkingDirectory` and `EnableConfigDiscovery` values with `ResumeSessionConfig` when resuming the session to keep the context stable. - ##### `ResumeSessionAsync(string sessionId, ResumeSessionConfig? config = null): Task` Resume an existing session. Returns the session with `WorkspacePath` populated if infinite sessions were enabled. diff --git a/go/README.md b/go/README.md index bc360253f9..c329fff65f 100644 --- a/go/README.md +++ b/go/README.md @@ -198,7 +198,7 @@ Event types: `SessionLifecycleCreated`, `SessionLifecycleDeleted`, `SessionLifec When `Path` is empty for stdio/tcp, the SDK uses the bundled CLI (or `COPILOT_CLI_PATH` env var). `StdioConnection` and `TCPConnection` accept an optional connection-level `Env`. Set environment variables via **either** the client-level `Env` option or the connection's `Env`, not both (setting both panics); prefer the connection-level `Env`. -- `WorkingDirectory` (string): Working directory for the runtime process +- `WorkingDirectory` (string): Working directory for the runtime process (default: current process working directory) - `BaseDirectory` (string): Base directory for Copilot data (session state, config, etc.). Sets `COPILOT_HOME` on the spawned runtime. When empty, the runtime defaults to `~/.copilot`. Ignored with `URIConnection`. This does **not** affect where the Go SDK extracts the embedded CLI binary; use `embeddedcli.Config.Dir` for the extraction/cache location. - `LogLevel` (string): Log level. When empty (default), the runtime uses its own default level (the SDK does not pass `--log-level`). - `Env` ([]string): Environment variables for the runtime process (default: inherits from current process) @@ -220,6 +220,7 @@ Event types: `SessionLifecycleCreated`, `SessionLifecycleDeleted`, `SessionLifec - `Provider` (\*ProviderConfig): Custom API provider configuration (BYOK). See [Custom Providers](#custom-providers) section. - `Streaming` (*bool): Enable streaming delta events (nil = runtime default) - `InfiniteSessions` (\*InfiniteSessionConfig): Automatic context compaction configuration +- `WorkingDirectory` (string): Working directory for the session (default: runtime process working directory) - `EnableSessionStore` (\*bool): Enables the cross-session store for search and retrieval across sessions. When unset in `ModeCopilotCli`, the runtime default applies (enabled). In `ModeEmpty`, defaults to disabled. - `OnPermissionRequest` (PermissionHandlerFunc): Optional handler called before each tool execution to approve or deny it. When nil, permission requests are emitted as events and left pending for manual resolution. `copilot.PermissionHandler.ApproveAll` approves requests when managed settings are disabled and returns an error when `EnableManagedSettings` is true. Custom handlers can inspect `RequiresManagedApproval()` for human-facing confirmation logic. See [Permission Handling](#permission-handling) section. - `OnUserInputRequest` (UserInputHandler): Handler for user input requests from the agent (enables ask_user tool). See [User Input Requests](#user-input-requests) section. diff --git a/java/README.md b/java/README.md index 1737d82d4a..78ab201381 100644 --- a/java/README.md +++ b/java/README.md @@ -127,6 +127,8 @@ and `setExcludedTools(...)`, prefer the source-qualified filter form `DefaultAgentConfig.setExcludedTools(...)`, use `-` directly. +`CopilotClientOptions.setCwd(...)` sets the runtime process working directory, which otherwise inherits the current process working directory. `SessionConfig.setWorkingDirectory(...)` sets the session working directory, which otherwise defaults to the runtime process working directory. + ## Permission Handling `PermissionHandler.APPROVE_ALL` approves requests when managed settings are disabled. When `enableManagedSettings` is true, it completes exceptionally. Custom handlers can inspect `request.getManagedApprovalRequired()` for human-facing confirmation logic. diff --git a/nodejs/README.md b/nodejs/README.md index 4c430da05c..c56109734f 100644 --- a/nodejs/README.md +++ b/nodejs/README.md @@ -135,6 +135,7 @@ Create a new conversation session. - `tools?: Tool[]` - Custom tools exposed to the CLI. Tools without `handler` are declaration-only and must be resolved via pending tool-call RPCs. - `systemMessage?: SystemMessageConfig` - System message customization (see below) - `infiniteSessions?: InfiniteSessionConfig` - Configure automatic context compaction (see below) +- `workingDirectory?: string` - Working directory for the session (default: runtime process cwd). - `enableSessionStore?: boolean` - Enables the cross-session store for search and retrieval across sessions. When unset in `"copilot-cli"` mode, the runtime default applies (enabled). In `"empty"` mode, defaults to disabled. - `provider?: ProviderConfig` - Custom API provider configuration (BYOK - Bring Your Own Key). See [Custom Providers](#custom-providers) section. - `onPermissionRequest?: PermissionHandler` - Optional handler called before each tool execution to approve or deny it. When omitted, permission requests are emitted as events and left pending for manual resolution. `approveAll` approves requests when managed settings are disabled and throws when `enableManagedSettings` is true. Custom handlers can inspect `managedApprovalRequired` for human-facing confirmation logic. See [Permission Handling](#permission-handling) section. diff --git a/python/README.md b/python/README.md index 0206ad49b3..cc44170549 100644 --- a/python/README.md +++ b/python/README.md @@ -279,6 +279,7 @@ These are passed as keyword arguments to `create_session()`: - `streaming` (bool): Enable streaming delta events - `provider` (ProviderConfig): Custom API provider configuration (BYOK). See [Custom Providers](#custom-providers) section. - `infinite_sessions` (InfiniteSessionConfig): Automatic context compaction configuration +- `working_directory` (str | None): Working directory for the session (default: runtime process working directory). - `enable_session_store` (bool): Enables the cross-session store for search and retrieval across sessions. When unset in `"copilot-cli"` mode, the runtime default applies (enabled). In `"empty"` mode, defaults to disabled. - `on_permission_request` (callable): Optional handler called before each tool execution to approve or deny it. When omitted, permission requests are emitted as events and left pending for manual resolution. `PermissionHandler.approve_all` approves requests when managed settings are disabled and raises an error when `enable_managed_settings` is true. Custom handlers can inspect `managed_approval_required` for human-facing confirmation logic. See [Permission Handling](#permission-handling) section. - `on_user_input_request` (callable): Handler for user input requests from the agent (enables ask_user tool). See [User Input Requests](#user-input-requests) section. diff --git a/rust/README.md b/rust/README.md index eccc29aa27..705166cdd8 100644 --- a/rust/README.md +++ b/rust/README.md @@ -108,6 +108,8 @@ With the default `CliProgram::Resolve`, `Client::start()` resolves the CLI in th Created via `Client::create_session` or `Client::resume_session`. Owns an internal event loop that dispatches CLI callbacks to the focused handler traits you install on `SessionConfig`, and broadcasts session events through `subscribe()`. +`SessionConfig::working_directory` sets the session working directory. When unset, the runtime uses its process working directory. + ```rust,ignore use github_copilot_sdk::MessageOptions;