Add Rust SDK model allowlist support - #2512
Conversation
Expose create/resume allowlists and the generated live-session replacement RPC with focused contract tests. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
Review tier: Lite
Findings: 1
New issues introduced by this change (1)
| Severity | Finding |
|---|---|
rust/src/types.rs — This builder will happily accept an empty iterator and serialize an explicit empty allowlist, but… |
What changed in this PR
Adds Rust SDK support for a host-controlled allowlist of model IDs, enabling consistent restrictions during session create/resume and while updating a running session via a new RPC.
Changes:
- Added
allowed_modelstoSessionConfigandResumeSessionConfigwith wire serialization asallowedModels. - Introduced
session.model.setAllowedModelsRPC surface with typed request/result structs and routing constant. - Added/updated tests covering serialization, wire conversion, method routing, and result deserialization.
| File | Description |
|---|---|
| rust/src/types.rs | Adds allowed_models to session configs, builders, Debug/Default, and wire conversion; adds unit tests. |
| rust/src/wire.rs | Extends session create/resume wire structs to carry allowed_models. |
| rust/src/generated/api_types.rs | Adds RPC method constant and typed request/result DTOs for setAllowedModels. |
| rust/src/generated/rpc.rs | Adds typed SessionRpcModel::set_allowed_models method calling the new wire RPC. |
| rust/tests/session_test.rs | Adds integration-style test verifying method name, params, and deserialization for replace/clear flows. |
| rust/tests/api_types_test.rs | Adds contract/serialization tests for the new request/result types. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Preserve current main changes while resolving the generated API test conflict and clarify that empty model allowlists are rejected by the runtime. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Augment the Rust API schema until the pinned CLI release includes the paired runtime contract, while remaining a no-op once the method ships. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Thanks for the contribution! I ran this against the real pinned CLI (v1.0.83-4) to validate the runtime side:
The Could you hold off until the corresponding runtime contract actually ships in a released CLI, then resubmit generated purely from the real schema (and ideally across all SDKs, since this isn't Rust-specific)? For tracking, I've moved this to draft - please mark as ready to review when appropriate. |
Thanks for validating this against the pinned CLI. Agreed: this should not merge while the shipped runtime ignores the create/resume field and does not implement the live RPC. I will keep the PR in draft and retain the branch only for coordination with the paired runtime/app work. Once the contract is in a released CLI, the SDK surface should be regenerated from that shipped schema and evaluated consistently across the SDKs. |
Resolve the generated API test import conflict while preserving both Auto-tier and allowlist coverage. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Preserve sandbox bypass, session detach, Auto-tier, and allowlist generated API test coverage while resolving the latest base conflict. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
https://github.com/github/copilot-agent-runtime/pull/18943has merged and is being staged for prerelease! Reopening for review cc @SteveSandersonMS |
|
Thanks for flagging that the runtime PR merged — I re-checked before proceeding. I re-validated against the latest shipped CLI release (v1.0.84-1, published after your comment) as well as the versions in between (v1.0.83-5, v1.0.83, v1.0.84-0): none of their So github/copilot-agent-runtime#18943 merging is good progress, but per your own note it's only "staged for prerelease" — it hasn't reached a released CLI build yet, and this repo's pinned |
Pin CLI 1.0.84-2 and regenerate the shared and Java SDK contracts. Remove the temporary Rust schema augmentation, cover the generated Java live allowlist API, and adapt affected test constructors. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Preserve CLI 1.0.84-2 while adopting the release-based Java schema loader and retaining both allowlist and upstream session coverage. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Reconcile with SDK main and regenerate canonical release contracts while preserving typed Rust create/resume allowlists and live-session API coverage. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Retain typed Rust create/resume allowlists and live-session API coverage while adopting canonical released contracts and current SDK main. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
@SteveSandersonMS SDK main now pins the published CLI 1.0.84-8 prerelease, whose canonical schema includes session.model.setAllowedModels. This branch is reconciled with main, the temporary schema augmentation is gone, and the owned generated contracts reproduce from that release. The typed Rust create/resume allowlists and live-session replacement/clear API are ready for review; focused validation passed. |
Covers replace, explicit-empty rejection, and clear against the real bundled CLI (v1.0.84-8), which now ships the runtime contract. The existing tests only exercised the RPC against a mock JSON-RPC server; this closes the gap by validating actual runtime behavior. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Re-validated against the currently pinned CLI (v1.0.84-8), which now genuinely ships the runtime contract:
One gap: the existing tests (
|
SteveSandersonMS
left a comment
There was a problem hiding this comment.
Approving — runtime contract verified live against pinned CLI v1.0.84-8, codegen is clean, and I added a real E2E test for the setAllowedModels RPC (see comment above).

Users need a host-controlled subset of model IDs to apply consistently when creating, resuming, and updating sessions. This adds the Rust SDK contract needed to pass that restriction to the runtime without duplicating runtime validation or policy logic.
Summary
allowed_modelsfields and fluent builders toSessionConfigandResumeSessionConfig, serialized asallowedModelsand omitted when unrestricted.session.model.setAllowedModelsRPC request/result surface for replacing or clearing a running session's restriction.The SDK preserves exact caller-provided IDs; the runtime remains responsible for validation, policy intersection, fallback selection, and enforcement across child, sub-agent, Auto, and remote execution paths.
Testing
COPILOT_SKIP_CLI_DOWNLOAD=1 cargo test --all-features allowed_modelsCOPILOT_SKIP_CLI_DOWNLOAD=1 cargo test --all-features wire_flags_off_without_handlerscargo +nightly-2026-04-14 fmt --check