Skip to content

Expose context tier in SDK set model APIs#1507

Open
dmytrostruk wants to merge 3 commits into
mainfrom
context-tier-set-model-sdk
Open

Expose context tier in SDK set model APIs#1507
dmytrostruk wants to merge 3 commits into
mainfrom
context-tier-set-model-sdk

Conversation

@dmytrostruk
Copy link
Copy Markdown
Contributor

Summary

  • expose shared ContextTier types across SDK/generated RPC surfaces following ReasoningSummary shape
  • add contextTier/context_tier support to setModel/set_model APIs across languages
  • update serialization/forwarding coverage for context tier on model switches

Testing

  • Not run per request.

Copilot AI review requested due to automatic review settings May 29, 2026 22:06
@dmytrostruk dmytrostruk requested a review from a team as a code owner May 29, 2026 22:06
Auto-committed by java-codegen-check workflow.
@github-actions github-actions Bot added the dependencies Pull requests that update a dependency file label May 29, 2026
var generatedContextTier = contextTier == null ? null : ContextTier.fromValue(contextTier);
return getRpc().model.switchTo(new SessionModelSwitchToParams(sessionId, model, reasoningEffort,
generatedReasoningSummary, generatedCapabilities)).thenApply(r -> null);
generatedReasoningSummary, generatedCapabilities, generatedContextTier)).thenApply(r -> null);
@github-actions
Copy link
Copy Markdown
Contributor

Cross-SDK Consistency Review ✅

This PR maintains strong feature parity across all six SDK implementations.

Coverage: Node.js, Python, Go, .NET, Java, and Rust all receive contextTier/context_tier support in their setModel/set_model APIs.

Consistency observations:

SDK Parameter type Pattern
Node.js ContextTier (typed) via options.contextTier?
Python ContextTier | None (typed enum) via context_tier= kwarg
Go *ContextTier (typed) via SetModelOptions.ContextTier
.NET ContextTier? (typed) via SetModelOptions.ContextTier
Rust Option<ContextTier> (typed enum) via SetModelOptions.with_context_tier()
Java String contextTier (raw string) follows existing Java-SDK pattern for reasoningSummary

The Java SDK's use of String for contextTier is consistent with its existing convention for reasoningSummary — both are converted to typed enums internally before dispatch. No inconsistency there.

Type consolidation: The PR also cleans up duplicate enum types (e.g., ModelCurrentContextTier / ModelSwitchToRequestContextTier → unified ContextTier in Rust/Go), which is a positive simplification.

No cross-SDK consistency issues found.

Generated by SDK Consistency Review Agent for issue #1507 · ● 3.9M ·

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR standardizes and exposes a shared ContextTier type across SDK surfaces and wires it through setModel / set_model / SetModelAsync APIs so model switches can pin the session to a specific context-window tier (e.g. long_context).

Changes:

  • Introduces/renames the shared ContextTier type in generated RPC types (replacing request/result-specific context-tier types).
  • Adds contextTier / context_tier support to model-switch APIs across Rust, Python, Node.js, Java, Go, and .NET and forwards it into session.model.switchTo.
  • Updates/extends per-language tests to assert correct serialization/forwarding of contextTier on model switches.
Show a summary per file
File Description
rust/tests/session_test.rs Extends Rust integration test to assert contextTier is sent on session.model.switchTo.
rust/src/wire.rs Uses typed ContextTier in session create/resume wire payloads.
rust/src/types.rs Re-exports ContextTier, updates configs to use it, and adds SetModelOptions.context_tier + builder.
rust/src/session.rs Forwards SetModelOptions.context_tier into ModelSwitchToRequest.
rust/src/generated/api_types.rs Unifies context-tier enums into ContextTier and updates request/result fields accordingly.
python/test_client.py Adds assertion that contextTier is included in captured session.model.switchTo params.
python/copilot/session.py Adds context_tier parameter to set_model and maps it into the generated RPC request.
python/copilot/generated/rpc.py Introduces ContextTier enum and updates CurrentModel / ModelSwitchToRequest to use it (with alias for compatibility).
nodejs/test/client.test.ts Extends Node client test to verify contextTier is passed to session.model.switchTo.
nodejs/src/types.ts Re-exports generated ContextTier type and removes the local duplicate type definition.
nodejs/src/session.ts Adds contextTier to setModel options and forwards it via spread into switchTo.
nodejs/src/generated/rpc.ts Renames/unifies context-tier types to ContextTier and updates request typing.
java/src/test/java/com/github/copilot/RpcWrappersTest.java Updates wrapper test to include and assert contextTier serialization for switchTo.
java/src/test/java/com/github/copilot/generated/rpc/GeneratedRpcRecordsCoverageTest.java Updates generated-record coverage tests for new ContextTier field/ctor params.
java/src/main/java/com/github/copilot/CopilotSession.java Adds setModel overload that accepts contextTier (string) and forwards it via generated ContextTier.
java/src/generated/java/com/github/copilot/generated/rpc/ContextTier.java Adds generated ContextTier enum definition.
go/types.go Aliases public ContextTier to generated rpc.ContextTier and maps exported constants.
go/session.go Adds SetModelOptions.ContextTier and forwards it into the SwitchTo request.
go/rpc/zrpc.go Unifies generated context-tier types into ContextTier and updates request/result structs.
dotnet/test/Unit/SerializationTests.cs Adds a serialization test ensuring contextTier is emitted for ModelSwitchToRequest.
dotnet/src/Types.cs Adds public SetModelOptions (including ContextTier) and registers it for source-gen serialization.
dotnet/src/Session.cs Adds SetModelAsync(string, SetModelOptions, ...) and routes existing overloads through it to forward ContextTier.
dotnet/src/Generated/Rpc.cs Updates generated RPC types/methods to use ContextTier for current model + switchTo requests.

Copilot's findings

Files not reviewed (1)
  • go/rpc/zrpc.go: Language not supported
  • Files reviewed: 16/23 changed files
  • Comments generated: 0

@github-actions
Copy link
Copy Markdown
Contributor

Java Codegen Fix Agent Report

The java-codegen-fix workflow ran but was unable to fully resolve the mvn verify failure. Here is the diagnosis:

Root Cause

The failure is not a code generation or handwritten code issue. The error is:

[ERROR] Rule 0: org.apache.maven.enforcer.rules.version.RequireJavaVersion failed with message:
[ERROR] JDK 25+ is required to build the Multi-Release JAR with the virtual-thread overlay.

This is a CI configuration mismatch:

  • java/pom.xml enforces JDK 25+ (the enforce-jdk25 Maven Enforcer rule)
  • .github/workflows/java-codegen-check.yml runs mvn verify with JDK 17

Current State

  • ✅ Generated files (java/src/generated/) are already up to date — re-running npx tsx java.ts produces no changes
  • ✅ No handwritten code changes are needed
  • mvn verify cannot pass with JDK 17 due to the enforcer rule in pom.xml

Required Fix (Manual Intervention)

Update .github/workflows/java-codegen-check.yml to use JDK 25 instead of JDK 17:

- uses: actions/setup-java@...
  if: steps.push-regen.outcome == 'success'
  with:
    java-version: "25"   # was "17"
    distribution: "microsoft"
    cache: "maven"

This will align the java-codegen-check workflow with the JDK 25 requirement already present in pom.xml and java-sdk-tests.yml.

Note: The enforce-jdk25 rule exists on main already; this mismatch affects any PR that triggers codegen regeneration.

Warning

Firewall blocked 5 domains

The following domains were blocked by the firewall during workflow execution:

  • jcenter.bintray.com
  • jfrog.io
  • repo.maven.apache.org
  • repo1.maven.org
  • search.maven.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "jcenter.bintray.com"
    - "jfrog.io"
    - "repo.maven.apache.org"
    - "repo1.maven.org"
    - "search.maven.org"

See Network Configuration for more information.

Generated by Java Codegen Agentic Fix · ● 22.9M ·

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants