Skip to content

Rust SDK: add typed SessionCapability enum and ClientOptions builders#1455

Draft
Morabbin wants to merge 1 commit into
github:mainfrom
Morabbin:morabbin/rust-typed-session-capabilities
Draft

Rust SDK: add typed SessionCapability enum and ClientOptions builders#1455
Morabbin wants to merge 1 commit into
github:mainfrom
Morabbin:morabbin/rust-typed-session-capabilities

Conversation

@Morabbin
Copy link
Copy Markdown
Contributor

Why

Fixes the Desktop app missing memory capability issue (github/agents#981).

The Desktop SDK currently accepts only stringly-typed capability flags, making it error-prone and giving callers no discoverability. This PR introduces a typed SessionCapability enum so callers can write with_enable_capability(SessionCapability::Memory) instead of hand-rolling --enable-capability memory strings.

Pairs with the CLI flag plumbing in github/copilot-agent-runtime#8029.

What

  • New SessionCapability enum -- typed variants for all 10 current CLI capability names plus Other(String) for forward compatibility.
  • ClientOptions gains enabled_capabilities / disabled_capabilities vectors and four chainable builders: with_enable_capability, with_disable_capability, with_enabled_capabilities, with_disabled_capabilities.
  • Client::capability_args emits --enable-capability <name> / --disable-capability <name> flags (enables first, then disables, in insertion order) and is hooked into both spawn_stdio and spawn_tcp between remote_args and extra_args.
  • Disable-wins semantics: if the same capability appears in both lists, the disable wins.
  • README.md updated: new rows in the ClientOptions table, a new ### Session capabilities subsection, and a bullet in the Rust-only API section.
  • 11 new unit tests cover Display, FromStr, From<&str>, From<String>, serde round-trip, arg ordering, and disable-wins semantics.

Pre-existing test breakage (unrelated to this PR)

rust/tests/session_test.rs and rust/tests/protocol_version_test.rs are broken on main due to removed API methods (from_streams_with_trace_provider, from_streams_with_connection_token, etc.). These are pre-existing failures not caused by this change. Lib + doc tests and clippy (--lib) are all green.

Checklist

  • Linked issue: github/agents#981
  • cargo fmt --check passes
  • cargo clippy --lib -- -D warnings passes
  • cargo test --lib passes (137 tests)
  • cargo test --doc passes (19 tests)
  • cargo build passes
  • README updated

Adds a typed `SessionCapability` enum and matching `ClientOptions` fields
plus builder methods to the Rust SDK, so callers can express "enable
memory", "disable bash", etc. without stringly-typed flags.

- `SessionCapability` is `#[non_exhaustive]`, kebab-case-serialized, and
  has an `Other(String)` escape hatch for forward compatibility with
  capabilities the runtime adds.
- `ClientOptions` gains `enabled_capabilities` and `disabled_capabilities`
  vectors and four builders: `with_enable_capability`,
  `with_disable_capability`, `with_enabled_capabilities`,
  `with_disabled_capabilities`.
- `Client::capability_args` emits the corresponding CLI flags
  (enables first, then disables, in insertion order), threaded into
  both `spawn_stdio` and `spawn_tcp` between `remote_args` and
  `extra_args`. Disable wins on conflict.

Pairs with github/copilot-agent-runtime#8029 (CLI flags) and
github/agents#981 (Desktop missing memory capability).

11 new unit tests cover the enum's `Display`, `FromStr`,
`From<&str>`, `From<String>`, serde round-trip, and the
capability-args ordering / disable-wins semantics.

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings May 27, 2026 14:47
@Morabbin Morabbin requested a review from a team as a code owner May 27, 2026 14:47
@Morabbin Morabbin marked this pull request as draft May 27, 2026 15:06
@Morabbin Morabbin changed the title rust: add typed SessionCapability enum and ClientOptions builders Rust SDK: add typed SessionCapability enum and ClientOptions builders May 27, 2026
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.

1 participant