-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expose Auto tier switching across all six SDKs #2514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
SteveSandersonMS
merged 7 commits into
main
from
issue-18045-expose-auto-tier-switching-across-sdks
Sep 4, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5c7ac98
Expose Auto tier switching across all six SDKs
andyfeller d7fea2c
Address pre-review findings on Auto tier switching
andyfeller 3ab56b1
Mark the Auto tier surface experimental in every SDK
andyfeller 8fb91e6
Use one vocabulary for resetting the Auto tier
andyfeller fee4bd7
Add end-to-end coverage for Auto tier switching
andyfeller 4ae0906
Fix Rust CI: format E2E imports and skip the README fragment
andyfeller cf38b7b
Address review feedback on the Auto tier surface
andyfeller File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| using GitHub.Copilot.Rpc; | ||
| using GitHub.Copilot.Test.Harness; | ||
| using Xunit; | ||
| using Xunit.Abstractions; | ||
|
|
||
| namespace GitHub.Copilot.Test.E2E; | ||
|
|
||
| /// <summary> | ||
| /// Mirrors nodejs/test/e2e/auto_tier.e2e.test.ts (snapshot category "auto_tier"). | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// The runtime stages an Auto routing preference instead of applying it immediately: a | ||
| /// request stays unclaimed until a later turn using the <c>auto</c> model mints a usable | ||
| /// model and token pair. These tests observe that staged state through | ||
| /// <c>Model.GetCurrentAsync</c>, so they assert what the runtime actually recorded rather | ||
| /// than what the SDK serialized. | ||
| /// </remarks> | ||
| public class AutoTierE2ETests(E2ETestFixture fixture, ITestOutputHelper output) | ||
| : E2ETestBase(fixture, "auto_tier", output) | ||
| { | ||
| private static async Task AssertPendingAutoTierAsync(CopilotSession session, AutoTier? expected) | ||
| { | ||
| var current = await session.Rpc.Model.GetCurrentAsync(); | ||
| Assert.Equal(expected, current.PendingAutoTier); | ||
| } | ||
|
|
||
| [Fact] | ||
| public async Task Should_Stage_And_Reset_Auto_Tier_Preference() | ||
| { | ||
| await using var session = await CreateSessionAsync(new SessionConfig | ||
| { | ||
| Model = "auto", | ||
| OnPermissionRequest = PermissionHandler.ApproveAll, | ||
| }); | ||
|
|
||
| await AssertPendingAutoTierAsync(session, null); | ||
|
|
||
| var staged = await session.SetAutoTierAsync(AutoTier.Efficiency); | ||
| Assert.Equal(ModelSwitchAutoTierStatus.Pending, staged.Status); | ||
| Assert.Equal(AutoTier.Efficiency, staged.PendingAutoTier); | ||
| await AssertPendingAutoTierAsync(session, AutoTier.Efficiency); | ||
|
|
||
| // A second request replaces the first and reports the one it displaced. | ||
| var superseded = await session.SetAutoTierAsync(AutoTier.Intelligence); | ||
| Assert.Equal(ModelSwitchAutoTierStatus.Pending, superseded.Status); | ||
| Assert.Equal(AutoTier.Intelligence, superseded.PendingAutoTier); | ||
| Assert.Equal(AutoTier.Efficiency, superseded.SupersededAutoTier); | ||
| await AssertPendingAutoTierAsync(session, AutoTier.Intelligence); | ||
|
|
||
| // A null tier returns the session to provider-default routing. The status is | ||
| // Unchanged because provider-default was already the committed preference; the | ||
| // request's effect is cancelling the staged one. | ||
| var reset = await session.SetAutoTierAsync(null); | ||
| Assert.Equal(ModelSwitchAutoTierStatus.Unchanged, reset.Status); | ||
| Assert.Equal(AutoTier.Intelligence, reset.SupersededAutoTier); | ||
| await AssertPendingAutoTierAsync(session, null); | ||
| } | ||
|
|
||
| [Fact] | ||
| public async Task Should_Preserve_Auto_Tier_When_Set_Model_Omits_It() | ||
| { | ||
| await using var session = await CreateSessionAsync(new SessionConfig | ||
| { | ||
| Model = "auto", | ||
| OnPermissionRequest = PermissionHandler.ApproveAll, | ||
| }); | ||
|
|
||
| await session.SetAutoTierAsync(AutoTier.Balance); | ||
| await AssertPendingAutoTierAsync(session, AutoTier.Balance); | ||
|
|
||
| // Leaving AutoTier unset without asking for a reset leaves the staged preference alone. | ||
| await session.SetModelAsync("auto", new SetModelOptions()); | ||
| await AssertPendingAutoTierAsync(session, AutoTier.Balance); | ||
|
|
||
| // Supplying a tier replaces it. | ||
| await session.SetModelAsync("auto", new SetModelOptions { AutoTier = AutoTier.Intelligence }); | ||
| await AssertPendingAutoTierAsync(session, AutoTier.Intelligence); | ||
|
|
||
| // ResetAutoTier clears it. Omission, a value, and a reset are three distinct | ||
| // outcomes, which is why a single nullable property cannot express the request. | ||
| await session.SetModelAsync("auto", new SetModelOptions { ResetAutoTier = true }); | ||
| await AssertPendingAutoTierAsync(session, null); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.