{"record":{"id":"7e8cd934214ccc30","repo":"xtekky/gpt4free","slug":"lmarena-json-loads-line-3","errorCode":null,"errorMessage":"LMArena: {json.loads(line[3:])}","messagePattern":"LMArena: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"g4f/Provider/needs_auth/LMArena.py","lineNumber":709,"sourceCode":"                                ]\n                                if __images:\n                                    yield ImageResponse(\n                                        __images, prompt, {\"model\": modelB}\n                                    )\n\n                            elif line.startswith(\"ad:\"):\n                                yield JsonConversation(\n                                    evaluationSessionId=evaluationSessionId\n                                )\n                                finish = json.loads(line[3:])\n                                if \"finishReason\" in finish:\n                                    yield FinishReason(finish[\"finishReason\"])\n                                if \"usage\" in finish:\n                                    yield Usage(**finish[\"usage\"])\n                            elif line.startswith(\"bd:\"):\n                                ...\n                            elif line.startswith(\"a3:\"):\n                                raise RuntimeError(f\"LMArena: {json.loads(line[3:])}\")\n                            elif line.startswith(\"b3:\"):\n                                ...\n                            else:\n                                debug.log(f\"LMArena: Unknown line prefix: {line[:2]}\")\n                break\n            except (CloudflareError, MissingAuthError) as error:\n                args = None\n                debug.error(error)\n                debug.log(f\"{cls.__name__}: Cloudflare error\")\n                continue\n            except RateLimitError as error:\n                if \"prompt failed\" in str(error):\n                    raise\n                args = None\n                _need_clear_cookies = True\n                debug.error(error)\n                continue\n            except:","sourceCodeStart":691,"sourceCodeEnd":727,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/Provider/needs_auth/LMArena.py#L691-L727","documentation":"In LMArena's streaming loop, a line prefixed 'a3:' carries a JSON error payload for the model-A side of the battle; g4f raises it verbatim as RuntimeError. Unlike hasArenaError, this includes structured error details from the arena backend (a3: is the counterpart of the 'ad:' finish-reason line).","triggerScenarios":"During response.iter_lines() of the chat POST, a line starting with 'a3:' arrives whose JSON body describes the failure — for example token/context limits exceeded, malformed conversation state, or backend exceptions surfaced mid-stream.","commonSituations":"Very long conversations that exceed the arena model's context; a stale/invalid evaluationSessionId reused from an old conversation object; upstream backend errors during heavy load.","solutions":["Read the JSON payload inside the message — it names the actual backend cause; act on that (shorten context, change model, etc.)","Start a fresh conversation (drop the saved JsonConversation/evaluationSessionId) and retry","Reduce message history or media size if the payload mentions limits","Update g4f and retry later if the payload indicates a platform-side error"],"exampleFix":"// before\n# opaque failure\nawait client.chat.completions.create(model=..., messages=long_history)\n\n// after\n# surface and log the a3 payload, then trim history\nexcept RuntimeError as e:\n    logging.error('LMArena a3 error detail: %s', str(e))\nresp = await client.chat.completions.create(model=..., messages=messages[-6:])","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    async for chunk in stream:\n        handle(chunk)\nexcept RuntimeError as e:\n    # str(e) contains the a3 JSON payload with the backend reason\n    logging.error('LMArena a3 error: %s', e)\n    if 'context' in str(e).lower():\n        messages = messages[-6:]  # trim and retry\n        raise Retryable(messages)","preventionTips":["Log the a3 payload verbatim — it names the real cause","Do not reuse old JsonConversation objects across sessions","Cap conversation length sent to the arena"],"tags":["lmarena","streaming","backend-error","runtime"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}