xtekky/gpt4free · error · RuntimeError
LMArena: {json.loads(line[3:])}
Error message
LMArena: {json.loads(line[3:])} What it means
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).
Source
Thrown at g4f/Provider/needs_auth/LMArena.py:709
]
if __images:
yield ImageResponse(
__images, prompt, {"model": modelB}
)
elif line.startswith("ad:"):
yield JsonConversation(
evaluationSessionId=evaluationSessionId
)
finish = json.loads(line[3:])
if "finishReason" in finish:
yield FinishReason(finish["finishReason"])
if "usage" in finish:
yield Usage(**finish["usage"])
elif line.startswith("bd:"):
...
elif line.startswith("a3:"):
raise RuntimeError(f"LMArena: {json.loads(line[3:])}")
elif line.startswith("b3:"):
...
else:
debug.log(f"LMArena: Unknown line prefix: {line[:2]}")
break
except (CloudflareError, MissingAuthError) as error:
args = None
debug.error(error)
debug.log(f"{cls.__name__}: Cloudflare error")
continue
except RateLimitError as error:
if "prompt failed" in str(error):
raise
args = None
_need_clear_cookies = True
debug.error(error)
continue
except:View on GitHub (pinned to 973504e177)
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
Example fix
// before
# opaque failure
await client.chat.completions.create(model=..., messages=long_history)
// after
# surface and log the a3 payload, then trim history
except RuntimeError as e:
logging.error('LMArena a3 error detail: %s', str(e))
resp = await client.chat.completions.create(model=..., messages=messages[-6:]) Defensive patterns
Strategy: try-catch
Try / catch
try:
async for chunk in stream:
handle(chunk)
except RuntimeError as e:
# str(e) contains the a3 JSON payload with the backend reason
logging.error('LMArena a3 error: %s', e)
if 'context' in str(e).lower():
messages = messages[-6:] # trim and retry
raise Retryable(messages) Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- LMArena Beta encountered an error: hasArenaError
- line.get("error")
- {r.status} {response body text}
- No audio chunks
- Install or update "curl_cffi" package | pip install -U curl_
AI-assisted analysis of xtekky/gpt4free@973504e177 (2026-08-14).
Data as JSON: /api/errors/7e8cd934214ccc30.
Report an issue: GitHub.