Skip to content

Commit 76a9f18

Browse files
arimu1cursoragentSteveSandersonMSCopilot
authored
test(java): re-enable ModeHandlers exit_plan_mode E2E assertions (#2032)
* test(java): re-enable ModeHandlers exit_plan_mode E2E assertions Remove the CLI 1.0.57 @disabled workaround and assert the canonical action order (autopilot, interactive, exit_only) plus recommendedAction, matching the other language SDKs after snapshot updates. Fixes #1547 Co-authored-by: Cursor <cursoragent@cursor.com> * fix(java): use agentMode instead of mode for exit_plan_mode E2E test The test was using MessageOptions.setMode("plan") which sets the wire-protocol 'mode' field (prompt formatting only, e.g. the [[PLAN]] prefix). The field that actually switches the CLI's active agent mode and exposes the exit_plan_mode tool to the model is 'agentMode', set via MessageOptions.setAgentMode(AgentMode.PLAN) - matching how the Node.js and .NET reference E2E tests invoke this same scenario. This was root-caused by capturing the Node SDK's actual outgoing session.send payload and comparing it against Java's: Node sends agentMode: "plan", Java was only sending mode: "plan". Without agentMode set, the CLI never enters plan UI mode, so exit_plan_mode is not registered as an available tool and the model's tool call is rejected by the real (non-replayed) CLI, causing the replay-proxy snapshot mismatch failure seen in CI. Reproduced the original failure locally, confirmed this fix resolves it, and validated on both JDK 25 and JDK 17 per java/README.md's two-step build/test process. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Steve Sanderson <SteveSandersonMS@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 5b1381b commit 76a9f18

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

java/src/test/java/com/github/copilot/ModeHandlersTest.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,19 @@
77
import static org.junit.jupiter.api.Assertions.*;
88

99
import java.util.HashMap;
10+
import java.util.List;
1011
import java.util.Map;
1112
import java.util.concurrent.CompletableFuture;
1213
import java.util.concurrent.TimeUnit;
1314

1415
import org.junit.jupiter.api.AfterAll;
1516
import org.junit.jupiter.api.BeforeAll;
16-
import org.junit.jupiter.api.Disabled;
1717
import org.junit.jupiter.api.Test;
1818

1919
import com.github.copilot.generated.ExitPlanModeAction;
2020
import com.github.copilot.generated.ExitPlanModeCompletedEvent;
2121
import com.github.copilot.generated.ExitPlanModeRequestedEvent;
22+
import com.github.copilot.rpc.AgentMode;
2223
import com.github.copilot.rpc.AutoModeSwitchRequest;
2324
import com.github.copilot.rpc.AutoModeSwitchResponse;
2425
import com.github.copilot.rpc.CopilotClientOptions;
@@ -68,7 +69,6 @@ private void configureAuthenticatedUser(String testName) throws Exception {
6869
}
6970

7071
@Test
71-
@Disabled("Snapshot needs re-recording for CLI 1.0.57: https://github.com/github/copilot-sdk/issues/1547")
7272
void shouldInvokeExitPlanModeHandlerWhenModelUsesTool() throws Exception {
7373
final String summary = "Greeting file implementation plan";
7474
configureAuthenticatedUser("should_invoke_exit_plan_mode_handler_when_model_uses_tool");
@@ -99,20 +99,23 @@ void shouldInvokeExitPlanModeHandlerWhenModelUsesTool() throws Exception {
9999

100100
var response = session.sendAndWait(new MessageOptions().setPrompt(
101101
"Create a brief implementation plan for adding a greeting.txt file, then request approval with exit_plan_mode.")
102-
.setMode("plan")).get(120, TimeUnit.SECONDS);
102+
.setAgentMode(AgentMode.PLAN)).get(120, TimeUnit.SECONDS);
103103

104104
var request = handlerCalled.get(10, TimeUnit.SECONDS);
105105
assertEquals(summary, request.getSummary());
106-
assertNotNull(request.getActions());
107-
assertTrue(request.getActions().contains("interactive"));
106+
// Canonical action order after CLI 1.0.57+ (aligned with #2023 / other SDKs).
107+
assertEquals(List.of("autopilot", "interactive", "exit_only"), request.getActions());
108+
assertEquals("interactive", request.getRecommendedAction());
108109
assertNotNull(request.getPlanContent());
109110

110111
var reqEvent = requestedEvent.get(10, TimeUnit.SECONDS);
111112
assertEquals(request.getSummary(), reqEvent.getData().summary());
113+
assertEquals(ExitPlanModeAction.INTERACTIVE, reqEvent.getData().recommendedAction());
112114

113115
var compEvent = completedEvent.get(10, TimeUnit.SECONDS);
114116
assertTrue(compEvent.getData().approved());
115117
assertEquals(ExitPlanModeAction.INTERACTIVE, compEvent.getData().selectedAction());
118+
assertEquals("Approved by the Java E2E test", compEvent.getData().feedback());
116119

117120
assertNotNull(response);
118121

0 commit comments

Comments
 (0)