You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: dotnet/README.md
+132Lines changed: 132 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -488,6 +488,95 @@ var safeLookup = AIFunctionFactory.Create(
488
488
});
489
489
```
490
490
491
+
### Commands
492
+
493
+
Register slash commands so that users of the CLI's TUI can invoke custom actions via `/commandName`. Each command has a `Name`, optional `Description`, and a `Handler` called when the user executes it.
Console.WriteLine($"Deploying with args: {context.Args}");
509
+
// Do work here — any thrown error is reported back to the CLI
510
+
},
511
+
},
512
+
],
513
+
});
514
+
```
515
+
516
+
When the user types `/deploy staging` in the CLI, the SDK receives a `command.execute` event, routes it to your handler, and automatically responds to the CLI. If the handler throws, the error message is forwarded.
517
+
518
+
Commands are sent to the CLI on both `CreateSessionAsync` and `ResumeSessionAsync`, so you can update the command set when resuming.
519
+
520
+
### UI Elicitation
521
+
522
+
When the session has elicitation support — either from the CLI's TUI or from another client that registered an `OnElicitationRequest` handler (see [Elicitation Requests](#elicitation-requests)) — the SDK can request interactive form dialogs from the user. The `session.Ui` object provides convenience methods built on a single generic elicitation RPC.
523
+
524
+
> **Capability check:** Elicitation is only available when at least one connected participant advertises support. Always check `session.Capabilities.Ui?.Elicitation` before calling UI methods — this property updates automatically as participants join and leave.
All UI methods throw if elicitation is not supported by the host.
579
+
491
580
### System Message Customization
492
581
493
582
Control the system prompt using `SystemMessage` in session config:
@@ -812,6 +901,49 @@ var session = await client.CreateSessionAsync(new SessionConfig
812
901
-`OnSessionEnd` - Cleanup or logging when session ends.
813
902
-`OnErrorOccurred` - Handle errors with retry/skip/abort strategies.
814
903
904
+
## Elicitation Requests
905
+
906
+
Register an `OnElicitationRequest` handler to let your client act as an elicitation provider — presenting form-based UI dialogs on behalf of the agent. When provided, the server notifies your client whenever a tool or MCP server needs structured user input.
When `OnElicitationRequest` is provided, the SDK sends `RequestElicitation = true` during session create/resume, which enables `session.Capabilities.Ui.Elicitation` on the session.
940
+
941
+
In multi-client scenarios:
942
+
943
+
- If no connected client was previously providing an elicitation capability, but a new client joins that can, all clients will receive a `capabilities.changed` event to notify them that elicitation is now possible. The SDK automatically updates `session.Capabilities` when these events arrive.
944
+
- Similarly, if the last elicitation provider disconnects, all clients receive a `capabilities.changed` event indicating elicitation is no longer available.
945
+
- The server fans out elicitation requests to **all** connected clients that registered a handler — the first response wins.
0 commit comments