diff --git a/.lastmerge b/.lastmerge index 92e0dd366..df5b85477 100644 --- a/.lastmerge +++ b/.lastmerge @@ -1 +1 @@ -4246289e484d42155c75267660d448d9ac4f9158 +4e1499dd23709022c720eaaa5457d00bf0cb3977 diff --git a/src/main/java/com/github/copilot/sdk/CopilotClient.java b/src/main/java/com/github/copilot/sdk/CopilotClient.java index 5c4fcfe21..023051edd 100644 --- a/src/main/java/com/github/copilot/sdk/CopilotClient.java +++ b/src/main/java/com/github/copilot/sdk/CopilotClient.java @@ -208,7 +208,18 @@ private void verifyProtocolVersion(Connection connection) throws Exception { } /** - * Stops the client and closes all sessions. + * Disconnects from the Copilot server and closes all active sessions. + *
+ * This method performs graceful cleanup: + *
+ * Note: session data on disk is preserved, so sessions can be resumed later. To
+ * permanently remove session data before stopping, call
+ * {@link #deleteSession(String)} for each session first.
*
* @return A future that completes when the client is stopped
*/
@@ -469,9 +480,12 @@ public CompletableFuture
- * This permanently removes the session and its conversation history.
+ * Unlike {@link CopilotSession#close()}, which only releases in-memory
+ * resources and preserves session data for later resumption, this method is
+ * irreversible. The session cannot be resumed after deletion.
*
* @param sessionId
* the ID of the session to delete
diff --git a/src/main/java/com/github/copilot/sdk/CopilotSession.java b/src/main/java/com/github/copilot/sdk/CopilotSession.java
index 1af22d803..80b2e85ea 100644
--- a/src/main/java/com/github/copilot/sdk/CopilotSession.java
+++ b/src/main/java/com/github/copilot/sdk/CopilotSession.java
@@ -58,6 +58,13 @@
* A session maintains conversation state, handles events, and manages tool
* execution. Sessions are created via {@link CopilotClient#createSession} or
* resumed via {@link CopilotClient#resumeSession}.
+ *
+ * {@code CopilotSession} implements {@link AutoCloseable}. Use the
+ * try-with-resources pattern for automatic cleanup, or call {@link #close()}
+ * explicitly. Closing a session releases in-memory resources but preserves
+ * session data on disk — the conversation can be resumed later via
+ * {@link CopilotClient#resumeSession}. To permanently delete session data, use
+ * {@link CopilotClient#deleteSession}.
*
* Example Usage
*
diff --git a/src/site/markdown/documentation.md b/src/site/markdown/documentation.md
index 01aba950f..26f17ce0f 100644
--- a/src/site/markdown/documentation.md
+++ b/src/site/markdown/documentation.md
@@ -617,8 +617,14 @@ See [ResumeSessionConfig](apidocs/com/github/copilot/sdk/json/ResumeSessionConfi
### Clean Up Sessions
+Closing a session releases its in-memory resources but **preserves session data on disk**, so
+it can be resumed later. Use `deleteSession()` to permanently remove session data from disk:
+
```java
-// Delete a specific session
+// Close a session (releases in-memory resources; session can be resumed later)
+session.close();
+
+// Permanently delete a session and all its data from disk (cannot be resumed)
client.deleteSession(sessionId).get();
```
diff --git a/src/test/java/com/github/copilot/sdk/CopilotSessionTest.java b/src/test/java/com/github/copilot/sdk/CopilotSessionTest.java
index 1dec8c881..787312cef 100644
--- a/src/test/java/com/github/copilot/sdk/CopilotSessionTest.java
+++ b/src/test/java/com/github/copilot/sdk/CopilotSessionTest.java
@@ -60,7 +60,7 @@ static void teardown() throws Exception {
}
/**
- * Verifies that a session can be created and destroyed properly.
+ * Verifies that a session can be created and closed properly.
*
* @see Snapshot: session/should_receive_session_events
*/