Skip to content

Draft: Support providing a custom session store#917

Draft
SteveSandersonMS wants to merge 1 commit intomainfrom
sdk-session-store-abstraction
Draft

Draft: Support providing a custom session store#917
SteveSandersonMS wants to merge 1 commit intomainfrom
sdk-session-store-abstraction

Conversation

@SteveSandersonMS
Copy link
Contributor

Not yet ready.

@SteveSandersonMS SteveSandersonMS force-pushed the sdk-session-store-abstraction branch 2 times, most recently from 5b7cfff to 152e970 Compare March 25, 2026 15:38
@github-actions
Copy link
Contributor

Cross-SDK Consistency Review

I've reviewed this PR for consistency with the other SDK implementations (Python, Go, and .NET). This PR introduces a custom session data store feature to the Node.js/TypeScript SDK only.

Summary of Changes

This PR adds:

  • SessionDataStoreConfig interface with a descriptor field and handler methods (load, append, truncate, list, delete)
  • New sessionDataStore option in CopilotClientOptions
  • Client-side RPC handlers via registerClientApiHandlers() that delegate storage operations to user-provided callbacks
  • Automatic registration of the data store when sessionDataStore is provided during connection
  • Test coverage in nodejs/test/e2e/session_store.test.ts

Consistency Gap Identified

Finding: This feature is not yet implemented in Python, Go, or .NET SDKs.

The equivalent configuration options in other SDKs are:

  • Python: SubprocessConfig and ExternalServerConfig (in python/copilot/client.py)
  • Go: ClientOptions struct (in go/types.go)
  • .NET: CopilotClientOptions class (in dotnet/src/Types.cs)

None of these currently have a sessionDataStore / session_data_store / SessionDataStore option.

Recommendation

Since this PR is marked as Draft and the body says "Not yet ready," I suggest:

  1. Consider this a phased rollout: If the goal is to validate the API design in Node.js first before implementing in other languages, that's a reasonable approach. Just ensure there's a plan to bring feature parity to other SDKs.

  2. For a consistent multi-language release, you may want to:

    • Add equivalent session_data_store support to Python (SubprocessConfig / client constructor)
    • Add SessionDataStore field to Go's ClientOptions struct
    • Add SessionDataStore property to .NET's CopilotClientOptions class
    • Ensure the handler interface (load, append, truncate, list, delete) is similarly structured across languages (accounting for naming conventions)
  3. API naming patterns to maintain:

    • Node.js: sessionDataStore (camelCase) ✅
    • Python: session_data_store (snake_case)
    • Go: SessionDataStore (PascalCase for public fields)
    • .NET: SessionDataStore (PascalCase)

Conclusion

No immediate action required since this is a draft PR. However, before marking this feature as generally available, consider implementing equivalent functionality in Python, Go, and .NET to maintain feature parity across the SDK suite. If this is intended as a Node.js-exclusive feature, that should be clearly documented with rationale.

Great work on the test coverage and RPC handler design! The approach is clean and extensible. 👍

Generated by SDK Consistency Review Agent for issue #917 ·

@github-actions
Copy link
Contributor

Cross-SDK Consistency Review

I've reviewed this PR for consistency across the four SDK implementations (Node.js/TypeScript, Python, Go, and .NET).

Summary

This PR introduces a custom session data store feature to the Node.js/TypeScript SDK only. This creates a feature parity gap with the other SDK implementations.

What This PR Adds

The PR adds a sessionDataStore option to CopilotClientOptions that allows applications to provide custom storage backends for session event persistence. Key aspects:

  1. New client option: sessionDataStore?: SessionDataStoreConfig in CopilotClientOptions
  2. Handler interface: SessionDataStoreHandler with methods: load(), append(), truncate(), list(), delete()
  3. Client API RPC registration: New registerClientApiHandlers() function that sets up bi-directional RPC handlers
  4. Automatic registration: When configured, the client calls sessionDataStore.setDataStore on connection and registers RPC handlers for the CLI to invoke

Cross-SDK Status

SDK Custom Session Store Support
Node.js/TypeScript ✅ Added in this PR
Python ❌ Not implemented
Go ❌ Not implemented
.NET ❌ Not implemented

Recommendation

To maintain feature parity, this capability should be added to the other three SDKs. Here's how it would map to each language's conventions:

Python (python/copilot/client.py)

  • Add session_data_store?: SessionDataStoreConfig to connection config (matching snake_case convention)
  • Create SessionDataStoreHandler protocol/interface with async methods
  • Example:
`@dataclass`
class SessionDataStoreConfig:
    descriptor: str
    load: Callable[[SessionDataStoreLoadParams], Awaitable[SessionDataStoreLoadResult]]
    append: Callable[[SessionDataStoreAppendParams], Awaitable[None]]
    truncate: Callable[[SessionDataStoreTruncateParams], Awaitable[SessionDataStoreTruncateResult]]
    list: Callable[[], Awaitable[SessionDataStoreListResult]]
    delete: Callable[[SessionDataStoreDeleteParams], Awaitable[None]]

Go (go/client.go, go/types.go)

  • Add SessionDataStore *SessionDataStoreConfig to ClientOptions (matching Go naming)
  • Create SessionDataStoreHandler interface
  • Example:
type SessionDataStoreHandler interface {
    Load(ctx context.Context, params SessionDataStoreLoadParams) (*SessionDataStoreLoadResult, error)
    Append(ctx context.Context, params SessionDataStoreAppendParams) error
    Truncate(ctx context.Context, params SessionDataStoreTruncateParams) (*SessionDataStoreTruncateResult, error)
    List(ctx context.Context) (*SessionDataStoreListResult, error)
    Delete(ctx context.Context, params SessionDataStoreDeleteParams) error
}

type SessionDataStoreConfig struct {
    Descriptor string
    Handler    SessionDataStoreHandler
}

.NET (dotnet/src/Types.cs, dotnet/src/Client.cs)

  • Add SessionDataStore property to CopilotClientOptions (PascalCase)
  • Create ISessionDataStoreHandler interface or callback delegates
  • Example:
public interface ISessionDataStoreHandler
{
    Task(SessionDataStoreLoadResult) LoadAsync(SessionDataStoreLoadParams parameters, CancellationToken cancellationToken = default);
    Task AppendAsync(SessionDataStoreAppendParams parameters, CancellationToken cancellationToken = default);
    Task(SessionDataStoreTruncateResult) TruncateAsync(SessionDataStoreTruncateParams parameters, CancellationToken cancellationToken = default);
    Task(SessionDataStoreListResult) ListAsync(CancellationToken cancellationToken = default);
    Task DeleteAsync(SessionDataStoreDeleteParams parameters, CancellationToken cancellationToken = default);
}

public sealed class SessionDataStoreConfig
{
    public required string Descriptor { get; init; }
    public required ISessionDataStoreHandler Handler { get; init; }
}

Notes

  • This is marked as a draft PR with "Not yet ready" in the description, so it may still be in development
  • The feature is valuable for applications that need custom storage (e.g., Redis, PostgreSQL, cloud storage)
  • Given that this is a draft, consider whether implementation should happen across all SDKs before merging, or if language-specific rollout is acceptable
  • The E2E tests added (nodejs/test/e2e/session_store.test.ts) demonstrate the feature thoroughly, which will be helpful when implementing in other languages

Would you like me to create tracking issues for the other SDK implementations, or is this intentionally a Node.js-only feature for now?

Generated by SDK Consistency Review Agent for issue #917 ·

- Add sessionDataStore option to CopilotClientOptions
- Extend codegen to generate client API handler types (SessionDataStoreHandler)
- Register as session data storage provider on connection via sessionDataStore.setDataStore RPC
- Add E2E tests for persist, resume, list, delete, and reject scenarios

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@SteveSandersonMS SteveSandersonMS force-pushed the sdk-session-store-abstraction branch from 152e970 to 3d11cff Compare March 25, 2026 15:45
@github-actions
Copy link
Contributor

Cross-SDK Consistency Review

This PR introduces a significant new feature: custom session data storage backend support via the sessionDataStore option. However, this feature is currently only implemented in the Node.js/TypeScript SDK.

What This PR Adds (Node.js/TypeScript only)

  1. New client option: sessionDataStore in CopilotClientOptions that allows providing custom callbacks for:

    • load(sessionId) - Load session events from storage
    • append(sessionId, events) - Append new events to storage
    • truncate(sessionId, upToEventId) - Truncate old events (compaction)
    • list() - List all sessions in storage
    • delete(sessionId) - Delete a session from storage
  2. Generated RPC types: New SessionDataStore* types in generated/rpc.ts including handler interfaces and registration helpers

  3. Integration: The client automatically calls sessionDataStore.setDataStore on connection and registers RPC handlers to route storage operations to the provided callbacks

  4. E2E tests: Comprehensive test suite demonstrating the feature with an in-memory store implementation

Missing From Other SDKs

Python (python/copilot/)

  • ❌ No session_data_store option in client configuration
  • ❌ No equivalent handler interface or callbacks
  • ❌ No tests for this feature

Go (go/)

  • ❌ No SessionDataStore field in ClientOptions
  • ❌ No equivalent handler interface or callbacks
  • ❌ No tests for this feature

.NET (dotnet/src/)

  • ❌ No SessionDataStore property in CopilotClientOptions
  • ❌ No equivalent handler interface or callbacks
  • ❌ No tests for this feature

Recommendation

This is a valuable feature for users who want to:

  • Store session state in Redis, databases, or other persistence layers
  • Implement custom retention/archival policies
  • Share session state across distributed systems

To maintain SDK consistency, this feature should be implemented across all four SDKs with equivalent APIs (accounting for language conventions):

  • Python: session_data_store parameter with Protocol or ABC defining required methods
  • Go: SessionDataStore field in ClientOptions with interface type defining required methods
  • .NET: SessionDataStore property in CopilotClientOptions with interface defining required methods

Each SDK should follow the same pattern established here:

  1. Client option to provide storage handlers
  2. Automatic registration on connection via sessionDataStore.setDataStore RPC
  3. Handler callbacks invoked by the CLI server for persistence operations
  4. E2E tests with an in-memory store implementation

Note: This PR is marked as draft and states "Not yet ready", so there may be time to implement this feature across all SDKs before merging. If the intent is to ship this feature incrementally (Node.js first), please add tracking issues for the other SDKs and update their respective roadmaps/documentation to note the feature gap.

Generated by SDK Consistency Review Agent for issue #917 ·

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