{"record":{"id":"ea92000579031a52","repo":"microsoft/autogen","slug":"failed-to-create-run","errorCode":null,"errorMessage":"Failed to create run","messagePattern":"Failed to create run","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-studio/frontend/src/components/views/playground/api.ts","lineNumber":131,"sourceCode":"      }\n    );\n    const data = await response.json();\n    if (!data.status)\n      throw new Error(data.message || \"Failed to fetch messages\");\n    return data.data;\n  }\n\n  // New method to create a run\n  async createRun(sessionId: number, userId: string): Promise<number> {\n    const payload = { session_id: sessionId, user_id: userId };\n    const response = await fetch(`${this.getBaseUrl()}/runs/`, {\n      method: \"POST\",\n      headers: this.getHeaders(),\n      body: JSON.stringify(payload),\n    });\n\n    const data = await response.json();\n    if (!data.status) throw new Error(data.message || \"Failed to create run\");\n    return data.data.run_id;\n  }\n}\n\nexport const sessionAPI = new SessionAPI();\n","sourceCodeStart":113,"sourceCodeEnd":137,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-studio/frontend/src/components/views/playground/api.ts#L113-L137","documentation":"Thrown by SessionAPI.createRun when POST /runs/ returns falsy status. The payload is {session_id, user_id}; on success it reads data.data.run_id. Failure means the backend refused to start a run — invalid session reference, missing team, or agent-run initialization error surfaced through the envelope.","triggerScenarios":"POST /runs/ with a session_id that doesn't exist or lacks a valid team, user_id not matching the session owner, or backend error while constructing the agent runtime for the session's team.","commonSituations":"Run started before the session's team finished saving, team component references broken (deleted from gallery), backend agent-building error (bad model config keys, missing API keys) wrapped as status:false. Fix order matters: verify the session and its team first, then the backend logs for the agent construction trace.","solutions":["Check data.message and backend logs together — run creation failures are almost always logged with the agent build error","Verify sessionAPI.getSession(sessionId, userId) succeeds and references a valid team","Ensure the team's components (model keys, agent configs) are complete before starting a run","Validate required API keys (e.g. model provider keys) exist in backend settings"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const session = await sessionAPI.getSession(sessionId, userId);\nif (!session?.team) throw new Error(\"Session has no team — cannot start a run\");","typeGuard":"function isRunCreatedEnvelope(x: unknown): x is { status: true; data: { run_id: number } } {\n  return !!x && (x as any).status === true && typeof (x as any).data?.run_id === \"number\";\n}","tryCatchPattern":"try {\n  return await sessionAPI.createRun(sessionId, userId);\n} catch (e) {\n  notify(`Run not started: ${e instanceof Error ? e.message : e}`);\n  throw e;\n}","preventionTips":["Verify session and team integrity before exposing the Run button","Ensure model API keys are present in settings — agent build fails without them","Check backend logs whenever data.message is vague here; the real error is server-side"],"tags":["runs","sessions","http","error-envelope"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}