Skip to content

Conversation

@dmytrostruk
Copy link
Member

Motivation and Context

Resolves: #1563

When Azure's asynchronous content filtering is enabled, streaming responses can contain annotation chunks where delta is None. Added a None check to handle these annotation messages gracefully.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

@dmytrostruk dmytrostruk self-assigned this Jan 16, 2026
Copilot AI review requested due to automatic review settings January 16, 2026 23:27
@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Jan 16, 2026

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/core/agent_framework/azure
   _chat_client.py79494%282, 284, 297–298
TOTAL17431266984% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
3149 213 💤 0 ❌ 0 🔥 1m 3s ⏱️

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug in the Azure OpenAI chat client where streaming responses with asynchronous content filtering enabled would fail due to None delta values. The fix adds a None check in the _parse_text_from_openai method override and includes a comprehensive test to verify the behavior.

Changes:

  • Added None check in AzureOpenAIChatClient._parse_text_from_openai to handle empty deltas from async content filtering
  • Added unit test to verify streaming handles None delta chunks correctly

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
python/packages/core/agent_framework/azure/_chat_client.py Added None check before accessing delta properties to prevent AttributeError when Azure async content filtering returns None deltas
python/packages/core/tests/azure/test_azure_chat_client.py Added test case that simulates streaming with None delta chunks followed by actual content

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: Enabling Asynchronous filtering in Azure OpenAI Service causes AttributeError in Streaming

2 participants