Commit efbed19
Expose Auto tier switching across all six SDKs (#2514)
* Expose Auto tier switching across all six SDKs
The runtime now accepts an Auto routing preference change on a live
session through `session.model.switchAutoTier`, and reports the
authoritative committed, pending, and activating preferences through
`session.model.getCurrent`. Without SDK support, integrators could only
choose a tier at session creation or resume and had no way to change it
or observe whether a change took effect.
Each SDK gains two capabilities:
* `setAutoTier` changes the routing preference without changing the
selected model.
* The model switch options gain an Auto tier field, which stages a tier
atomically with selecting `auto`.
The runtime distinguishes an explicit null tier, meaning "return to
provider-default routing," from an absent one, meaning "leave the
preference alone." Python, Go, .NET, Java, and Rust generated wrappers
drop null properties, so those SDKs build the request payload directly
where a null must survive; each bypass carries a comment explaining why.
Node.js needed no workaround. The tri-state choice is expressed
idiomatically per language: `undefined`/tier/`null` in Node.js, an
`_UNSET` sentinel in Python, a `ClearAutoTier` flag validated as
mutually exclusive in Go, .NET, and Java, and an `AutoTierPreference`
enum in Rust.
Tests cover the wire payloads for both methods, including the explicit
null case, and decoding of the ephemeral
`session.auto_tier_switch_failed` event across all four failure reasons
plus the null requested-tier case.
Documentation previously stated that a resident resume rejects a
different tier. The authoritative schema now says the runtime requests a
safe switch applied after the resume succeeds, which cannot change a
turn already in flight. This corrects that text in all six SDKs and in
the session persistence guide.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 2aad36e9-e078-4b9c-afa1-0c7cd2c71f74
* Address pre-review findings on Auto tier switching
Reviewing the change against the standards maintainers have applied to
earlier SDK pull requests surfaced four issues worth fixing before
opening the pull request.
Python could not accept the enum it hands back. `set_auto_tier` and
`set_model` were typed for the `AutoTier` string literal, but results and
events carry the generated `AutoTier` enum. Feeding that value back
raised `TypeError: Object of type AutoTier is not JSON serializable`,
because the JSON-RPC encoder calls `json.dumps` with no enum support.
Both methods now accept either representation and normalize to the wire
value. Added a regression test.
.NET and Go hand-copied request fields. Both built a second, partial copy
of the model-switch payload so an explicit null tier would survive
serialization. Each copy listed only a subset of the generated request's
fields, so a new field on the schema would have been silently dropped on
the clear path. Both now serialize the generated request and write the
null back, matching what Rust, Java, and Python already did. This also
removes two hand-written request types and their serializer
registrations from the .NET SDK.
Java allocated raw `ObjectMapper` instances instead of using the shared
`MAPPER`, which is configured to match the JSON-RPC encoder. A
differently configured mapper could produce a different wire shape.
The .NET test compared the status enum through `ToString`; it now
compares the enum directly.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 2aad36e9-e078-4b9c-afa1-0c7cd2c71f74
* Mark the Auto tier surface experimental in every SDK
The .NET and Java implementations carried [Experimental] and
@CopilotExperimental, but the Node.js, Python, Go, and Rust equivalents
carried no marker. That asymmetry is the exact gap maintainers have
flagged before: C# gets the annotation and the other languages are left
without the corresponding doc annotation.
Auto tier routing is still moving — the `fast` tier is not yet exposed
and the runtime contract may shift — so the surface is marked
experimental consistently in all six SDKs, each using the convention
already established in that language.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 2aad36e9-e078-4b9c-afa1-0c7cd2c71f74
* Use one vocabulary for resetting the Auto tier
The SDKs described the same idea three different ways: Rust called it
`AutoTierPreference::ProviderDefault`, while Go, .NET, and Java called it
`ClearAutoTier`. Cross-SDK consistency is the standard maintainers apply
most often, and a reader comparing two SDKs had no way to tell these were
the same operation.
Everything now uses "reset": `ResetAutoTier` in Go and .NET,
`setResetAutoTier` in Java, and `AutoTierPreference::Reset` with
`with_reset_auto_tier` in Rust.
The underlying shapes stay language-idiomatic. Node.js and Python express
all three states natively, because `null` and `None` are distinguishable
from an omitted argument. Rust uses a sum type. Go, .NET, and Java cannot
make that distinction in a single value, so they keep a separate reset
option. Forcing Rust's enum onto Go would mean exported constructor
functions in place of the pointer-and-flag pattern Go already uses for
"unset versus explicit zero", which trades a cross-language inconsistency
for a within-language one.
Documented the trade-off and added a per-SDK table for staging a tier on
a model switch, so the difference is explained rather than discovered.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 2aad36e9-e078-4b9c-afa1-0c7cd2c71f74
* Add end-to-end coverage for Auto tier switching
The unit tests for Auto tier switching only check the JSON-RPC payload the SDK
builds. That proves the wire shape but not that the runtime interprets it the
way the API documents, which is the part reviewers have asked us to demonstrate
on earlier model-switching work.
These tests run against a real Copilot runtime and read the staged state back
through `model.getCurrent()`, so every assertion reflects recorded runtime
behavior. Two scenarios, identical across all six SDKs:
- Staging and resetting. A request is accepted as `pending`, a second request
replaces the first and reports the tier it displaced, and a null tier returns
the session to provider-default routing.
- Omission semantics. Calling `setModel("auto")` without a tier preserves the
staged preference, passing a tier replaces it, and asking for a reset clears
it. These are three distinct outcomes, which is why the reset is expressed
separately from the tier value in every language.
The runtime only commits a preference on a later turn that uses the `auto`
model, so it rejects `switchAutoTier` unless `auto` is selected. Both snapshots
therefore list `auto` and record no conversation; covering the commit path
through `session.model_change` and `session.auto_tier_switch_failed` needs a
recorded conversation and is left as follow-up.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 2aad36e9-e078-4b9c-afa1-0c7cd2c71f74
* Fix Rust CI: format E2E imports and skip the README fragment
The Auto tier README example is a fragment that references an undefined
'session' binding, so rustdoc could not compile it as a doctest. Mark it
'rust,ignore' to match every other fragment in the file, and apply the
rustfmt import merge the format job asked for.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 2aad36e9-e078-4b9c-afa1-0c7cd2c71f74
* Address review feedback on the Auto tier surface
Gate the experimental Auto tier options consistently. The .NET
SetModelOptions.AutoTier and .ResetAutoTier properties, the Java Auto tier
accessors, and the Python set_model auto_tier parameter now carry the same
experimental marker their dedicated setAutoTier counterparts already had.
Correct two documentation errors. The reset-state paragraph claimed four SDKs
cannot express reset in a single value; Rust can, through
AutoTierPreference::Reset, so only Go, .NET, and Java need a separate flag.
The live-switching section now states that it needs Copilot CLI 1.0.83-4,
which is newer than the 1.0.82-1 required to select a tier at create or resume.
Fix the Java class Javadoc, which said every option is optional when setModel
rejects a null model, and rewrite the Rust E2E doc comment to describe what it
covers instead of pointing at the Node.js test.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 2aad36e9-e078-4b9c-afa1-0c7cd2c71f74
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 2aad36e9-e078-4b9c-afa1-0c7cd2c71f741 parent 0921029 commit efbed19
42 files changed
Lines changed: 2640 additions & 75 deletions
File tree
- docs/features
- dotnet
- src
- test
- E2E
- Unit
- go
- internal/e2e
- java
- sdk/src
- main/java/com/github/copilot
- rpc
- test/java/com/github/copilot
- nodejs
- src
- test
- e2e
- python
- copilot
- e2e
- rust
- src
- tests
- e2e
- test/snapshots/auto_tier
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
245 | | - | |
| 245 | + | |
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
| |||
262 | 262 | | |
263 | 263 | | |
264 | 264 | | |
265 | | - | |
| 265 | + | |
266 | 266 | | |
267 | 267 | | |
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
271 | 271 | | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
272 | 314 | | |
273 | 315 | | |
274 | 316 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
284 | 284 | | |
285 | 285 | | |
286 | 286 | | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
287 | 308 | | |
288 | 309 | | |
289 | 310 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
1927 | 1928 | | |
1928 | 1929 | | |
1929 | 1930 | | |
| 1931 | + | |
| 1932 | + | |
| 1933 | + | |
| 1934 | + | |
| 1935 | + | |
| 1936 | + | |
| 1937 | + | |
| 1938 | + | |
| 1939 | + | |
| 1940 | + | |
| 1941 | + | |
| 1942 | + | |
| 1943 | + | |
| 1944 | + | |
| 1945 | + | |
| 1946 | + | |
| 1947 | + | |
| 1948 | + | |
| 1949 | + | |
| 1950 | + | |
| 1951 | + | |
| 1952 | + | |
| 1953 | + | |
| 1954 | + | |
| 1955 | + | |
| 1956 | + | |
1930 | 1957 | | |
1931 | 1958 | | |
| 1959 | + | |
1932 | 1960 | | |
1933 | 1961 | | |
1934 | 1962 | | |
| |||
1938 | 1966 | | |
1939 | 1967 | | |
1940 | 1968 | | |
| 1969 | + | |
| 1970 | + | |
| 1971 | + | |
| 1972 | + | |
| 1973 | + | |
| 1974 | + | |
| 1975 | + | |
| 1976 | + | |
| 1977 | + | |
| 1978 | + | |
| 1979 | + | |
| 1980 | + | |
| 1981 | + | |
| 1982 | + | |
| 1983 | + | |
| 1984 | + | |
| 1985 | + | |
| 1986 | + | |
| 1987 | + | |
| 1988 | + | |
| 1989 | + | |
| 1990 | + | |
| 1991 | + | |
| 1992 | + | |
| 1993 | + | |
| 1994 | + | |
| 1995 | + | |
| 1996 | + | |
| 1997 | + | |
| 1998 | + | |
| 1999 | + | |
| 2000 | + | |
| 2001 | + | |
| 2002 | + | |
| 2003 | + | |
| 2004 | + | |
| 2005 | + | |
| 2006 | + | |
| 2007 | + | |
| 2008 | + | |
| 2009 | + | |
| 2010 | + | |
| 2011 | + | |
| 2012 | + | |
| 2013 | + | |
| 2014 | + | |
| 2015 | + | |
| 2016 | + | |
| 2017 | + | |
| 2018 | + | |
| 2019 | + | |
| 2020 | + | |
| 2021 | + | |
| 2022 | + | |
| 2023 | + | |
| 2024 | + | |
| 2025 | + | |
| 2026 | + | |
| 2027 | + | |
| 2028 | + | |
| 2029 | + | |
| 2030 | + | |
| 2031 | + | |
1941 | 2032 | | |
1942 | 2033 | | |
1943 | 2034 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2447 | 2447 | | |
2448 | 2448 | | |
2449 | 2449 | | |
2450 | | - | |
2451 | | - | |
2452 | | - | |
| 2450 | + | |
| 2451 | + | |
| 2452 | + | |
| 2453 | + | |
| 2454 | + | |
2453 | 2455 | | |
2454 | 2456 | | |
2455 | 2457 | | |
| |||
3017 | 3019 | | |
3018 | 3020 | | |
3019 | 3021 | | |
| 3022 | + | |
| 3023 | + | |
| 3024 | + | |
| 3025 | + | |
| 3026 | + | |
| 3027 | + | |
| 3028 | + | |
| 3029 | + | |
| 3030 | + | |
| 3031 | + | |
| 3032 | + | |
| 3033 | + | |
| 3034 | + | |
| 3035 | + | |
| 3036 | + | |
| 3037 | + | |
| 3038 | + | |
| 3039 | + | |
| 3040 | + | |
| 3041 | + | |
3020 | 3042 | | |
3021 | 3043 | | |
3022 | 3044 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
0 commit comments