Skip to content

rust: forward cached models during session creation - #2660

Open
Chuxel wants to merge 2 commits into
mainfrom
chuxel-vigilant-parakeet
Open

Chuxel wants to merge 2 commits into
mainfrom
chuxel-vigilant-parakeet

Conversation

@Chuxel

@Chuxel Chuxel commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Why

The runtime already accepts a cached model catalog during session.create, but the Rust SDK does not expose or forward it. This leaves hosts unable to avoid the duplicate model-catalog fetch through the supported SDK API.

Related issue: https://github.com/github/copilot-agent-runtime/issues/17913
Runtime support (merged): https://github.com/github/copilot-agent-runtime/pull/18113
Changes

  • Expose CachedModel { id: String, supports_reasoning_effort: bool } and SessionConfig.cached_models: Option<Vec<CachedModel>>, plus the normal with_cached_models builder.
  • Forward only id and required supportsReasoningEffort in camelCase cachedModels entries. None omits the field, an empty list is authoritative and stays [], and false is preserved.
  • Keep this input exclusive to session.create; session.resume is unchanged. The SDK performs no new fetch, validation, or refresh. The runtime retains ownership of the asynchronous post-create refresh, and the consumer retains account/catalog policy.
  • Add four focused config-to-wire tests covering omission, empty and populated catalogs, and resume exclusion.

Only rust/src/types.rs and rust/src/wire.rs change. This PR targets latest upstream main; no release-prep targeting requirement was found. No consumer vendoring, dependency pins, runtime edits, or feature flags are included. The App must receive this API through normal canonical sync after SDK merge.

Validation

The new tests first failed to compile because the public API was missing. After implementation:

  • Nightly formatting check passed: cargo +nightly-2026-04-14 fmt --all -- --config-path .rustfmt.nightly.toml --check.
  • cargo clippy --all-features --all-targets -- -D warnings passed.
  • cargo test --all-features --lib types::tests passed all 70 tests, including the four new contract tests.
  • cargo test --all-features --no-run compiled the Rust unit and integration test targets.

Cargo validation used COPILOT_SKIP_CLI_DOWNLOAD=1 because these checks exercise SDK serialization and compilation, not runtime behavior. Runtime-backed E2E tests were not run.

Expose the runtime's cached-model validation input without adding model discovery or refresh behavior to the SDK. Preserve absent, empty, and explicit false values, and keep the field exclusive to session.create.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings September 15, 2026 01:22
@Chuxel
Chuxel requested a review from a team as a code owner September 15, 2026 01:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The focused changes are tested and have no unresolved blocking issues.

Review tier: Lite (auto)
Findings: None

Note

Copilot is running an experiment and ran this review at Lite.

What changed in this PR

Adds Rust SDK support for forwarding cached model metadata during session.create.

Changes:

  • Adds CachedModel and SessionConfig.cached_models.
  • Preserves omission, empty-list, and camelCase serialization semantics.
  • Adds focused wire-format tests while leaving session.resume unchanged.
File Description
rust/​src/​wire.rs Adds cachedModels to session creation payloads.
rust/​src/​types.rs Defines the cached-model API, builder, conversion, and tests.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@Chuxel
Chuxel marked this pull request as draft September 15, 2026 01:30
@Chuxel
Chuxel marked this pull request as ready for review September 15, 2026 20:06
Resolve adjacent Rust SessionConfig and SessionCreateWire additions by retaining both cached_models and allowed_models, including their defaults, debug fields, builders, and wire mappings.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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