microsoft/autogen · error · Error
Invalid session configuration
Error message
Invalid session configuration
What it means
Error thrown by setupWebSocket in autogen-studio's playground chat when the component tries to open the run WebSocket but the current session object is null or has no id. The WebSocket URL is built from /api/ws/runs/{runId} plus session-derived state, so without a session id the run cannot be tied to a conversation.
Source
Thrown at python/packages/autogen-studio/frontend/src/components/views/playground/chat/chat.tsx:467
// Setup WebSocket with files
const socket = setupWebSocket(runId, query, processedFiles);
setActiveSocket(socket);
activeSocketRef.current = socket;
} catch (error) {
handleError(error);
} finally {
setLoading(false);
}
};
const setupWebSocket = (
runId: number,
query: string,
files: { name: string; type: string; content: string }[]
): WebSocket => {
if (!session || !session.id) {
throw new Error("Invalid session configuration");
}
// Close existing socket if any
if (activeSocket?.readyState === WebSocket.OPEN) {
activeSocket.close();
}
const baseUrl = getBaseUrl(serverUrl);
const wsProtocol = window.location.protocol === "https:" ? "wss:" : "ws:";
const auth_token = localStorage.getItem("auth_token");
const wsUrl = `${wsProtocol}//${baseUrl}/api/ws/runs/${runId}?token=${auth_token}`;
const socket = new WebSocket(wsUrl);
// Initialize current run
setCurrentRun({
id: runId,
created_at: new Date().toISOString(),
status: "active",View on GitHub (pinned to 027ecf0a37)
Solutions
- Disable the send button / run action until session && session.id is truthy (e.g. conditionally render or early-return in the send handler).
- Ensure a default session is created and awaited before the chat view becomes interactive.
- If the session may have been deleted, re-fetch or re-create it before starting a run.
Example fix
// before
const socket = setupWebSocket(runId, query, files); // session may be null
// after
if (!session?.id) {
messageApi.error("Please select or create a session first.");
return;
}
const socket = setupWebSocket(runId, query, files); Defensive patterns
Strategy: validation
Validate before calling
const canSend = Boolean(session?.id);
if (!canSend) {
messageApi.warning("Create or select a session before sending.");
return;
}
const socket = setupWebSocket(runId, query, files); Type guard
const hasSession = (s: Session | null | undefined): s is Session => Boolean(s && typeof s.id === "number" && s.id > 0);
Try / catch
try { const socket = setupWebSocket(runId, query, files); }
catch (e) {
if (e instanceof Error && e.message === "Invalid session configuration") {
handleError(new Error("Session not ready; please select a session."));
return;
}
throw e;
} Prevention
- Disable the send button until session.id is set.
- Create/default-select a session before rendering the interactive chat.
- Re-validate the session exists (fetch) when deep-linking with a session id.
When it happens
Trigger: Calling sendMessage/run before a session was created or selected (session is null on first mount); session.id is undefined because the session came from a draft/unsaved builder entity; the session was deleted while the view was open.
Common situations: Users typing a message before the session has been persisted; deep-linking into the playground with an invalid session id so the fetch returned no session; race between session creation and the user hitting send; compare-mode with one panel lacking a session.
Related errors
- Unable to generate valid configuration
- Failed to validate component
- Invalid server URL configuration
- HTTP ${response.status}: ${errorText || "Failed to create We
- useAuth must be used within an AuthProvider
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/19d64997be2cc39d.
Report an issue: GitHub.