OpenAI Responses API: publish the output message phase at response.output_item.added

オープン 初心者向け
#8,427 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python

調査の方向性

livekit/agents/llm/_responses_engine.pyから始め、イベントの解析とフェーズの出力を行う箇所として issue が示している _parse_ws_event と _handle_output_items_done を読みます。フェーズが null でないメッセージ項目について response.output_item.added を処理し、両方の Responses LLM 統合が共有エンジンを使用しているか確認します。フェーズチャンクがテキストデルタより前に利用可能になれば完了です。イベントの順序とフェーズ処理に焦点を当てたテストを追加または更新します。

索引モデルが issue の本文から書いたものです。

説明

enhancement
Feature Type

Would make my life easier

Feature Description
Problem

The OpenAI Responses API marks each output message with a phase (commentary or final_answer), and the phase is already set when the item starts (response.output_item.added). ResponsesLLMStream ignores that event. It sends the phase only from response.output_item.done, after all of that item's text deltas:

So an agent that wants to speak only the final_answer (for example, by filtering in llm_node) can't tell an item's phase while its text streams. It has to buffer each item until the item ends before sending the text to TTS. In our traffic this adds about 0.3 s on average to each response of two or more sentences.

Proposal

Handle response.output_item.added. When the item is a ResponseOutputMessage with a non-null phase, send the existing phase chunk (ChoiceDelta(extra={"openai": {"phase": ...}})) right away. Optionally keep sending it at done as well, for backward compatibility.

The stream is ordered (added, then deltas, then done), so each text delta belongs to the most recent phase. The filter then becomes simple:

async def llm_node(self, chat_ctx, tools, model_settings):
    phase = None
    async for chunk in Agent.default.llm_node(self, chat_ctx, tools, model_settings):
        if isinstance(chunk, llm.ChatChunk) and chunk.delta:
            phase = (chunk.delta.extra or {}).get("openai", {}).get("phase") or phase
            if chunk.delta.content and phase == "commentary":
                continue
        yield chunk

The change affects both openai.responses.LLM and inference.responses.LLM, since they share _responses_engine.py.

Workarounds / Alternatives

No response

Additional Context

No response

主要言語
Python
スター
14.6k
フォーク
3.9k
平均マージ
3日
マージ済み PR(30日)
262

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

livekit/agents のほかの issue

livekit/agents の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。