Skip to content

Add getSessionMetadata for O(1) session lookup by ID#30

Draft
brunoborges wants to merge 2 commits intomainfrom
feat/add-get-session-metadata
Draft

Add getSessionMetadata for O(1) session lookup by ID#30
brunoborges wants to merge 2 commits intomainfrom
feat/add-get-session-metadata

Conversation

@brunoborges
Copy link
Copy Markdown
Collaborator

@brunoborges brunoborges commented Mar 25, 2026

Ports upstream copilot-sdk PR #899 to the Java SDK. Adds a new getSessionMetadata(String sessionId) method to CopilotClient that calls the session.getMetadata JSON-RPC endpoint for efficient O(1) single-session metadata lookup. Returns null when the session is not found (Java-idiomatic absent value).


Before the change?

  • No way to look up a single session's metadata by ID — callers had to use listSessions() and filter client-side.

After the change?

  • CopilotClient.java — New getSessionMetadata(String) method following the same pattern as listSessions/deleteSession
  • GetSessionMetadataResponse.java — New response DTO record (@since 1.2.0) for the session.getMetadata RPC call
  • SessionMetadata.java — Updated Javadoc with @see tag referencing the new method
  • CopilotSessionTest.java — New @Disabled E2E test; disabled because the should_get_session_metadata snapshot was added by upstream PR #899 and won't be available until .lastmerge is advanced past that PR

Upstream reference

SDK Method Return type Not-found value
Java getSessionMetadata(sessionId) CompletableFuture<SessionMetadata> null

Pull request checklist

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)
  • mvn spotless:apply has been run to format the code
  • mvn clean verify passes locally

Does this introduce a breaking change?

  • Yes
  • No


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Port upstream copilot-sdk PR #899 to Java SDK. Adds a new
getSessionMetadata(sessionId) method to CopilotClient that calls the
session.getMetadata JSON-RPC endpoint for efficient single-session
metadata lookup. Returns null when the session is not found.

Changes:
- CopilotClient: new getSessionMetadata(String) method
- GetSessionMetadataResponse: new response DTO record
- SessionMetadata: updated Javadoc to reference new method
- CopilotSessionTest: new @disabled E2E test (matching upstream skip
  pattern for session lifecycle tests)

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

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Ports upstream support for O(1) session metadata lookup by adding a new CopilotClient#getSessionMetadata(String) API that calls the session.getMetadata JSON-RPC endpoint, plus the associated response DTO and test scaffolding.

Changes:

  • Add CopilotClient#getSessionMetadata(String) that returns SessionMetadata (or null if not found).
  • Introduce GetSessionMetadataResponse DTO for session.getMetadata RPC responses.
  • Update SessionMetadata Javadoc and add a disabled E2E test for the new behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/main/java/com/github/copilot/sdk/CopilotClient.java Adds the new getSessionMetadata JSON-RPC wrapper method.
src/main/java/com/github/copilot/sdk/json/GetSessionMetadataResponse.java Adds the RPC response record used to deserialize session.getMetadata results.
src/main/java/com/github/copilot/sdk/json/SessionMetadata.java Updates Javadoc to reference the new lookup API.
src/test/java/com/github/copilot/sdk/CopilotSessionTest.java Adds an (currently disabled) E2E test for session metadata lookup by ID.

*
* @see com.github.copilot.sdk.CopilotClient#getSessionMetadata(String)
* @see SessionMetadata
* @since 1.0.0
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The @since tag is set to 1.0.0, but this response type (and CopilotClient#getSessionMetadata(String)) is being introduced in this PR. Please update @since to the version where this API is actually added (consistent with other newer additions that use @since 1.2.0, etc.).

Suggested change
* @since 1.0.0
* @since 1.2.0

Copilot uses AI. Check for mistakes.
@edburns edburns marked this pull request as draft March 25, 2026 22:08
@edburns
Copy link
Copy Markdown
Collaborator

edburns commented Mar 25, 2026

Converting this to draft until the reference implementation PR github/copilot-sdk#899 is merged. @MackinnonBuck is still actively working on this.

@edburns
Copy link
Copy Markdown
Collaborator

edburns commented Mar 27, 2026

@copilot In the time between when I most recently marked this as draft and now, the reference implementation did have github/copilot-sdk#899 merged. I believe there have been additional commits to that PR that need to be considered when making a complete implementation of that PR in this codebase.

Please analyze the PR and make sure you have picked up all the changes, making changes to your implementation as necessary.

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 27, 2026

@copilot In the time between when I most recently marked this as draft and now, the reference implementation did have github/copilot-sdk#899 merged. I believe t...

Analyzed the final merged state of upstream PR #899 (10 commits, all 4 SDK languages). The Java implementation already matches the upstream API correctly — getSessionMetadata(sessionId) calls session.getMetadata and returns SessionMetadata or null.

Changes in 648e3f1:

  • Fixed @since 1.0.0@since 1.2.0 on GetSessionMetadataResponse (per reviewer feedback)
  • Updated @Disabled reason: the test is disabled because the should_get_session_metadata snapshot was added by upstream PR #899 and won't be available until .lastmerge is advanced past that PR
  • Added @see for getSessionMetadata(String) in SessionMetadata Javadoc

Build passes: 463 tests, 0 failures, 1 skipped (the disabled snapshot test).

Copilot AI requested a review from edburns March 27, 2026 16:27
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