feat: add session.getMetadata to all SDK languages#899
feat: add session.getMetadata to all SDK languages#899MackinnonBuck wants to merge 6 commits intomainfrom
Conversation
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>
✅ Cross-SDK Consistency ReviewI've reviewed this PR for consistency across all four SDK implementations (Node.js, Python, Go, and .NET). This PR maintains excellent cross-language consistency! SummaryThis PR successfully adds the ✅ API Design
All follow language-specific naming conventions (camelCase, snake_case, PascalCase) and return idiomatic "not found" values ( ✅ Implementation Pattern
✅ Documentation
✅ Test Coverage
No Consistency Issues FoundThis PR maintains feature parity and consistent API design across all SDK implementations. Great work! 🎉
|
|
@MackinnonBuck Looks like this is close to being ready. If you're waiting for review please let me know, but otherwise I'll hold off until the Go part is passing. |
✅ Cross-SDK Consistency ReviewThis PR demonstrates excellent cross-language consistency. The API Consistency ✓All four SDKs follow the same semantic pattern:
✅ Naming conventions: Properly adapted to each language (camelCase, snake_case, PascalCase) Documentation Consistency ✓All four implementations include:
Test Coverage Consistency ✓All four SDKs include E2E tests that:
Test status is correctly aligned with existing
Implementation Details ✓
No consistency issues found. This PR maintains excellent feature parity across the SDK implementations. 🎉
|
There was a problem hiding this comment.
Pull request overview
Exposes the new session.getMetadata JSON-RPC endpoint across all four SDKs to enable efficient per-session metadata lookup without calling session.list and filtering client-side.
Changes:
- Added session metadata lookup methods to Node, Python, Go, and .NET clients with language-idiomatic “not found” results.
- Added/updated E2E coverage (running in Python/Go; skipped in Node/.NET to match existing patterns).
- Added a replay-proxy snapshot for the new session metadata E2E scenario.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
test/snapshots/session/should_get_session_metadata.yaml |
Adds replay-proxy snapshot used by the new session-metadata E2E scenario. |
python/e2e/test_session.py |
Adds a running E2E test covering happy-path + not-found behavior for get_session_metadata. |
python/copilot/client.py |
Implements get_session_metadata(session_id) returning `SessionMetadata |
nodejs/test/e2e/session.test.ts |
Adds a skipped E2E test for getSessionMetadata (consistent with existing skipped lifecycle tests). |
nodejs/src/client.ts |
Implements getSessionMetadata(sessionId) returning SessionMetadata | undefined. |
go/types.go |
Adds internal request/response structs for session.getMetadata. |
go/internal/e2e/session_test.go |
Adds a running E2E subtest for GetSessionMetadata happy-path + not-found. |
go/client.go |
Implements GetSessionMetadata(ctx, sessionID) returning (*SessionMetadata, error) with nil for not-found. |
dotnet/test/SessionTests.cs |
Adds a skipped test for GetSessionMetadataAsync happy-path + not-found. |
dotnet/src/Client.cs |
Implements GetSessionMetadataAsync, adds internal request/response records, and registers them for source-gen JSON. |
- Fix Python copilot/client.py ruff format check by collapsing get_session_metadata method signature and request call to single lines - Fix Node.js session.test.ts assertion to check first message only, since CLI 1.0.11 now emits session.custom_agents_updated after session.start (matching the same fix needed on main)
CLI 1.0.11 makes a GET request to /agents/*/custom-agents/* during startup. The replay proxy had no handler for this endpoint, causing it to call onError and hang new CLI processes. This broke the 'should resume a session using a new client' and 'should produce deltas after session resume' E2E tests which spawn a second CopilotClient. Add a stub handler (returning empty agents list) matching the existing pattern used for memory endpoints.
✅ Cross-SDK Consistency ReviewThis PR demonstrates excellent consistency across all four SDK implementations. The API Design Consistency ✨All four SDKs follow parallel patterns accounting for language idioms:
Key Consistency Points ✅
Implementation Quality 🎯
No consistency issues found. This is a model example of feature parity across the SDK! 🚀
|
# Conflicts: # nodejs/test/e2e/session.test.ts
Motivation
The runtime now exposes a
session.getMetadataJSON-RPC method (copilot-agent-runtime#5021) that provides efficient O(1) lookup of a single session's metadata by ID — avoiding the need to callsession.listand filter client-side. This PR exposes that endpoint in all four SDK language bindings.Approach
Each SDK already has
listSessionsreturningSessionMetadata[]. The new method reuses the sameSessionMetadatatype (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.getSessionMetadata(sessionId)Promise<SessionMetadata | undefined>undefinedget_session_metadata(session_id)SessionMetadata | NoneNoneGetSessionMetadata(ctx, sessionID)(*SessionMetadata, error)nilGetSessionMetadataAsync(sessionId, ct)Task<SessionMetadata?>nullChanges
client.tswith full JSDoc; skipped E2E test (matching existinglistSessionsskip pattern)client.pywith docstring; running E2E test (Python/Go session lifecycle tests are live)client.go, internal request/response structs intypes.go; running E2E testClient.cs, internal records +[JsonSerializable]registration; skipped E2E testtest/snapshots/session/should_get_session_metadata.yamlfor the replay proxyNotes
listSessionstests ("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.