Skip to content

Python: [Bug]: AZURE_EXPERIMENTAL_ENABLE_GENAI_TRACING=true crashes agent-framework-openai streaming #7461

Description

@djw-bsn

Description

Setting AZURE_EXPERIMENTAL_ENABLE_GENAI_TRACING=true causes all streaming agent requests to fail with AttributeError: 'AsyncStreamWrapper' object has no attribute 'parse'. The agent returns no response and the error is not clearly linked to the tracing configuration.

Error

AttributeError: 'AsyncStreamWrapper' object has no attribute 'parse'

  File "agent_framework_openai/_chat_client.py", line 740, in _stream
    async with raw_create_response.parse() as stream_response:

Root Cause

When AZURE_EXPERIMENTAL_ENABLE_GENAI_TRACING=true, the Azure OpenTelemetry instrumentation wraps the OpenAI responses client, returning an AsyncStreamWrapper instead of the raw OpenAI response object. agent_framework_openai._chat_client calls .parse() on this object at line 740, which AsyncStreamWrapper does not expose.

Impact

  • All streaming requests fail completely
  • No response is returned to the user
  • The error message does not indicate the tracing configuration as the cause, making it hard to diagnose

Workaround

Set AZURE_EXPERIMENTAL_ENABLE_GENAI_TRACING=false. Side effect: LLM/GenAI spans are not emitted to Application Insights.

Request

Either:

  • Make _chat_client.py handle wrapped response objects from the tracing instrumentation, or
  • Document that AZURE_EXPERIMENTAL_ENABLE_GENAI_TRACING=true is incompatible with the current streaming implementation

Package Versions

agent-framework-openai: 1.12.0, azure-monitor-opentelemetry: 1.8.7, azure-ai-projects: 2.3.0

Python Version

Python: 3.12

Metadata

Metadata

Assignees

No one assigned

    Labels

    pythonUsage: [Issues, PRs], Target: Pythonrequested-infotriageUsage: [Issues], Target: All issues that still need to be triaged

    Type

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions