Skip to content

Add typed context tier support#1503

Merged
stephentoub merged 2 commits into
mainfrom
stephentoub/context-tier-enum
May 29, 2026
Merged

Add typed context tier support#1503
stephentoub merged 2 commits into
mainfrom
stephentoub/context-tier-enum

Conversation

@stephentoub
Copy link
Copy Markdown
Collaborator

Context tier is a small string-enum surface, but the C# SDK exposed it as string? while similar values use typed string-enum wrappers. This adds a typed C# surface and aligns Go with its named string type convention without changing the JSON wire values.

Summary

  • Add a C# ContextTier struct with Default and LongContext well-known values and JSON conversion.
  • Update C# session create/resume config and request DTOs to use ContextTier?, with clone and serialization coverage.
  • Add a Go ContextTier named string type with constants and use it in public config and internal session request payloads.

Notes

Node and Python already expose ContextTier literal aliases. Rust and Java keep raw-string config surfaces for forward-compatible arbitrary values, so this PR leaves those unchanged.

Testing

  • dotnet test dotnet\test\GitHub.Copilot.SDK.Test.csproj --no-restore --filter "SessionRequests_CanSerializeContextTier|ResumeSessionConfig_Clone_CopiesContextTier|SessionConfig_Clone_CopiesAllProperties"
  • Push-Location go; go test -count=1 . ./rpc; Pop-Location
  • go test ./... was attempted but Go E2E packages require local CLI setup from nodejs first.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 29, 2026 20:12
@stephentoub stephentoub requested a review from a team as a code owner May 29, 2026 20:12
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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 adds typed context tier support for the C# and Go SDK surfaces while preserving the existing JSON wire values used by the Copilot CLI.

Changes:

  • Adds a C# ContextTier string-enum wrapper and uses it in session create/resume configuration and internal request DTOs.
  • Adds a Go ContextTier named string type with known constants and wires it through public configs and internal request payloads.
  • Updates C# clone/serialization tests and Go request serialization tests to use the new typed constants.
Show a summary per file
File Description
dotnet/src/Types.cs Defines the C# ContextTier wrapper and updates session config typing/docs.
dotnet/src/Client.cs Updates internal create/resume request records to carry ContextTier?.
dotnet/test/Unit/SerializationTests.cs Verifies C# request JSON serialization for context tier values.
dotnet/test/Unit/CloneTests.cs Updates clone tests to use the typed C# context tier value.
go/types.go Defines the Go ContextTier type/constants and applies them to config/request structs.
go/client_test.go Updates Go serialization tests to use the new context tier constants.

Copilot's findings

  • Files reviewed: 6/6 changed files
  • Comments generated: 0

@github-actions
Copy link
Copy Markdown
Contributor

Cross-SDK Consistency Review ✅

This PR maintains cross-SDK consistency well. Here's a summary across all SDKs:

SDK ContextTier surface Status
Node.js/TypeScript type ContextTier = "default" | "long_context" (literal union) ✅ Already typed
Python ContextTier = Literal["default", "long_context"] ✅ Already typed
Go type ContextTier string + ContextTierDefault/ContextTierLongContext constants ✅ Added in this PR
.NET readonly struct ContextTier with Default/LongContext well-known values ✅ Added in this PR
Rust Raw string config surface i️ Intentionally left as-is (forward-compatible)
Java Raw string config surface i️ Intentionally left as-is (forward-compatible)

The approach taken for Go and .NET mirrors the existing patterns in those languages (Go named string type with constants, .NET string-enum struct wrapper), which is consistent with how ReasoningSummary is handled in both SDKs. The PR correctly avoids adding typed enums to Rust and Java where raw strings provide more forward-compatible flexibility.

Generated by SDK Consistency Review Agent for issue #1503 · ● 1.3M ·

@stephentoub stephentoub merged commit 13abec9 into main May 29, 2026
30 checks passed
@stephentoub stephentoub deleted the stephentoub/context-tier-enum branch May 29, 2026 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants