Skip to content

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

Merged
SteveSandersonMS merged 15 commits into
github:mainfrom
Morabbin:morabbin/rust-session-memory-config
Jun 15, 2026
Merged

SDK: add optional memory configuration to session create and resume#1617
SteveSandersonMS merged 15 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, SessionConfig};

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 thread rust/README.md
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
Morabbin added 2 commits June 10, 2026 21:13
- Fix Python payload keys for ModelCapabilitiesOverride serialization to match wire format (camelCase instead of snake_case)
- Update Rust README example to include SessionConfig import
@Morabbin Morabbin requested a review from Copilot June 15, 2026 11:03
The Node.js SDK Tests (windows-latest) leg failed on an unrelated, flaky
end-to-end test (test/e2e/rpc_session_state.e2e.test.ts, model switchTo:
expected claude-sonnet-4.5, received gpt-4.1). This PR only changes the
memory configuration RPC surface and does not touch model switching or
session-state code. The same base commit (Update @github/copilot to 1.0.62)
passes this leg on main.

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: 37/37 changed files
  • Comments generated: 1

Comment thread python/copilot/_mode.py
@Morabbin Morabbin requested a review from Copilot June 15, 2026 11:08

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 (3)

rust/src/wire.rs:1

  • memory is an Option<> but it’s missing #[serde(skip_serializing_if = \"Option::is_none\")]. As written, memory: None will serialize as \"memory\": null, which conflicts with the intended/covered behavior (omitting when unset). Add the skip attribute on the memory field (and keep the existing one on config_dir).
    rust/src/wire.rs:1
  • Same issue as SessionCreateWire: memory is missing #[serde(skip_serializing_if = \"Option::is_none\")], so an unset value will serialize as null instead of being omitted. Add the skip attribute to memory.
    python/copilot/client.py:1
  • This file used to define (and therefore export) ModelLimitsOverride, ModelSupportsOverride, and ModelVisionLimitsOverride, but it now imports only ModelCapabilitiesOverride. If copilot.client.*Override imports are part of the supported API surface, consider re-exporting the other override dataclasses here as imports from copilot.session to preserve compatibility.
"""
  • Files reviewed: 37/37 changed files
  • Comments generated: 1

Comment thread python/copilot/client.py
Type _memory_default's supplied parameter and return value as
MemoryConfiguration | None instead of Any, matching the type specificity of
the other mode-default helpers and recovering the benefit of the
MemoryConfiguration TypedDict. The type is imported under TYPE_CHECKING (with
the module's existing 'from __future__ import annotations') so no runtime
import edge is added between _mode and session.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Morabbin Morabbin requested a review from Copilot June 15, 2026 11:23

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 (1)

rust/src/wire.rs:1

  • memory is missing #[serde(skip_serializing_if = \"Option::is_none\")], so None will serialize as \"memory\": null instead of being omitted. This also conflicts with the new tests that assert the field is omitted when unset. Add skip_serializing_if directly on the memory field (and likewise for the resume wire struct).
  • Files reviewed: 37/37 changed files
  • Comments generated: 3

Comment thread java/src/main/java/com/github/copilot/CopilotClient.java
Comment thread python/copilot/client.py
Comment thread python/copilot/_mode.py

@SteveSandersonMS SteveSandersonMS 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.

Excellent - thanks!

@SteveSandersonMS SteveSandersonMS added this pull request to the merge queue Jun 15, 2026
Merged via the queue into github:main with commit 86df7e5 Jun 15, 2026
39 checks passed
krukow added a commit to copilot-community-sdk/copilot-sdk-clojure that referenced this pull request Jun 18, 2026
* chore(schema): bump CLI schema 1.0.61 -> 1.0.63 and regenerate

Pins @github/copilot to 1.0.63 and regenerates generated/event_specs.clj
from the refreshed JSON Schemas. Pulls in new wire surface: the
session.todos_changed event, optional AssistantUsageData fields
(contentFilterTriggered, finishReason), ToolExecutionCompleteResult
structuredContent, ToolExecutionStartData toolDescription, and the
plugin/session ExtensionSource values.

Upstream: github/copilot-sdk#1686 (1.0.63),
commit a115246a (1.0.62).

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

* feat(sync): port post-v1.0.1 config, lifecycle, and event additions

Adds the public-SDK surface introduced upstream after v1.0.1:

- :memory session config ({:enabled boolean}) forwarded on both
  create-session and resume-session, omitted when unset.
  github/copilot-sdk#1617
- :otlp-protocol telemetry option mapped to OTEL_EXPORTER_OTLP_PROTOCOL.
  github/copilot-sdk#1648
- Graceful runtime.shutdown in stop! for SDK-owned processes, bounded by
  a 10s timeout; force-stop! left unchanged.
  github/copilot-sdk#1667
- :mcp-defer-tools (#{:auto :never}) on MCP stdio/http server configs,
  rendered as deferTools on the wire (1.0.63 schema).
- :token-prices on ::model-billing.
  github/copilot-sdk#1633
- Optional event-data fields surfaced by the 1.0.63 schema
  (assistant.usage content-filter/finish-reason,
  tool.execution_complete structured-content) and the
  :copilot/session.todos_changed public event.

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

* test(sync): cover memory, otlp, graceful shutdown, and deferTools

Adds integration coverage for the new session config and wire mappings,
mock-server handling for the runtime.shutdown RPC, and process-level
assertions for graceful termination ordering.

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

* docs(sync): document new config and bump version to 1.0.1.1

Documents :memory, :otlp-protocol, MCP :defer-tools, :token-prices,
the session.todos_changed event, and graceful shutdown across API.md,
the MCP overview, and CHANGELOG. Bumps the Clojure patch to 1.0.1.1.

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

* fix(sync): address Copilot review feedback

Resolve four findings from the Copilot Code Review bot on PR #139:

- process.clj: preserve the thread interrupt flag in wait-for-exit!.
  .waitFor throws InterruptedException (a subclass of Exception), so the
  generic catch was swallowing it and clearing the interrupt flag. Catch
  it separately and re-set the flag via (.interrupt (Thread/currentThread))
  so callers still observe cancellation.
- util.clj: correct the mcp-server->wire docstring example. clj->wire
  produces camelCase keyword keys, not string keys.
- specs.clj: fix the memory-config comment to cite upstream PR #1617
  (not #1638).
- CHANGELOG.md: drop the nonexistent ::memory-enabled spec reference;
  only ::memory exists (reusing the existing ::enabled spec).

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

* docs(sync): drop non-exposed RPC method reference from todos_changed row

The session.todos_changed event reference pointed Clojure users at
session.plan.readSqlTodosWithDependencies(), a TS-style method call for
an @experimental upstream method this SDK does not expose. Reword the row
as signal-only with no payload, consistent with how the rest of the doc
names JSON-RPC methods.

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

---------

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.

4 participants