You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Python: foundry-hosting drops request metadata from the stored response — _create_response_event_stream never passes request to ResponseEventStream #9529
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:
GetProjectConversationItemsAsync(conversationId) to enumerate message items (items carry no metadata, only ResponseId).
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."""ifcontext.is_recovery:
persisted_response=context.persisted_responseifpersisted_responseisnotNone:
returnResponseEventStream(response=persisted_response, response_id=context.response_id)
returnResponseEventStream(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
Host any agent or workflow with ResponsesHostServer.
POST /responses with "metadata": {"foo": "bar"} and "store": true.
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:
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.
Activity
its-amann commentedon Oct 19, 2026
Hi! I'd like to work on this. Eduard van Valkenburg (@eavanvalkenburg), could you assign it to me? I'll follow up with a PR that includes a fix and tests.