Skip to content

feat: add session.getMetadata to all SDK languages#899

Draft
MackinnonBuck wants to merge 1 commit intomainfrom
add-get-session-metadata
Draft

feat: add session.getMetadata to all SDK languages#899
MackinnonBuck wants to merge 1 commit intomainfrom
add-get-session-metadata

Conversation

@MackinnonBuck
Copy link
Collaborator

Motivation

The runtime now exposes a session.getMetadata JSON-RPC method (copilot-agent-runtime#5021) that provides efficient O(1) lookup of a single session's metadata by ID — avoiding the need to call session.list and filter client-side. This PR exposes that endpoint in all four SDK language bindings.

Approach

Each SDK already has listSessions returning SessionMetadata[]. The new method reuses the same SessionMetadata type (no new public types needed) but returns a single optional result. When the session is not found, the method returns the language-idiomatic "absent" value rather than throwing an error.

SDK Method Return type Not-found value
Node.js getSessionMetadata(sessionId) Promise<SessionMetadata | undefined> undefined
Python get_session_metadata(session_id) SessionMetadata | None None
Go GetSessionMetadata(ctx, sessionID) (*SessionMetadata, error) nil
.NET GetSessionMetadataAsync(sessionId, ct) Task<SessionMetadata?> null

Changes

  • Node.js — New method in client.ts with full JSDoc; skipped E2E test (matching existing listSessions skip pattern)
  • Python — New method in client.py with docstring; running E2E test (Python/Go session lifecycle tests are live)
  • Go — New method in client.go, internal request/response structs in types.go; running E2E test
  • .NET — New method in Client.cs, internal records + [JsonSerializable] registration; skipped E2E test
  • Snapshottest/snapshots/session/should_get_session_metadata.yaml for the replay proxy

Notes

  • E2E tests in Node.js and .NET are skipped with the same TODO as the existing listSessions tests ("Re-enable once test harness CAPI proxy supports this test's session lifecycle"). Python and Go E2E tests are running, consistent with their existing session lifecycle tests.
  • All E2E tests cover both the happy path (create session → get metadata → verify fields) and the not-found case.

Add a new getSessionMetadata method across all four SDK language bindings
(Node.js, Python, Go, .NET) that provides efficient O(1) lookup of a
single session's metadata by ID via the session.getMetadata JSON-RPC
endpoint.

Changes per SDK:
- Node.js: getSessionMetadata() in client.ts + skipped E2E test
- Python: get_session_metadata() in client.py + running E2E test
- Go: GetSessionMetadata() in client.go + types in types.go + running E2E test
- .NET: GetSessionMetadataAsync() in Client.cs + skipped E2E test

Also adds test/snapshots/session/should_get_session_metadata.yaml for
the E2E test replay proxy.

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

✅ Cross-SDK Consistency Review

I've reviewed this PR for consistency across all four SDK implementations (Node.js, Python, Go, and .NET). This PR maintains excellent cross-language consistency!

Summary

This PR successfully adds the session.getMetadata RPC method to all four SDK languages with consistent:

API Design

  • Node.js: getSessionMetadata(sessionId)Promise(SessionMetadata | undefined)
  • Python: get_session_metadata(session_id)SessionMetadata | None
  • Go: GetSessionMetadata(ctx, sessionID)(*SessionMetadata, error)
  • .NET: GetSessionMetadataAsync(sessionId, ct)Task(SessionMetadata?)

All follow language-specific naming conventions (camelCase, snake_case, PascalCase) and return idiomatic "not found" values (undefined, None, nil, null).

Implementation Pattern

  • All SDKs reuse the existing SessionMetadata type (no new types needed)
  • All call the same JSON-RPC method: session.getMetadata
  • All properly check client connection state before making the call
  • All handle the not-found case gracefully without throwing errors

Documentation

  • Consistent descriptions across all languages emphasizing O(1) efficiency
  • Similar code examples demonstrating usage
  • Proper parameter and return type documentation

Test Coverage

  • Node.js and .NET: Tests present but skipped (matching existing listSessions pattern with same TODO)
  • Python and Go: Active E2E tests (consistent with their existing session lifecycle test patterns)
  • All tests cover both success and not-found cases
  • Shared snapshot file: test/snapshots/session/should_get_session_metadata.yaml

No Consistency Issues Found

This PR maintains feature parity and consistent API design across all SDK implementations. Great work! 🎉

Generated by SDK Consistency Review Agent for issue #899 ·

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