Skip to content

Port mode handler APIs (ExitPlanMode, AutoModeSwitch) from reference implementation#183

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/reference-implementation-sync
Draft

Port mode handler APIs (ExitPlanMode, AutoModeSwitch) from reference implementation#183
Copilot wants to merge 4 commits intomainfrom
copilot/reference-implementation-sync

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 10, 2026

Resolves #196


Before the change?

  • Java SDK lacked ExitPlanMode and AutoModeSwitch handler APIs present in other SDK implementations
  • ModelBilling.multiplier was a primitive double, couldn't represent absent values
  • .lastmerge pointed to 066a69c, @github/copilot at prior version

After the change?

  • Mode handler APIs — Ports 671b50a (Restore mode handler APIs across SDKs):
    • ExitPlanModeHandler / AutoModeSwitchHandler functional interfaces with request/result/invocation types
    • SessionConfig and ResumeSessionConfig gain onExitPlanMode / onAutoModeSwitch fields (with clone support)
    • CreateSessionRequest / ResumeSessionRequest gain requestExitPlanMode / requestAutoModeSwitch capability flags
    • SessionRequestBuilder wires handlers and flags automatically
    • CopilotSession registers handlers via AtomicReference, dispatches with safe defaults (approved=true / NO)
    • RpcHandlerDispatcher handles exitPlanMode.request and autoModeSwitch.request RPC methods
  • Nullable multiplierModelBilling.multiplier changed from double to Double (from e759700)
  • Version sync.lastmergef625779, @github/copilot^1.0.44-3

Not ported (not applicable to Java): Go/Rust/Node/Python SDK changes, CI fork restrictions, generated code changes, doc typos in ref-impl-only files.

var config = new SessionConfig()
    .setOnExitPlanMode((request, invocation) -> {
        // Review plan before exiting plan mode
        return CompletableFuture.completedFuture(
            new ExitPlanModeResult().setApproved(true));
    })
    .setOnAutoModeSwitch((request, invocation) -> {
        // Handle rate-limit mode switch prompt
        return CompletableFuture.completedFuture(AutoModeSwitchResponse.YES);
    });

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 3 commits May 10, 2026 23:39
…delBilling.multiplier from the reference implementation

Co-authored-by: edburns <75821+edburns@users.noreply.github.com>
Co-authored-by: edburns <75821+edburns@users.noreply.github.com>
…om.xml CLI version, and update scripts/codegen @github/copilot version

Co-authored-by: edburns <75821+edburns@users.noreply.github.com>
Copilot AI changed the title [WIP] Sync reference implementation with latest commits Port mode handler APIs (ExitPlanMode, AutoModeSwitch) from reference implementation May 10, 2026
Copilot AI requested a review from edburns May 10, 2026 23:42

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.getValue()));
}
}).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<ExitPlanModeResult> handle(ExitPlanModeRequest request, ExitPlanModeInvocation invocation);
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: 11 new commits (2026-05-10)

2 participants