MCPcopy Index your code
hub / github.com/github/copilot-sdk / DeleteSession

Method DeleteSession

go/client.go:1310–1339  ·  view source on GitHub ↗

DeleteSession permanently deletes a session and all its data from disk, including conversation history, planning state, and artifacts. Unlike [Session.Disconnect], which only releases in-memory resources and preserves session data for later resumption, DeleteSession is irreversible. The session can

(ctx context.Context, sessionID string)

Source from the content-addressed store, hash-verified

1308// log.Fatal(err)
1309// }
1310func (c *Client) DeleteSession(ctx context.Context, sessionID string) error {
1311 if err := c.ensureConnected(ctx); err != nil {
1312 return err
1313 }
1314
1315 result, err := c.client.Request(ctx, "session.delete", deleteSessionRequest{SessionID: sessionID})
1316 if err != nil {
1317 return err
1318 }
1319
1320 var response deleteSessionResponse
1321 if err := json.Unmarshal(result, &response); err != nil {
1322 return fmt.Errorf("failed to unmarshal delete response: %w", err)
1323 }
1324
1325 if !response.Success {
1326 errorMsg := "unknown error"
1327 if response.Error != nil {
1328 errorMsg = *response.Error
1329 }
1330 return fmt.Errorf("failed to delete session %s: %s", sessionID, errorMsg)
1331 }
1332
1333 // Remove from local sessions map if present
1334 c.sessionsMux.Lock()
1335 delete(c.sessions, sessionID)
1336 c.sessionsMux.Unlock()
1337
1338 return nil
1339}
1340
1341// GetLastSessionID returns the ID of the most recently updated session.
1342//

Callers 2

TestClientAPIE2EFunction · 0.95
TestSessionE2EFunction · 0.95

Calls 2

ensureConnectedMethod · 0.95
RequestMethod · 0.45

Tested by 2

TestClientAPIE2EFunction · 0.76
TestSessionE2EFunction · 0.76