Skip to content

SDK: add optional memory configuration to session create and resume#1617

Open
Morabbin wants to merge 9 commits into
github:mainfrom
Morabbin:morabbin/rust-session-memory-config
Open

SDK: add optional memory configuration to session create and resume#1617
Morabbin wants to merge 9 commits into
github:mainfrom
Morabbin:morabbin/rust-session-memory-config

Conversation

@Morabbin

@Morabbin Morabbin commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds an optional, typed memory configuration to session creation and resume across the SDK languages (Rust, Go, Node, Python, .NET, and Java).

A new MemoryConfiguration type carries the memory feature's settings, and a memory option is available on the session create and resume configuration in each language.

use github_copilot_sdk::types::MemoryConfiguration;

let config = SessionConfig::default().with_memory(MemoryConfiguration::enabled());
let session = client.create_session(config).await?;

Details

  • MemoryConfiguration carries enabled today and is extensible: further tuning knobs can be added as optional fields without a breaking change.
  • The option is accepted on both create and resume in every language, following each SDK's existing configuration idiom.
  • It serializes as an optional memory object on the session.create / session.resume requests (for example { "memory": { "enabled": true } }), and is omitted from the wire when unset.
  • Defaulting follows the client mode: in the default copilot-cli mode the SDK leaves memory unset so the runtime applies its own default, while in empty mode memory defaults to disabled unless the caller supplies a value. A caller-supplied configuration always wins.

Tests

  • Per-language unit tests for MemoryConfiguration construction/serialization and for the create/resume wire payload (memory present with enabled, omitted when unset).
  • Unit tests for the mode-based default: empty mode defaults memory to disabled, copilot-cli mode leaves it unset, and a caller-supplied value wins in either mode.

Docs

  • "Memory" section in each language's README documenting the session configuration and its mode-based defaulting.

@Morabbin Morabbin marked this pull request as ready for review June 10, 2026 12:22
@Morabbin Morabbin requested a review from a team as a code owner June 10, 2026 12:22
Copilot AI review requested due to automatic review settings June 10, 2026 12: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.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a per-session “memory” configuration that can be sent over the wire when creating or resuming sessions, plus SDK docs/tests for the new feature.

Changes:

  • Introduce MemoryConfiguration and expose it via SessionConfig / ResumeSessionConfig builder APIs.
  • Extend wire request structs to serialize an optional memory field.
  • Add serialization/unit tests and README documentation for configuring memory.
Show a summary per file
File Description
rust/src/wire.rs Adds optional memory field to session create/resume wire payloads.
rust/src/types.rs Defines MemoryConfiguration, threads it through config structs, and adds tests.
rust/README.md Documents how to enable/disable memory per session.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 2

Comment thread rust/src/types.rs Outdated
Comment thread rust/README.md
@Morabbin Morabbin requested a review from Copilot June 10, 2026 13:55
Morabbin and others added 4 commits June 10, 2026 14:55
Add a `MemoryConfiguration` type and a `memory` option on `SessionConfig`
and `ResumeSessionConfig`, with `with_memory` builders. The configuration
serializes as an optional `memory` object on the `session.create` /
`session.resume` requests and is omitted when unset, so the runtime applies
its own default for the memory feature.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep the runtime-default note only on the MemoryConfiguration type
comment; drop it from the field and builder docs. In the README, drop
the runtime-default note (no sibling feature section mentions runtime
defaults), fix the trailing colon so the code block reads as a usage
example, and remove the extensibility aside.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
No other SessionConfig / ResumeSessionConfig builder method carries a
usage-example doctest; keep with_memory consistent with its siblings.
The README retains a usage example.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
MemoryConfiguration exposes explicit enabled()/disabled() constructors, so a
Default impl is redundant. SessionConfig and ResumeSessionConfig hold memory as
Option<MemoryConfiguration>, which defaults to None without requiring
MemoryConfiguration: Default.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 1

Comment thread rust/README.md Outdated
@Morabbin Morabbin force-pushed the morabbin/rust-session-memory-config branch from 7e5e217 to 74c0b28 Compare June 10, 2026 13:59
@Morabbin Morabbin requested a review from Copilot June 10, 2026 14:00

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's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 3

Comment thread rust/src/wire.rs
Comment thread rust/src/wire.rs
Comment thread rust/README.md
@Morabbin Morabbin marked this pull request as draft June 10, 2026 14:59
@Morabbin Morabbin changed the title Rust SDK: add optional memory configuration to session create and resume SDK: add optional memory configuration to session create and resume Jun 10, 2026
@Morabbin Morabbin requested a review from Copilot June 10, 2026 15:00

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's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 2

Comment thread rust/src/wire.rs
Comment on lines 134 to 139
#[serde(skip_serializing_if = "Option::is_none")]
pub model_capabilities: Option<ModelCapabilitiesOverride>,
#[serde(skip_serializing_if = "Option::is_none")]
pub memory: Option<MemoryConfiguration>,
#[serde(skip_serializing_if = "Option::is_none")]
pub config_dir: Option<PathBuf>,
Comment thread rust/README.md
### Memory

Configure the runtime memory feature for a session:

Mirror the Rust session memory surface across the remaining SDK
languages: session create and resume accept an optional memory
configuration carrying a required `enabled` flag, omitted from the
wire when unset. Adds the type, the create/resume wiring, clone and
serialization coverage, and README docs per language.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread python/copilot/client.py Fixed
@Morabbin Morabbin marked this pull request as ready for review June 10, 2026 16:18
Apply the empty-mode SDK default for the `memory` session option across all
language SDKs: in `empty` client mode `memory` defaults to disabled unless the
app supplies a value, while in the default `copilot-cli` mode `memory` is left
unset so the runtime applies its own default. Caller-supplied configuration
always wins. Adds unit tests (Rust, Go, Node, Python) and a README note per
language.

Also break a module-level cyclic import in the Python client by importing
`MemoryConfiguration` under `TYPE_CHECKING` (it is only referenced in
annotations, which are lazy via `from __future__ import annotations`).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread python/copilot/client.py Fixed
@Morabbin Morabbin requested a review from Copilot June 10, 2026 20:05

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's findings

Comments suppressed due to low confidence (2)

python/copilot/session.py:1

  • The dict keys emitted by _capabilities_to_dict are snake_case (e.g. max_prompt_tokens, supported_media_types), but the rest of the SDK wire format consistently uses camelCase (and reasoningEffort is already camelCase in this same function). This likely produces a payload shape the runtime won’t recognize for model capability overrides. Convert these keys to the expected wire names (e.g. maxPromptTokens, maxOutputTokens, maxContextWindowTokens, and supportedMediaTypes / maxPromptImages / maxPromptImageSize).
    rust/README.md:1
  • This example uses SessionConfig but doesn’t import or qualify it, so it won’t compile as-written even ignoring the ,ignore hint. Consider adding the missing import (e.g. importing SessionConfig alongside MemoryConfiguration) or qualifying SessionConfig to make the snippet copy/pasteable.
  • Files reviewed: 37/37 changed files
  • Comments generated: 1

Comment thread python/copilot/client.py
Comment on lines +184 to +186
def _memory_to_wire(config: Mapping[str, Any]) -> dict[str, Any]:
"""Convert a ``MemoryConfiguration`` mapping to wire format."""
return {"enabled": config["enabled"]}
- Fix Python payload keys for ModelCapabilitiesOverride serialization to match wire format (camelCase instead of snake_case)
- Update Rust README example to include SessionConfig import
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.

3 participants