Add session-scoped GitHub token providers - #2412
Conversation
Expose lifecycle-safe GitHub credential callbacks across all six SDKs, with idiomatic APIs, tagged results, tests, and documentation. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a447a8bc-8687-47ea-a545-4370979e8128
There was a problem hiding this comment.
Pull request overview
Adds session-scoped rotating GitHub token providers across all six SDKs, including JSON-RPC routing, lifecycle management, documentation, and tests.
Changes:
- Adds provider APIs and token/cancellation response mapping.
- Adds registration, rollback, replacement, and cleanup logic.
- Documents expiry semantics and adds cross-language tests.
Show a summary per file
| File | Description |
|---|---|
rust/tests/session_test.rs |
Tests provider routing and rollback. |
rust/src/wire.rs |
Adds registration IDs to wire requests. |
rust/src/types.rs |
Adds provider configuration APIs. |
rust/src/session.rs |
Manages registration ownership. |
rust/src/router.rs |
Routes token requests. |
rust/src/lib.rs |
Exposes APIs and registry lifecycle. |
rust/src/github_token.rs |
Implements Rust provider support. |
rust/src/errors.rs |
Adds provider error kind. |
rust/README.md |
Documents Rust usage. |
python/test_github_token_provider.py |
Tests Python provider behavior. |
python/README.md |
Documents Python usage. |
python/copilot/session.py |
Adds disconnect cleanup callback. |
python/copilot/client.py |
Implements registration and dispatch. |
python/copilot/__init__.py |
Exports provider types. |
nodejs/test/github-token-provider.test.ts |
Tests TypeScript provider behavior. |
nodejs/src/types.ts |
Defines provider types and configuration. |
nodejs/src/session.ts |
Adds disconnect cleanup hook. |
nodejs/src/index.ts |
Exports provider types. |
nodejs/src/client.ts |
Implements provider lifecycle and dispatch. |
nodejs/README.md |
Documents TypeScript usage. |
java/sdk/src/test/java/com/github/copilot/SessionRequestBuilderTest.java |
Tests wire casing and redaction. |
java/sdk/src/test/java/com/github/copilot/RpcHandlerDispatcherTest.java |
Tests callback dispatch. |
java/sdk/src/test/java/com/github/copilot/JsonRpcClientTest.java |
Tests diagnostic redaction. |
java/sdk/src/test/java/com/github/copilot/GitHubTokenProviderRegistryTest.java |
Tests registry ownership. |
java/sdk/src/main/java/com/github/copilot/RpcHandlerDispatcher.java |
Dispatches provider callbacks. |
java/sdk/src/main/java/com/github/copilot/rpc/SessionConfig.java |
Adds create provider configuration. |
java/sdk/src/main/java/com/github/copilot/rpc/ResumeSessionRequest.java |
Adds resume registration field. |
java/sdk/src/main/java/com/github/copilot/rpc/ResumeSessionConfig.java |
Adds resume provider configuration. |
java/sdk/src/main/java/com/github/copilot/rpc/GitHubTokenProviderResult.java |
Defines provider results. |
java/sdk/src/main/java/com/github/copilot/rpc/GitHubTokenProviderArgs.java |
Defines callback arguments. |
java/sdk/src/main/java/com/github/copilot/rpc/GitHubTokenProvider.java |
Defines provider interface. |
java/sdk/src/main/java/com/github/copilot/rpc/CreateSessionRequest.java |
Adds create registration field. |
java/sdk/src/main/java/com/github/copilot/JsonRpcClient.java |
Redacts credential diagnostics. |
java/sdk/src/main/java/com/github/copilot/GitHubTokenProviderRegistry.java |
Implements provider registry. |
java/sdk/src/main/java/com/github/copilot/CopilotSession.java |
Owns registration cleanup. |
java/sdk/src/main/java/com/github/copilot/CopilotClient.java |
Integrates provider lifecycle. |
java/README.md |
Documents Java usage. |
go/types.go |
Adds provider configuration and wire fields. |
go/session.go |
Releases session registrations. |
go/README.md |
Documents Go usage. |
go/github_token_provider.go |
Defines Go provider API. |
go/github_token_provider_test.go |
Tests Go provider lifecycle. |
go/client.go |
Implements provider dispatch and ownership. |
dotnet/test/Unit/ClientSessionLifetimeTests.cs |
Tests .NET provider behavior. |
dotnet/src/Types.cs |
Adds provider configuration. |
dotnet/src/Session.cs |
Owns registration cleanup. |
dotnet/src/JsonRpc.cs |
Supports polymorphic callback responses. |
dotnet/src/GitHubTokenProvider.cs |
Defines .NET provider API. |
dotnet/src/Client.cs |
Implements provider registration and dispatch. |
dotnet/README.md |
Documents .NET usage. |
docs/setup/multi-tenancy.md |
Recommends rotating credentials. |
docs/auth/authenticate.md |
Adds cross-language guidance. |
CHANGELOG.md |
Records the new feature. |
Review details
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Suppressed comments (3)
nodejs/src/client.ts:2039
- A failed resume removes the newly registered session from
this.sessionsbut does not restore the session object that was there before the attempt. The new provider registration is rolled back here, while the previous provider remains registered but its session can no longer receive routed callbacks/events. Preserve the prior session before replacement and restore it conditionally on failure, as the Go and Java paths do.
python/copilot/client.py:3583 - The rollback removes the new registration, but the resume path overwrote
_sessions[session_id]before the RPC and then pops that entry on failure without restoring the prior session. Consequently a failed provider replacement leaves the old provider registered but drops routing for the still-valid old session. Save and conditionally restore the previous session as part of this rollback.
dotnet/src/Client.cs:1517 - The resume path has no transactional ownership handoff for an existing session. On success this transfers the new registration but never retires the replaced session's registration, leaving the old callback callable; on failure
session?.RemoveFromClient()removes the new entry without restoring the prior session mapping. Track the replaced session and commit or roll back both the session map and provider ownership together.
if (registrationId is not null)
{
session.SetGitHubTokenProviderRegistration(registrationId);
registrationTransferred = true;
- Files reviewed: 53/53 changed files
- Comments generated: 7
- Review effort level: Balanced
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a447a8bc-8687-47ea-a545-4370979e8128
Release session-owned provider registrations after successful session deletion and treat empty static .NET tokens as configured for mutual-exclusion validation. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a447a8bc-8687-47ea-a545-4370979e8128
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
SteveSandersonMS
left a comment
There was a problem hiding this comment.
Looks great. I did a review pass and it didn't come up with anything other than commentary on the design tradeoffs, all of which look very reasonable.
Order the new GitHub token re-export according to the nightly rustfmt configuration used by CI. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a447a8bc-8687-47ea-a545-4370979e8128
Cross-SDK Consistency Review ✅This PR adds session-scoped GitHub token providers to .NET, Go, and Java — completing the feature across all six SDKs (Node.js, Python, and Rust already had the feature). API surface consistency check:
All implementations:
No cross-SDK consistency issues found.
|
Why
The runtime now supports a session-scoped GitHub credential authority backed by either the existing static
gitHubTokenor an expiry-aware callback. SDK users need an idiomatic callback API without handling registration IDs or raw JSON-RPC dispatch.Runtime context: https://github.com/github/copilot-agent-runtime/pull/16381
What
gitHubTokenand reject configuring static and callback credentials together.expiresInsemantics, typical eight-hour GitHub tokens, cancellation, and the intentionally absent retry/challenge/upscope behavior.Testing
ty, provider tests (6 passed)go test .andgo test -race .DOTNET_ROLL_FORWARD=Majorbecause only .NET 10 is installed locally)verify -DskipITs(7 passed)git diff --checkValidation notes
matchexample using the machine's older system Python;mypyis also unavailable in that interpreter.ErgonomicToolDefinitionITtimed out; the focused verify gate passed.openaidependency. Repository-wide Pythonty checkretains unrelated pre-existing diagnostics; changed Python files pass.