{"record":{"id":"adec325b7643e16b","repo":"xtekky/gpt4free","slug":"failed-to-start-conversation-await-resp-text","errorCode":null,"errorMessage":"Failed to start conversation: {await resp.text()}","messagePattern":"Failed to start conversation: (.+?)","errorType":"http","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"g4f/Provider/CopilotApp.py","lineNumber":67,"sourceCode":"        }\n\n        start_payload = {\n            \"timeZone\": \"Europe/Kiev\",\n            \"startNewConversation\": True,\n            \"teenSupportEnabled\": True,\n            \"correctPersonalizationSetting\": True,\n            \"deferredDataUseCapable\": True,\n        }\n        try:\n            async with aiohttp.ClientSession() as session:\n                async with session.post(\n                    \"https://copilot.microsoft.com/c/api/start\",\n                    headers=headers,\n                    json=start_payload,\n                    proxy=proxy,\n                ) as resp:\n                    if resp.status != 200:\n                        raise RuntimeError(\n                            f\"Failed to start conversation: {await resp.text()}\"\n                        )\n\n                    start_data = await resp.json()\n                    conversation_id = start_data.get(\"currentConversationId\")\n\n                client_session_id = str(uuid.uuid4())\n                ws_url = f\"wss://copilot.microsoft.com/c/api/chat?api-version=2&clientSessionId={client_session_id}\"\n\n                async with session.ws_connect(ws_url, headers=headers, proxy=proxy) as ws:\n                    async for msg in ws:\n                        if msg.type == aiohttp.WSMsgType.TEXT:\n                            data = json.loads(msg.data)\n                            if data.get(\"event\") == \"connected\":\n                                break\n\n                    model_lower = model.lower()\n                    if (","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/Provider/CopilotApp.py#L49-L85","documentation":"CopilotApp POSTs to https://copilot.microsoft.com/c/api/start to create a conversation; any non-200 status raises with the response body attached. Common statuses: 401/403 (session not established), 429 (too many live sessions — the class tracks a 'live' counter), or 4xx from missing/invalid headers.","triggerScenarios":"Calling /c/api/start without valid session cookies; exceeding the provider's concurrent-session expectations (cls.live); request blocked by bot detection; malformed start_payload after an upstream schema change.","commonSituations":"Auth cookie not passed in headers; running many parallel CopilotApp requests from one IP; Microsoft requiring additional headers/turnstile token; proxy stripping cookies.","solutions":["Read the status/body in the message: 401/403 → refresh auth cookies; 429 → back off and limit concurrency","Ensure session-establishing cookies are included in the headers passed to create_async_generator","Serialize or cap concurrent CopilotApp conversations to avoid session-limit rejections"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    async for chunk in CopilotApp.create_async_generator(model, messages):\n        yield chunk\nexcept RuntimeError as e:\n    text = str(e)\n    if '429' in text:\n        await asyncio.sleep(30)  # session limit: back off\n        async for chunk in CopilotApp.create_async_generator(model, messages):\n            yield chunk\n    elif '401' in text or '403' in text:\n        raise AuthNeeded('CopilotApp session rejected — refresh cookies')\n    else:\n        raise","preventionTips":["Cap concurrent CopilotApp conversations (the provider tracks a live counter)","Pass valid session cookies on every call; don't assume the provider establishes them","Back off on 429; refresh auth on 401/403"],"tags":["http","copilot","session","upstream"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}