Skip to content

Python: [Bug]: Foundry Hosted agent - delay before final response when streaming #7487

Description

@cecheta

Description

When a Foundry Hosted agent streams a response, there is a ~5 delay between the last response.output_item.done item and the final response.completed event. This can be seen in the logs:

2026-08-03 14:15:02,826 INFO azure.ai.agentserver: Inbound POST /responses started
2026-08-03 14:15:02,827 INFO azure.ai.agentserver: Creating response caresp_205688e047e259e500PbZ66Mj3R6Omb1FaSrJUaK3conqWDk9c: streaming=True background=False store=True model= conversation_id=None previous_response_id=None has_user_id=False has_call_id=False
2026-08-03 14:15:02,828 INFO azure.ai.agentserver: Invoking handler ResponsesAgentServerHost._dispatch_create for response caresp_205688e047e259e500PbZ66Mj3R6Omb1FaSrJUaK3conqWDk9c
2026-08-03 14:15:02,830 INFO agent_framework: {'role': <MessageRole.USER: 'user'>, 'parts': [{'type': 'text', 'content': 'Hi'}]}
2026-08-03 14:15:02,830 INFO agent_framework: {'role': <MessageRole.USER: 'user'>, 'parts': [{'type': 'text', 'content': 'Hi'}]}
2026-08-03 14:15:03,628 INFO httpx: HTTP Request: POST https://aif-7f6zzbbgxhhmy.services.ai.azure.com/api/projects/proj-7f6zzbbgxhhmy/openai/v1/responses "HTTP/1.1 200 OK"
2026-08-03 14:15:04,155 WARNING agent_framework_foundry_hosting._responses: Content type 'usage' is not supported yet. This is usually safe to ignore.
2026-08-03 14:15:09,171 INFO agent_framework: {'role': 'assistant', 'parts': [{'type': 'text', 'content': 'Hi! How can I help?'}]}
2026-08-03 14:15:09,172 INFO agent_framework: {'role': 'assistant', 'parts': [{'type': 'text', 'content': 'Hi! How can I help?'}]}
2026-08-03 14:15:09,176 INFO azure.ai.agentserver: 127.0.0.1:37214 "POST /responses 1.1" 200 - 6349804μs
2026-08-03 14:15:09,177 INFO azure.ai.agentserver: Inbound POST /responses completed with status 200 in 6350.2ms

Code Sample

import os

from agent_framework import Agent
from agent_framework.foundry import FoundryChatClient
from agent_framework_foundry_hosting import ResponsesHostServer
from azure.identity import DefaultAzureCredential


def main():
    model_name = os.getenv("AZURE_AI_MODEL_DEPLOYMENT_NAME") or os.getenv("FOUNDRY_MODEL_NAME")
    if not model_name:
        raise RuntimeError(
            "Model deployment name is not configured. Set AZURE_AI_MODEL_DEPLOYMENT_NAME or FOUNDRY_MODEL_NAME."
        )

    client = FoundryChatClient(
        project_endpoint=os.environ["FOUNDRY_PROJECT_ENDPOINT"],
        model=model_name,
        credential=DefaultAzureCredential(),
    )

    agent = Agent(
        client=client,
        instructions="You are a friendly assistant. Keep your answers brief.",
        default_options={"store": False},
    )

    server = ResponsesHostServer(agent)
    server.run()


if __name__ == "__main__":
    main()

Error Messages / Stack Traces

Package Versions

agent-framework-core:1.13.0, agent-framework-foundry: 1.10.4, agent-framework-foundry-hosting: 1.0.0b260730, agent-framework-openai: 1.12.0

Python Version

Python 3.13

Additional Context

No response

Metadata

Metadata

Assignees

Labels

hostingUsage: [Issues, PRs], Target: all hosting related solutionspythonUsage: [Issues, PRs], Target: Pythonrequested-info

Type

Projects

Status
No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions