microsoft/autogen · error · Error

Failed to fetch session runs

Error message

Failed to fetch session runs

What it means

Thrown by SessionAPI.getSessionRuns when GET /sessions/{id}/runs?user_id=... returns falsy status. This endpoint returns run transcripts; failure means the session id/user pair is invalid or the backend failed loading runs. The comment notes the success shape is {runs: RunMessage[]}.

Source

Thrown at python/packages/autogen-studio/frontend/src/components/views/playground/api.ts:89

    if (!data.status)
      throw new Error(data.message || "Failed to update session");
    return data.data;
  }

  // session runs with messages
  async getSessionRuns(
    sessionId: number,
    userId: string
  ): Promise<SessionRuns> {
    const response = await fetch(
      `${this.getBaseUrl()}/sessions/${sessionId}/runs?user_id=${userId}`,
      {
        headers: this.getHeaders(),
      }
    );
    const data = await response.json();
    if (!data.status)
      throw new Error(data.message || "Failed to fetch session runs");
    return data.data; // Returns { runs: RunMessage[] }
  }

  async deleteSession(sessionId: number, userId: string): Promise<void> {
    const response = await fetch(
      `${this.getBaseUrl()}/sessions/${sessionId}?user_id=${userId}`,
      {
        method: "DELETE",
        headers: this.getHeaders(),
      }
    );
    const data = await response.json();
    if (!data.status)
      throw new Error(data.message || "Failed to delete session");
  }

  // Adding messages endpoint
  async listSessionMessages(sessionId: number, userId: string): Promise<any[]> {

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. Verify the session exists first via getSession(sessionId, userId)
  2. Inspect data.message for the backend's stated reason
  3. If session validity is confirmed and it still fails, check backend logs for the runs query error
  4. Guard the UI so a runs-load failure doesn't blank the whole session view
Defensive patterns

Strategy: try-catch

Validate before calling

await sessionAPI.getSession(sessionId, userId); // throws a clearer error if session invalid

Type guard

function isSessionRunsEnvelope(x: unknown): x is { status: true; data: { runs: unknown[] } } {
  return !!x && (x as any).status === true && Array.isArray((x as any).data?.runs);
}

Try / catch

try {
  const { runs } = (await sessionAPI.getSessionRuns(sessionId, userId)).data as any;
  return runs ?? [];
} catch {
  return []; // runs history is non-critical — degrade gracefully
}

Prevention

When it happens

Trigger: GET /sessions/{sessionId}/runs?user_id=X for a nonexistent/deleted session, ownership mismatch, or a backend error while querying run/message tables.

Common situations: Opening run history for a session whose rows were purged, backend DB migration leaving run tables inconsistent, stale sessionId in a long-lived playground tab.

Related errors


AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15). Data as JSON: /api/errors/6a1c131fd2632d6f. Report an issue: GitHub.