xtekky/gpt4free · error · RuntimeError

Error during CopilotApp interaction: {e}

Error message

Error during CopilotApp interaction: {e}

What it means

This is the outer catch-all of CopilotApp's generator: any exception raised inside the start/WebSocket flow (including errors 14 and 15 above) is re-raised as RuntimeError with the original exception chained via `from e`. It also decrements cls.live, the concurrency counter. The real cause is always in the chained exception `e`.

Source

Thrown at g4f/Provider/CopilotApp.py:131

                            event = data.get("event")
                            if event == "appendText":
                                yield data.get("text", "")
                            elif event == "citation":
                                sources[data.get("url")] = data
                                yield SourceLink(
                                    list(sources.keys()).index(data.get("url")),
                                    data.get("url"),
                                )
                            elif event == "done":
                                if sources:
                                    yield Sources(sources.values())
                                cls.live += 1
                                break
                        elif msg.type == aiohttp.WSMsgType.ERROR:
                            raise RuntimeError(f"WebSocket Error: {ws.exception()}")
        except Exception as e:
            cls.live -= 1
            raise RuntimeError(f"Error during CopilotApp interaction: {e}") from e

View on GitHub (pinned to 973504e177)

Solutions

  1. Inspect the chained exception (__cause__) rather than just the wrapper message to find the root cause
  2. Fix the underlying error per its own diagnosis (auth, transport, or parsing)
  3. Enable debug logging to capture the event stream leading up to the failure

Example fix

# before
try:
    async for chunk in CopilotApp.create_async_generator(...):
        ...
except RuntimeError as e:
    print(e)

# after
except RuntimeError as e:
    print('root cause:', e.__cause__ or e)
Defensive patterns

Strategy: try-catch

Try / catch

try:
    async for chunk in CopilotApp.create_async_generator(model, messages):
        yield chunk
except RuntimeError as e:
    root = e.__cause__ or e
    log.error('CopilotApp failed: %s', root)
    raise

Prevention

When it happens

Trigger: Any failure inside the try block: failed /c/api/start, websocket transport error, JSON decode errors on malformed events, unexpected None fields in event data.

Common situations: Wrapper obscures the root cause in logs if callers only print str(exc); concurrent session counter drifting after repeated failures; upstream schema changes causing KeyError/TypeError deep in the handler.

Related errors


AI-assisted analysis of xtekky/gpt4free@973504e177 (2026-08-14). Data as JSON: /api/errors/f08395b223c22dc9. Report an issue: GitHub.