xtekky/gpt4free · error · RuntimeError
Error: {msg}
Error message
Error: {msg} What it means
CopilotSession's WebSocket event loop received an event with type 'error' from Microsoft's Copilot backend. Identical semantics to Copilot.py error 11: an upstream rejection of the turn (moderation, invalid model, server error) with the full event dict embedded in the message.
Source
Thrown at g4f/Provider/CopilotSession.py:222
yield msg.get("text")
elif msg.get("event") == "titleUpdate":
yield TitleGeneration(msg.get("title"))
elif msg.get("event") == "citation":
sources[msg.get("url")] = msg
yield SourceLink(
list(sources.keys()).index(msg.get("url")), msg.get("url")
)
elif msg.get("event") == "partialImageGenerated":
mime_type = is_accepted_format(
base64.b64decode(msg.get("content")[:12])
)
yield ImagePreview(
f"data:{mime_type};base64,{msg.get('content')}", image_prompt
)
elif msg.get("event") == "chainOfThought":
yield Reasoning(msg.get("text"))
elif msg.get("event") == "error":
raise RuntimeError(f"Error: {msg}")
elif msg.get("event") not in [
"received",
"startMessage",
"partCompleted",
"connected",
]:
debug.log(f"Copilot Message: {msg_txt[:100]}...")
if not done:
raise MissingAuthError(f"Invalid response: {last_msg}")
if sources:
yield Sources(sources.values())
if has_nodriver:
async def click_trunstile(
page: nodriver.Tab, element='document.getElementById("cf-turnstile")'
):View on GitHub (pinned to 973504e177)
Solutions
- Parse the embedded msg dict for the error code/subcode to identify moderation vs server failure
- Retry in a fresh conversation; rephrase if moderation-related
- Verify the model string against the provider's supported models
Defensive patterns
Strategy: try-catch
Try / catch
try:
async for chunk in CopilotSession.create_async_generator(model, messages):
yield chunk
except RuntimeError as e:
if 'Error:' in str(e):
# parse embedded event for code; abort on policy, retry once on server errors
raise
except Exception:
raise Prevention
- Read the embedded event dict to classify moderation vs server errors before retrying
- Never retry content-policy failures
- Use a new conversation for each retry
When it happens
Trigger: Content-policy rejection of the prompt; model unavailable for the session; server-side error mid-conversation; malformed request parameters for image or tool requests.
Common situations: Sensitive prompts; model name mismatch across Copilot surfaces; stale conversation reused; upstream incident.
Related errors
- Failed to start conversation: {await resp.text()}
- WebSocket Error: {ws.exception()}
- Invalid response: {last_msg}
- Error during CopilotApp interaction: {e}
- All Antigravity endpoints failed. Last error: {last_error}
AI-assisted analysis of xtekky/gpt4free@973504e177 (2026-08-14).
Data as JSON: /api/errors/c471bda4ddeece61.
Report an issue: GitHub.