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
{{ message }}
Repository navigation
Flaky E2E test in rpc_session_state.e2e.test.ts (model switchto) #1629
The test should call session rpc model switchto is flaky, particularly on Windows CI.
It has a race condition where it awaits session.model_change after switchTo completes, frequently missing the event if it fires too quickly. It also incorrectly hardcodes gpt-4.1 expectations which fails on environments without auth.
Verdict: confirmed bug — the test should call session rpc model switchto in nodejs/test/e2e/rpc_session_state.e2e.test.ts has two distinct problems that together explain the flaky behaviour on Windows CI.
After calling session.rpc.model.switchTo({ modelId: "gpt-4.1", ... }), the test calls session.rpc.model.getCurrent() and expects the result to still equal the original model:
expect(after.modelId).toBe(before.modelId);// expects OLD model — wrong
This directly contradicts:
The skipped sibling test in rpc.e2e.test.ts (line 104), which was written to test the same feature and correctly expects the new model:
expect(after.modelId).toBe("gpt-4.1");// expects NEW model — correct
The behaviour confirmed by session.e2e.test.ts tests (should set model on existing session, should set model with reasoningEffort), which verify via the session.model_change event that the model is updated to the switched value.
The wrong assertion is what makes the test flaky: because the CLI may update its internal state and emit the session.model_change event asynchronously after returning the JSON-RPC response to switchTo, getCurrent() sometimes races with that state update. When getCurrent() wins the race (state not yet updated) the wrong assertion accidentally passes; when the state update wins (more likely under different OS scheduling on Windows), getCurrent() returns "gpt-4.1" and the wrong assertion fails.
The rpc_session_state test never subscribes to this event at all. The correct pattern for verifying the post-switch state would be to wait for the model_change event (to confirm the CLI has committed the switch) before calling getCurrent().
Activity
github-actions commentedon Jun 11, 2026
Investigation findings
Verdict: confirmed bug — the test
should call session rpc model switchtoinnodejs/test/e2e/rpc_session_state.e2e.test.tshas two distinct problems that together explain the flaky behaviour on Windows CI.1. Wrong assertion (
expect(after.modelId).toBe(before.modelId))After calling
session.rpc.model.switchTo({ modelId: "gpt-4.1", ... }), the test callssession.rpc.model.getCurrent()and expects the result to still equal the original model:This directly contradicts:
rpc.e2e.test.ts(line 104), which was written to test the same feature and correctly expects the new model:session.e2e.test.tstests (should set model on existing session,should set model with reasoningEffort), which verify via thesession.model_changeevent that the model is updated to the switched value.The wrong assertion is what makes the test flaky: because the CLI may update its internal state and emit the
session.model_changeevent asynchronously after returning the JSON-RPC response toswitchTo,getCurrent()sometimes races with that state update. WhengetCurrent()wins the race (state not yet updated) the wrong assertion accidentally passes; when the state update wins (more likely under different OS scheduling on Windows),getCurrent()returns"gpt-4.1"and the wrong assertion fails.2. Missing event-subscription pattern (race condition)
session.e2e.test.tssubscribes tosession.model_changebefore triggering the switch:The
rpc_session_statetest never subscribes to this event at all. The correct pattern for verifying the post-switch state would be to wait for themodel_changeevent (to confirm the CLI has committed the switch) before callinggetCurrent().Files investigated
nodejs/test/e2e/rpc_session_state.e2e.test.ts(lines 52–71)nodejs/test/e2e/rpc.e2e.test.ts(lines 84–105)expect(after.modelId).toBe("gpt-4.1")assertionnodejs/test/e2e/session.e2e.test.ts(lines 956–981)test/snapshots/rpc_session_state/should_call_session_rpc_model_switchto.yamlclaude-sonnet-4.5;gpt-4.1works because the CLI does not validate model IDs against the/modelsendpointSuggested fix
session.model_changebefore callingswitchTo.getCurrent()and assertafter.modelId === "gpt-4.1".it.skipinrpc.e2e.test.tsonce the active test is fixed (it already has the correct assertions).patniko commentedon Sep 8, 2026
Closing as fixed after verification against the current public SDK sources and bundled behavior.
Public evidence
bd7b50a17628— [E2E] session.todos_changed event + readSqlTodosWithDependencies (6 languages) ([E2E] session.todos_changed event + readSqlTodosWithDependencies (6 languages) #1622)nodejs/test/e2e/rpc_session_state.e2e.test.ts—createSdkTestContext; switchTo; getCurrentnodejs/test/e2e/rpc_session_state.e2e.test.ts—should call session rpc model switchtoThe reported behavior/request is implemented at the current SDK baseline, so this issue is being closed as completed.
Public SDK baseline: github/copilot-sdk
d5c9d06d8c41.