Skip to content

Commit 5c44dda

Browse files
Clarify legacy ask-user handler documentation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent ca7ecc4 commit 5c44dda

10 files changed

Lines changed: 25 additions & 20 deletions

File tree

dotnet/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ Create a new conversation session.
135135
- `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.
136136
- `GitHubTokenProvider` - Acquires session-scoped GitHub tokens on demand. Return `GitHubTokenProviderResult.FromToken` with a positive `ExpiresIn` value (production GitHub tokens typically use `8 * 60 * 60` seconds), or `GitHubTokenProviderResult.Cancel()`. Cannot be combined with `GitHubToken`.
137137
- `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 `EnableManaged设置` is true. Custom handlers can inspect `ManagedApprovalRequired` for human-facing confirmation logic. See [Permission Handling](#permission-handling) section.
138-
- `OnUserInputRequest` - Handler for user input requests from the agent (enables ask_user tool). See [User Input Requests](#user-input-requests) section.
138+
- `OnUserInputRequest` - Handler for legacy question-and-answer requests from the agent. Enables the legacy `ask_user` tool. See [User Input Requests](#user-input-requests) section.
139139
- `AskUserVariant` - Selects the model-facing `ask_user` tool shape. Defaults to `AskUserVariant.Legacy`; use `AskUserVariant.Elicitation` with `OnElicitationRequest`.
140140
- `Hooks` - Hook handlers for session lifecycle events. See [Session Hooks](#session-hooks) section.
141141

@@ -873,7 +873,7 @@ To let a specific custom tool bypass the permission prompt entirely, set `SkipPe
873873

874874
## User Input Requests
875875

876-
Enable the agent to ask questions to the user using the `ask_user` tool by providing an `OnUserInputRequest` handler:
876+
Enable the legacy question-and-answer `ask_user` tool by providing an `OnUserInputRequest` handler:
877877

878878
```csharp
879879
var session = await client.CreateSessionAsync(new SessionConfig

go/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ Event types: `SessionLifecycleCreated`, `SessionLifecycleDeleted`, `SessionLifec
224224
- `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.
225225
- `GitHubTokenProvider` (GitHubTokenProvider): Acquires session-scoped GitHub tokens on demand. Return `GitHubTokenResult` with a positive `ExpiresIn` value (production GitHub tokens typically use `8 * 60 * 60` seconds), or `GitHubTokenCancelled`. Cannot be combined with `GitHubToken`.
226226
- `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 `EnableManaged设置` is true. Custom handlers can inspect `RequiresManagedApproval()` for human-facing confirmation logic. See [Permission Handling](#permission-handling) section.
227-
- `OnUserInputRequest` (UserInputHandler): Handler for user input requests from the agent (enables ask_user tool). See [User Input Requests](#user-input-requests) section.
227+
- `OnUserInputRequest` (UserInputHandler): Handler for legacy question-and-answer requests from the agent. Enables the legacy `ask_user` tool. See [User Input Requests](#user-input-requests) section.
228228
- `AskUserVariant` (AskUserVariant): Selects the model-facing shape of the `ask_user` tool. The zero value preserves legacy behavior; use `AskUserVariantElicitation` with `OnElicitationRequest`.
229229
- `Hooks` (\*SessionHooks): Hook handlers for session lifecycle events. See [Session Hooks](#session-hooks) section.
230230
- `Commands` ([]CommandDefinition): Slash-commands registered for this session. See [Commands](#commands) section.
@@ -772,7 +772,7 @@ To let a specific custom tool bypass the permission prompt entirely, set `SkipPe
772772

773773
## User Input Requests
774774

775-
Enable the agent to ask questions to the user using the `ask_user` tool by providing an `OnUserInputRequest` handler:
775+
Enable the legacy question-and-answer `ask_user` tool by providing an `OnUserInputRequest` handler:
776776

777777
```go
778778
session, err := client.CreateSession(context.Background(), &copilot.SessionConfig{

go/types.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,7 +1350,8 @@ type SessionConfig struct {
13501350
// GitHubTokenProvider acquires session-scoped GitHub tokens on demand. It
13511351
// cannot be combined with GitHubToken.
13521352
GitHubTokenProvider GitHubTokenProvider
1353-
// OnUserInputRequest is a handler for user input requests from the agent (enables ask_user tool)
1353+
// OnUserInputRequest handles legacy question-and-answer requests from the agent
1354+
// and enables the legacy ask_user tool.
13541355
OnUserInputRequest UserInputHandler
13551356
// AskUserVariant selects the model-facing shape of the ask_user tool.
13561357
// The zero value preserves legacy behavior. AskUserVariantElicitation also
@@ -1928,7 +1929,8 @@ type ResumeSessionConfig struct {
19281929
// OnMCPAuthRequest is an optional handler for MCP OAuth requests from MCP servers.
19291930
// See SessionConfig.OnMCPAuthRequest.
19301931
OnMCPAuthRequest MCPAuthHandler
1931-
// OnUserInputRequest is a handler for user input requests from the agent (enables ask_user tool)
1932+
// OnUserInputRequest handles legacy question-and-answer requests from the agent
1933+
// and enables the legacy ask_user tool.
19321934
OnUserInputRequest UserInputHandler
19331935
// AskUserVariant selects the model-facing shape of the ask_user tool.
19341936
// The zero value preserves legacy behavior. AskUserVariantElicitation also

java/sdk/src/main/java/com/github/copilot/rpc/SessionConfig.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,9 @@ public UserInputHandler getOnUserInputRequest() {
919919
/**
920920
* Sets a handler for user input requests from the agent.
921921
* <p>
922-
* When provided, enables the ask_user tool for the agent to request user input.
922+
* When provided, enables the legacy question-and-answer form of the
923+
* {@code ask_user} tool. Use an elicitation handler with
924+
* {@link AskUserVariant#ELICITATION}.
923925
*
924926
* @param onUserInputRequest
925927
* the user input handler

nodejs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,7 @@ To let a specific custom tool bypass the permission prompt entirely, set `skipPe
960960

961961
## User Input Requests
962962

963-
Enable the agent to ask questions to the user using the `ask_user` tool by providing an `onUserInputRequest` handler:
963+
Enable the legacy question-and-answer `ask_user` tool by providing an `onUserInputRequest` handler:
964964

965965
```typescript
966966
const session = await client.createSession({

nodejs/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1265,7 +1265,7 @@ export const defaultJoinSessionPermissionHandler: PermissionHandler =
12651265
// ============================================================================
12661266

12671267
/**
1268-
* Request for user input from the agent (enables ask_user tool)
1268+
* Legacy question-and-answer request from the `ask_user` tool.
12691269
*/
12701270
export interface UserInputRequest {
12711271
/**

python/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ These are passed as keyword arguments to `create_session()`:
283283
- `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.
284284
- `github_token_provider` (callable): Acquires rotating, session-scoped GitHub tokens. Token results require a positive `expiresIn` value in seconds remaining when the callback completes; production tokens typically last eight hours. Cannot be combined with `github_token`.
285285
- `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.
286-
- `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.
286+
- `on_user_input_request` (callable): Handler for legacy question-and-answer requests from the agent. Enables the legacy `ask_user` tool. See [User Input Requests](#user-input-requests) section.
287287
- `ask_user_variant` (`"legacy"` | `"elicitation"`): Selects the model-facing shape of the `ask_user` tool. Defaults to `"legacy"`; use `"elicitation"` with `on_elicitation_request`. Re-supply this option when cold-resuming a session.
288288
- `hooks` (SessionHooks): Hook handlers for session lifecycle events. See [Session Hooks](#session-hooks) section.
289289

@@ -900,7 +900,7 @@ To let a specific custom tool bypass the permission prompt entirely, set `skip_p
900900

901901
## User Input Requests
902902

903-
Enable the agent to ask questions to the user using the `ask_user` tool by providing an `on_user_input_request` handler:
903+
Enable the legacy question-and-answer `ask_user` tool by providing an `on_user_input_request` handler:
904904

905905
```python
906906
async def handle_user_input(request, invocation):

python/copilot/session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ class McpAuthContext(TypedDict):
504504

505505

506506
class UserInputRequest(TypedDict, total=False):
507-
"""Request for user input from the agent (enables ask_user tool)"""
507+
"""Legacy question-and-answer request from the ask_user tool."""
508508

509509
question: str
510510
choices: list[str]

rust/src/handler.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,11 @@ pub trait McpAuthHandler: Send + Sync + 'static {
294294
) -> McpAuthResult;
295295
}
296296

297-
/// Handler for `user_input.requested` events from the `ask_user` tool.
297+
/// Handler for `user_input.requested` events from the legacy question-and-answer
298+
/// `ask_user` variant.
298299
///
299-
/// When unset, `requestUserInput: false` goes on the wire and the
300-
/// `ask_user` tool is disabled for the session.
300+
/// When unset, `requestUserInput: false` goes on the wire, so this client
301+
/// cannot handle legacy user-input requests.
301302
#[async_trait]
302303
pub trait UserInputHandler: Send + Sync + 'static {
303304
/// Answer a question on behalf of the user. Return `None` to signal

rust/src/types.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2198,9 +2198,9 @@ pub struct SessionConfig {
21982198
/// Optional MCP OAuth request handler. When set, the SDK can satisfy MCP
21992199
/// server OAuth requests with host-acquired token data or cancellation.
22002200
pub mcp_auth_handler: Option<Arc<dyn McpAuthHandler>>,
2201-
/// Optional user-input handler. When `None`,
2202-
/// `requestUserInput: false` goes on the wire and the `ask_user`
2203-
/// tool is disabled.
2201+
/// Optional handler for the legacy question-and-answer `ask_user` variant.
2202+
/// When `None`, `requestUserInput: false` goes on the wire, so this client
2203+
/// cannot handle legacy user-input requests.
22042204
pub user_input_handler: Option<Arc<dyn UserInputHandler>>,
22052205
/// Optional exit-plan-mode handler. When `None`,
22062206
/// `requestExitPlanMode: false` goes on the wire.
@@ -2676,8 +2676,8 @@ impl SessionConfig {
26762676
self
26772677
}
26782678

2679-
/// Install a [`UserInputHandler`]. Required for the `ask_user` tool
2680-
/// to be enabled.
2679+
/// Install a [`UserInputHandler`] for the legacy question-and-answer
2680+
/// `ask_user` variant.
26812681
pub fn with_user_input_handler(mut self, handler: Arc<dyn UserInputHandler>) -> Self {
26822682
self.user_input_handler = Some(handler);
26832683
self

0 commit comments

Comments
 (0)