OpenAI Realtime engine: expose the WebSocket close code and reason to subclasses
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 35/100
調査の方向性
Start with livekit/agents/llm/_realtime/openai.py, especially the receive loop at lines 1176–1190, and inspect how _is_fatal_error classifies error events. Trace how the WebSocket close code and reason are discarded and how errors are retried; done means subclasses can use close details to classify fatal versus retryable closures. An open linked pull request (#8078) is already addressing this issue.
索引モデルが issue の本文から書いたものです。
説明
Feature Type
Would make my life easier
Feature Description
The shared OpenAI Realtime engine (livekit.agents.llm._realtime.openai) discards the WebSocket close code and reason. When the server closes the socket, _recv_task raises a generic, retryable APIConnectionError("… connection closed unexpectedly"), whatever the close frame said (openai.py#L1176-L1190).
OpenAI-compatible providers built on this engine often use close codes to signal that the session is over for good. For example, a provider closes with 4001 for bad credentials or 1008 for a policy violation, where reconnecting can't help. Since the code and reason are lost, the engine retries these until max_retry is used up, and a plugin can't tell a fatal close from a transient one.
It would help if the close code and reason were available to subclasses, for example:
- carried on the raised error (e.g.
APIConnectionError.body = {"code": ..., "reason": ...}), or - passed to an overridable hook such as
_on_ws_closed(code, reason) -> APIError, which decides whether the error is retryable.
Workarounds / Alternatives
The ElevenLabs realtime plugin in #8075 wraps the aiohttp WebSocket returned by _create_ws_conn to record the close frame's code and reason. Its _run_ws override then catches the APIConnectionError and raises a mapped APIError with the right retryable flag. It works, but it depends on internals of the receive loop, and every OpenAI-compatible provider would need to repeat it.
Additional Context
The same engine already lets subclasses classify errors that arrive as error events (_is_fatal_error). This would give close frames the same treatment.
🤖 Generated with Claude Code
- 主要言語
- Python
- スター
- 14.6k
- フォーク
- 3.9k
- 平均マージ
- 3日 21時間
- マージ済み PR(30日)
- 197
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
livekit/agents のほかの issue
-
Assistant markup is stripped from chat history when expressive mode is off対応中かも @ShivamSharma43 が 15 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
docs: openai.LLM vs openai.responses.LLM for HTTP OpenAI-compat hosts再び着手できるかも @AbarnaaSree が 55 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
livekit/agents#7022 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Anthropic plugin ignores parallel_tool_calls=False unless tool_choice is also set対応中かも @sarankumar1325 が今日担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 30/100
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
sergey-miryanov/gcmon#230 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Azure-Samples/azure-search-openai-demo#3249 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] Failed archive extraction deletes the dataset cache対応中かも @dajiaohuang が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
alibaba/GraphScope#4674 ·