Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Python: foundry-hosting drops request `metadata` from the stored response — `_create_response_event_stream` never passes `request` to `ResponseEventStream`

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

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

@its-amann がすでに取り組んでいます。

2026年10月19日 から。

評価

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

調査の方向性

agent_framework_foundry_hosting/_responses.pyから始めて、_handle_responseから_create_response_event_streamまでを追います。issueでは、新しいレスポンスに必要なリクエスト引数が欠けていると指摘されています。ResponseEventStreamがリクエストからフィールドを設定する方法を確認し、作成されたレスポンスと保存されたレスポンスのメタデータに関する的を絞ったテストを追加または更新します。POST時のメタデータがレスポンスイベントとGET /responses/{id}で保持されれば完了です。

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

説明

python triage
Description

When a client calls POST /responses on a ResponsesHostServer with a metadata object, that metadata is not present on the response object that is emitted (response.created / terminal events) or persisted, so GET /responses/{id} returns metadata: null.

This breaks the standard OpenAI Responses contract, where request metadata is echoed onto the response, and prevents clients from using response metadata to label/correlate turns (for example, recording per-turn settings and reading them back when listing conversation history).

Client impact (.NET SDK)

Our client is a .NET service using Azure.AI.Projects / Azure.AI.Extensions.OpenAI (2.1.0-beta.4). It sends the metadata when creating the response (CreateResponseOptions.Metadata), and when listing conversation history it reads it back per turn:

  1. GetProjectConversationItemsAsync(conversationId) to enumerate message items (items carry no metadata, only ResponseId).
  2. GetResponseAsync(new GetResponseOptions(responseId)) and read result.Value.Metadata.

Because the hosted agent never seeds metadata onto the response, result.Value.Metadata is always empty for responses produced by a ResponsesHostServer-hosted agent, so the .NET client has no way to recover the per-turn values it sent.

Root cause

azure-ai-agentserver-responses already supports this: ResponseEventStream(request=...) seeds metadata, background, previous_response_id, conversation, model and agent_reference from the request.

However, in agent_framework_foundry_hosting/_responses.py the stream is created without the request:

def _create_response_event_stream(context: ResponseContext) -> ResponseEventStream:
    """Create a response stream seeded from recovery state when available."""
    if context.is_recovery:
        persisted_response = context.persisted_response
        if persisted_response is not None:
            return ResponseEventStream(response=persisted_response, response_id=context.response_id)
    return ResponseEventStream(response_id=context.response_id)

and ResponsesHostServer._handle_response(self, request, context, cancellation_signal) calls _create_response_event_stream(context) even though request is in scope. The same code is still present on main.

Steps to reproduce
  1. Host any agent or workflow with ResponsesHostServer.
  2. POST /responses with "metadata": {"foo": "bar"} and "store": true.
  3. Inspect the response.created event, or GET /responses/{id}.

Expected: metadata == {"foo": "bar"}
Actual: metadata is null / missing.

Suggested fix

Pass the request through for fresh (non-recovery) responses:

def _create_response_event_stream(context: ResponseContext, request: CreateResponse) -> ResponseEventStream:
    if context.is_recovery:
        persisted_response = context.persisted_response
        if persisted_response is not None:
            return ResponseEventStream(response=persisted_response, response_id=context.response_id)
    return ResponseEventStream(request=request, response_id=context.response_id)

and call _create_response_event_stream(context, request) from _handle_response.

Current workaround

Monkey-patching the private agent_framework_foundry_hosting._responses._create_response_event_stream to stamp metadata onto stream.response["metadata"] before response.created is emitted. This depends on a private symbol and breaks on upgrade.

Related: #9265 (public per-request / stream-wrapping hooks).

Versions
  • agent-framework-foundry-hosting 1.0.0b260903 (also verified on main)
  • agent-framework 1.18.x
  • azure-ai-agentserver-responses 2.2.0b1, azure-ai-agentserver-core 2.1.0
  • Python 3.14
主要言語
Python
スター
14.2k
フォーク
2.5k
平均マージ
2日 9時間
マージ済み PR(30日)
369

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

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

microsoft/agent-framework のほかの issue

microsoft/agent-framework の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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