Upstream sync: Port Commands, Elicitation, Session Capabilities, and getSessionMetadata (27 commits)#52
Merged
brunoborges merged 7 commits intomainfrom Apr 6, 2026
Conversation
Agent-Logs-Url: https://github.com/github/copilot-sdk-java/sessions/16d575c4-83f4-4d20-99d9-b48635b3791d Co-authored-by: edburns <75821+edburns@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/copilot-sdk-java/sessions/16d575c4-83f4-4d20-99d9-b48635b3791d Co-authored-by: edburns <75821+edburns@users.noreply.github.com>
src/main/java/com/github/copilot/sdk/json/CommandHandler.java
Dismissed
Show dismissed
Hide dismissed
src/main/java/com/github/copilot/sdk/json/ElicitationHandler.java
Dismissed
Show dismissed
Hide dismissed
…c example Agent-Logs-Url: https://github.com/github/copilot-sdk-java/sessions/16d575c4-83f4-4d20-99d9-b48635b3791d Co-authored-by: edburns <75821+edburns@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Sync upstream with 27 new commits
Upstream sync: Port Commands, Elicitation, Session Capabilities, and getSessionMetadata (27 commits)
Apr 6, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Ports upstream changes to add slash commands, elicitation (UI dialogs), session capability reporting/updates, and efficient per-session metadata lookup.
Changes:
- Add command registration and
command.executeevent handling, including wire-format support in create/resume requests. - Add elicitation support (incoming handler + outgoing
session.getUi()API) and session capabilities populated from create/resume +capabilities.changed. - Add
CopilotClient.getSessionMetadata(sessionId)plus tests and documentation updates (including required CLI version bump).
Show a summary per file
| File | Description |
|---|---|
| src/test/java/com/github/copilot/sdk/ElicitationTest.java | Adds unit tests for elicitation DTOs, cloning behavior, and request flags. |
| src/test/java/com/github/copilot/sdk/CopilotSessionTest.java | Adds snapshot test for getSessionMetadata(sessionId) behavior. |
| src/test/java/com/github/copilot/sdk/CommandsTest.java | Adds unit tests for command DTOs, cloning behavior, and wire serialization. |
| src/site/markdown/index.md | Updates documented minimum Copilot CLI version. |
| src/site/markdown/advanced.md | Documents slash commands, elicitation, capabilities, and session-metadata-by-id. |
| src/main/java/com/github/copilot/sdk/SessionRequestBuilder.java | Includes commands + requestElicitation in create/resume requests; registers handlers on session. |
| src/main/java/com/github/copilot/sdk/json/SessionUiCapabilities.java | Introduces UI capability flag model (elicitation). |
| src/main/java/com/github/copilot/sdk/json/SessionUiApi.java | Introduces UI API surface for elicitation convenience methods. |
| src/main/java/com/github/copilot/sdk/json/SessionConfig.java | Adds commands + elicitation handler to session config (+ clone support). |
| src/main/java/com/github/copilot/sdk/json/SessionCapabilities.java | Adds capabilities container DTO. |
| src/main/java/com/github/copilot/sdk/json/ResumeSessionResponse.java | Extends resume response to include capabilities. |
| src/main/java/com/github/copilot/sdk/json/ResumeSessionRequest.java | Extends resume request to include commands + requestElicitation. |
| src/main/java/com/github/copilot/sdk/json/ResumeSessionConfig.java | Adds commands + elicitation handler to resume config (+ clone support). |
| src/main/java/com/github/copilot/sdk/json/InputOptions.java | Adds options DTO for ui.input(...). |
| src/main/java/com/github/copilot/sdk/json/GetSessionMetadataResponse.java | Adds RPC response wrapper for metadata-by-id call. |
| src/main/java/com/github/copilot/sdk/json/ElicitationSchema.java | Adds JSON-schema DTO used for elicitation dialogs. |
| src/main/java/com/github/copilot/sdk/json/ElicitationResultAction.java | Adds action enum for elicitation results. |
| src/main/java/com/github/copilot/sdk/json/ElicitationResult.java | Adds elicitation result DTO. |
| src/main/java/com/github/copilot/sdk/json/ElicitationParams.java | Adds outgoing elicitation request params DTO. |
| src/main/java/com/github/copilot/sdk/json/ElicitationHandler.java | Adds functional interface for incoming elicitation handling. |
| src/main/java/com/github/copilot/sdk/json/ElicitationContext.java | Adds context DTO for incoming elicitation requests. |
| src/main/java/com/github/copilot/sdk/json/CreateSessionResponse.java | Extends create response to include capabilities. |
| src/main/java/com/github/copilot/sdk/json/CreateSessionRequest.java | Extends create request to include commands + requestElicitation. |
| src/main/java/com/github/copilot/sdk/json/CommandWireDefinition.java | Adds wire DTO for command definitions sent over RPC. |
| src/main/java/com/github/copilot/sdk/json/CommandHandler.java | Adds functional interface for slash command handling. |
| src/main/java/com/github/copilot/sdk/json/CommandDefinition.java | Adds command definition DTO (name/description/handler). |
| src/main/java/com/github/copilot/sdk/json/CommandContext.java | Adds context DTO passed to command handlers. |
| src/main/java/com/github/copilot/sdk/events/SessionEventParser.java | Registers new event types (command.execute, elicitation.requested, capabilities.changed). |
| src/main/java/com/github/copilot/sdk/events/PermissionRequestedEvent.java | Adds resolvedByHook field to support short-circuit behavior. |
| src/main/java/com/github/copilot/sdk/events/ElicitationRequestedEvent.java | Adds event type for incoming elicitation requests. |
| src/main/java/com/github/copilot/sdk/events/CommandExecuteEvent.java | Adds event type for slash command execution requests. |
| src/main/java/com/github/copilot/sdk/events/CapabilitiesChangedEvent.java | Adds event type for capability updates. |
| src/main/java/com/github/copilot/sdk/events/AbstractSessionEvent.java | Updates sealed hierarchy to include new event classes. |
| src/main/java/com/github/copilot/sdk/CopilotSession.java | Implements command execution + elicitation handling, UI API, and capabilities updates. |
| src/main/java/com/github/copilot/sdk/CopilotClient.java | Populates session capabilities and adds getSessionMetadata(sessionId) RPC. |
| README.md | Updates documented minimum Copilot version. |
| .lastmerge | Advances upstream sync marker to f7fd757. |
Copilot's findings
Comments suppressed due to low confidence (3)
src/main/java/com/github/copilot/sdk/CopilotSession.java:979
- handleElicitationRequestAsync assumes the elicitation handler completes with a non-null ElicitationResult. If a user handler returns CompletableFuture.completedFuture(null), result.getAction()/getContent() will throw a NullPointerException and no response will be sent. Treat a null result as CANCEL (and send a cancel response) to make the API more robust.
handler.handle(context).thenAccept(result -> {
try {
String actionStr = result.getAction() != null
? result.getAction().getValue()
: ElicitationResultAction.CANCEL.getValue();
Map<String, Object> resultMap = result.getContent() != null
? Map.of("action", actionStr, "content", result.getContent())
: Map.of("action", actionStr);
src/main/java/com/github/copilot/sdk/CopilotSession.java:1043
- SessionUiApiImpl.elicitation dereferences params and params.getRequestedSchema() without validation. Passing null params (or a params object with null requestedSchema) will currently fail with a NullPointerException. Consider validating inputs and throwing an IllegalArgumentException with a clear message (e.g., require non-null params, message, and requestedSchema).
public CompletableFuture<ElicitationResult> elicitation(ElicitationParams params) {
assertElicitation();
var schema = new java.util.HashMap<String, Object>();
schema.put("type", params.getRequestedSchema().getType());
schema.put("properties", params.getRequestedSchema().getProperties());
if (params.getRequestedSchema().getRequired() != null) {
src/main/java/com/github/copilot/sdk/CopilotSession.java:1029
- The IllegalStateException message mentions
getUi()?.getElicitation(), but?.is not valid Java syntax. This can confuse SDK users trying to follow the guidance. Update the message to use a Java-accurate check (e.g.,caps.getUi() != null && Boolean.TRUE.equals(caps.getUi().getElicitation())).
SessionCapabilities caps = capabilities;
if (caps == null || caps.getUi() == null || !Boolean.TRUE.equals(caps.getUi().getElicitation())) {
throw new IllegalStateException("Elicitation is not supported by the host. "
+ "Check session.getCapabilities().getUi()?.getElicitation() before calling UI methods.");
}
- Files reviewed: 37/37 changed files
- Comments generated: 3
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/copilot-sdk-java/sessions/b5d79053-ae26-4c98-9047-b2457c08b0b8 Co-authored-by: brunoborges <129743+brunoborges@users.noreply.github.com>
brunoborges
approved these changes
Apr 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ports 27 upstream commits from
github/copilot-sdk(up tof7fd757). Updates.lastmergeaccordingly.Before the change?
SessionUiApiJavadoc used?.(not valid Java syntax) in the prose descriptionAfter the change?
Slash Commands — Register
/commandhandlers invoked from the CLI TUI:command.executeevents dispatched to registered handlers; responds viasession.commands.handlePendingCommandcommandNamenull-checked beforeConcurrentHashMaplookup to preventNullPointerExceptionCommandWireDefinitionlist in create/resume requestsElicitation (UI Dialogs) — Two directions:
onElicitationRequesthandler receives elicitation requests from server/MCP tools;requestElicitation=trueadvertises supportsession.getUi().confirm()/.select()/.input()/.elicitation()for proactive dialogs when host supports itSession Capabilities —
session.getCapabilities()populated from create/resume response and updated viacapabilities.changedevents:getSessionMetadata(sessionId)— O(1) session lookup by ID onCopilotClient(vs. scanning all sessions withlistSessions()).resolvedByHookfix — Permission events already resolved by a pre-hook now short-circuit before invoking the client-side permission handler.Javadoc / docs fixes —
SessionUiApiprose now uses valid Java null-check syntax instead of?.; README updated to say "GitHub Copilot CLI 1.0.17".New Types
json/:CommandDefinition,CommandContext,CommandHandler,CommandWireDefinition,ElicitationContext,ElicitationResult,ElicitationSchema,ElicitationParams,ElicitationResultAction,ElicitationHandler,InputOptions,SessionCapabilities,SessionUiCapabilities,SessionUiApi,GetSessionMetadataResponseevents/:CommandExecuteEvent,ElicitationRequestedEvent,CapabilitiesChangedEventPull request checklist
mvn spotless:applyhas been run to format the codemvn clean verifypasses locallyDoes this introduce a breaking change?