{"record":{"id":"7b801352cbf40bf6","repo":"binary-husky/gpt_academic","slug":"update-web-page-context-failed","errorCode":null,"errorMessage":"Update web page context failed","messagePattern":"Update web page context failed","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"request_llms/edge_gpt_free.py","lineNumber":508,"sourceCode":"                            {\n                                \"author\": \"user\",\n                                \"description\": webpage_context,\n                                \"contextType\": \"WebPage\",\n                                \"messageType\": \"Context\",\n                            },\n                        ],\n                        \"conversationId\": self.request.conversation_id,\n                        \"source\": \"cib\",\n                        \"traceId\": _get_ran_hex(32),\n                        \"participant\": {\"id\": self.request.client_id},\n                        \"conversationSignature\": self.request.conversation_signature,\n                    },\n                )\n            if response.status_code != 200:\n                print(f\"Status code: {response.status_code}\")\n                print(response.text)\n                print(response.url)\n                raise Exception(\"Update web page context failed\")\n            # Construct a ChatHub request\n            self.request.update(\n                prompt=prompt,\n                conversation_style=conversation_style,\n                options=options,\n            )\n        # Send request\n        await self.wss.send_str(_append_identifier(self.request.struct))\n        final = False\n        draw = False\n        resp_txt = \"\"\n        result_text = \"\"\n        resp_txt_no_link = \"\"\n        while not final:\n            msg = await self.wss.receive()\n            try:\n                objects = msg.data.split(DELIMITER)\n            except:","sourceCodeStart":490,"sourceCodeEnd":526,"githubUrl":"https://github.com/binary-husky/gpt_academic/blob/d6bde0fa54373309bd05823a49bda8da019d2c77/request_llms/edge_gpt_free.py#L490-L526","documentation":"ChatHub handshake failure: before streaming a prompt, _ChatHub.ask sends a web-context update POST to conversation/create-style endpoint carrying the page context/conversation signature; a non-200 response triggers Exception('Update web page context failed'). Printed status/body/url identify the rejection.","triggerScenarios":"request_llms/edge_gpt_free.py:508: the initial context-update request in ask() returns non-200 — expired or invalid conversationSignature/conversationId, rate-limited IP, or the (proxy) endpoint rejecting the payload shape. It fires per-message, so a session can work once then fail after signature expiry.","commonSituations":"Reusing a conversation object after its signature expired (~minutes); heavy usage triggering 429; cookies partially valid (create succeeded, chat rejected); churchless fallback proxy restrictive on the context update call.","solutions":["Create a fresh conversation (new cookies/signature) instead of reusing a long-lived one","Check printed status: 401/403 → refresh cookies; 429 → back off and retry later","Verify BING_PROXY_URL forwards the context-update endpoint, not just conversation/create","Catch this exception and auto-recreate the conversation once before giving up"],"exampleFix":"# before\ntry:\n    async for resp in chathub.ask(prompt):\n        ...\nexcept Exception:\n    raise\n\n# after: recreate conversation once on handshake failure\ntry:\n    async for resp in chathub.ask(prompt):\n        ...\nexcept Exception as e:\n    if 'Update web page context failed' in str(e):\n        chatbot = await Chatbot.create(cookies=COOKIES, proxy=PROXY)  # fresh signature\n        async for resp in chatbot.ask(prompt):\n            ...","handlingStrategy":"fallback","validationCode":"import time\nif conversation.created_at and time.time() - conversation.created_at > 15*60:\n    conversation = await Chatbot.create(cookies=COOKIES, proxy=PROXY)  # refresh before signature expires","typeGuard":null,"tryCatchPattern":"try:\n    async for resp in chathub.ask(prompt):\n        ...\nexcept Exception as e:\n    if 'Update web page context failed' in str(e):\n        chatbot = await Chatbot.create(cookies=COOKIES, proxy=PROXY)  # fresh conversation, one retry\n        async for resp in chatbot.ask(prompt):\n            ...\n    else:\n        raise","preventionTips":["Treat Bing conversation signatures as short-lived; recreate per task","Check the printed status code: 429 -> backoff, 401/403 -> refresh cookies","Wrap ask() with exactly one conversation-recreate retry, then surface the error"],"tags":["bing","network","session-expiry","third-party-api"],"backgroundTag":null,"analyzedSha":"d6bde0fa54373309bd05823a49bda8da019d2c77","analyzedAt":"2026-08-14T22:48:35.038Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}