github/copilot-sdk · error · RuntimeException
session.create response did not include a sessionId
Error message
session.create response did not include a sessionId
What it means
CopilotClient.createSession sends a session.create RPC and requires the server response to carry a sessionId. If the response's sessionId field is null or empty, the client cannot register or look up the session, so it throws immediately rather than returning a broken CopilotSession.
Solutions
- Upgrade the Copilot agent/server to a version matching the SDK's expected session.create response schema
- Verify no proxy or interceptor is stripping the sessionId field from RPC responses
- Log the raw session.create response (enable FINE logging via LoggingHelpers) to confirm what the server returned
- If using a stub server, make it return a non-empty sessionId
Example fix
// before (stub server)
server.on("session.create", (req, resp) -> resp.send(Map.of()));
// after
server.on("session.create", (req, resp) -> resp.send(Map.of("sessionId", UUID.randomUUID().toString()))); Defensive patterns
Strategy: try-catch
Try / catch
try {
CopilotSession s = client.createSession(options);
} catch (RuntimeException e) {
if (e.getMessage().contains("did not include a sessionId")) {
// check server/agent version compatibility; retry with a fresh server
}
} Prevention
- Pin the Copilot agent/server version tested against this SDK version
- Enable FINE logging on session creation to capture raw responses
- Validate stub/mock servers return complete session.create payloads
When it happens
Trigger: The session.create RPC completes but response.sessionId() returns null or "" — e.g. a misbehaving or incompatible Copilot server/extension version that omits the sessionId field, or a proxy mangling the response payload.
Common situations: Running against an outdated or third-party Copilot agent binary whose session.create response schema differs; network middleware stripping fields; testing against a mock/stub RPC server that returns an incomplete response.
Understand the failure class
Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.
Related errors
- session.create returned sessionId
- No session found for sessionId
- session.create returned sessionId
- Failed to delete session
- Failed to set foreground session
AI-assisted analysis of github/copilot-sdk@cd8cf15dc3 (2026-09-09).
Data as JSON: /api/errors/425803ed537eb7f0.
Report an issue: GitHub.
Appendix: source
Thrown at java/sdk/src/main/java/com/github/copilot/CopilotClient.java:1015
? null
: gitHubTokenProviders.register(config.getGitHubTokenProvider());
if (tokenRegistration != null) {
request.setGitHubTokenProviderRegistrationId(tokenRegistration.id());
if (preRegisteredSessionHolder[0] != null) {
preRegisteredSessionHolder[0].setGitHubTokenProviderRegistration(tokenRegistration);
}
}
long rpcNanos = System.nanoTime();
return connection.rpc.invoke("session.create", request, CreateSessionResponse.class)
.thenCompose(response -> {
String returnedId = response.sessionId();
LoggingHelpers.logTiming(LOG, Level.FINE,
"CopilotClient.createSession session creation request completed. Elapsed={Elapsed}, SessionId="
+ (returnedId != null ? returnedId : localSessionId),
rpcNanos);
if (returnedId == null || returnedId.isEmpty()) {
throw new RuntimeException("session.create response did not include a sessionId");
}
if (localSessionId != null && !localSessionId.equals(returnedId)) {
throw new RuntimeException("session.create returned sessionId " + returnedId
+ " but the caller requested " + localSessionId);
}
CopilotSession session = preRegisteredSessionHolder[0] != null
? preRegisteredSessionHolder[0]
: initializeSession.apply(returnedId);
preRegisteredSessionHolder[0] = session;
if (tokenRegistration != null) {
session.setGitHubTokenProviderRegistration(tokenRegistration);
}
registeredIdHolder[0] = returnedId;
CompletableFuture<?> interest = config.getOnMcpAuthRequest() != null
? session.getRpc().eventLog.registerInterest(
new SessionEventLogRegisterInterestParams(returnedId, "mcp.oauth_required"))
: CompletableFuture.completedFuture(null);
session.setWorkspacePath(response.workspacePath());View on GitHub (pinned to cd8cf15dc3)