Skip to content

Port ExitPlanMode and AutoModeSwitch handler APIs from reference implementation#181

Draft
Copilot wants to merge 5 commits intomainfrom
copilot/reference-impl-sync-9-new-commits
Draft

Port ExitPlanMode and AutoModeSwitch handler APIs from reference implementation#181
Copilot wants to merge 5 commits intomainfrom
copilot/reference-impl-sync-9-new-commits

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 9, 2026

Resolves #297


Before the change?

  • Java SDK lacked ExitPlanMode and AutoModeSwitch handler APIs present in other SDK implementations, preventing hosts from responding to runtime mode-switching requests (plan exit approval, rate-limit model switching).

After the change?

  • New handler typesExitPlanModeHandler, AutoModeSwitchHandler with corresponding request/result/invocation POJOs and AutoModeSwitchResponse enum (YES, YES_ALWAYS, NO)
  • Full handler wiringSessionConfig / ResumeSessionConfigSessionRequestBuilder (sets requestExitPlanMode / requestAutoModeSwitch flags) → CopilotSession (AtomicReference storage, registration, dispatch with defaults) → RpcHandlerDispatcher (exitPlanMode.request, autoModeSwitch.request RPC methods)
  • Default behavior — ExitPlanMode auto-approves; AutoModeSwitch declines (NO) when no handler registered, matching .NET reference
  • Codegen sync@github/copilot bumped to ^1.0.44-3, .lastmerge advanced to 30a76a5
var session = client.createSession(
    new SessionConfig()
        .setOnExitPlanMode((req, inv) -> CompletableFuture.completedFuture(
            new ExitPlanModeResult().setApproved(true).setSelectedAction("autopilot")))
        .setOnAutoModeSwitch((req, inv) -> CompletableFuture.completedFuture(
            AutoModeSwitchResponse.YES))
).get();

Commits analyzed (9): 1 ported (671b50a mode handlers), 1 synced via finish script (ac55e9a codegen version), 7 not applicable (Go/Rust/CI-only, .NET generated code, doc typos not present in Java SDK).

Pull request checklist

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)
  • mvn spotless:apply has been run to format the code
  • mvn clean verify passes locally

Does this introduce a breaking change?

  • Yes
  • No

Copilot AI and others added 2 commits May 9, 2026 23:17
…implementation

Co-authored-by: edburns <75821+edburns@users.noreply.github.com>
Co-authored-by: edburns <75821+edburns@users.noreply.github.com>

session.handleExitPlanModeRequest(request).thenAccept(result -> {
try {
rpc.sendResponse(Long.parseLong(requestId), result);
}
}).exceptionally(ex -> {
try {
rpc.sendErrorResponse(Long.parseLong(requestId), -32603,

session.handleAutoModeSwitchRequest(request).thenAccept(response -> {
try {
rpc.sendResponse(Long.parseLong(requestId), java.util.Map.of("response", response));
}
}).exceptionally(ex -> {
try {
rpc.sendErrorResponse(Long.parseLong(requestId), -32603,
* context information about the invocation
* @return a future that resolves with the user's decision
*/
CompletableFuture<AutoModeSwitchResponse> handle(AutoModeSwitchRequest request,
* @return a future that resolves with the user's decision
*/
CompletableFuture<AutoModeSwitchResponse> handle(AutoModeSwitchRequest request,
AutoModeSwitchInvocation invocation);
* context information about the invocation
* @return a future that resolves with the user's decision
*/
CompletableFuture<ExitPlanModeResult> handle(ExitPlanModeRequest request, ExitPlanModeInvocation invocation);
* context information about the invocation
* @return a future that resolves with the user's decision
*/
CompletableFuture<ExitPlanModeResult> handle(ExitPlanModeRequest request, ExitPlanModeInvocation invocation);
Copilot AI and others added 2 commits May 9, 2026 23:36
…om.xml CLI version, and update scripts/codegen @github/copilot version

Co-authored-by: edburns <75821+edburns@users.noreply.github.com>
Co-authored-by: edburns <75821+edburns@users.noreply.github.com>
Copilot AI changed the title [WIP] Sync reference implementation with 9 new commits Port ExitPlanMode and AutoModeSwitch handler APIs from reference implementation May 9, 2026
Copilot finished work on behalf of edburns May 9, 2026 23:38
Copilot AI requested a review from edburns May 9, 2026 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[reference-impl-sync] Reference Implementation sync: 9 new commits (2026-05-09)

2 participants