Skip to content

Python: fix: AzureAIClient always shows unsupported warning (#4681)#4712

Open
LEDazzio01 wants to merge 7 commits intomicrosoft:mainfrom
LEDazzio01:fix/azure-ai-client-spurious-warning
Open

Python: fix: AzureAIClient always shows unsupported warning (#4681)#4712
LEDazzio01 wants to merge 7 commits intomicrosoft:mainfrom
LEDazzio01:fix/azure-ai-client-spurious-warning

Conversation

@LEDazzio01
Copy link
Contributor

Summary

Fixes #4681

AzureAIClient always emits a spurious warning:

"AzureAIClient does not support runtime tools or structured_output overrides after agent creation. Use AzureOpenAIResponsesClient instead."

…even when the tool set hasn't actually changed.

Root Cause

In _remove_agent_level_run_options(), when warn_runtime_tools_and_structure_changed is False (the use_latest_version path that fetches an existing agent rather than creating one), the code sets:

tools_changed = runtime_tools is not None

Since the framework always populates runtime_tools, this is always True, causing the warning on every single request — regardless of whether tools actually differ.

Fix

Move the warn_runtime_tools_and_structure_changed check to be the outer guard condition. When the flag is False (no agent was created by this client), we skip the entire warning block. When True, we compare the runtime tools against the creation-time set and only warn if they actually differ.

-        if runtime_tools is not None or runtime_structured_output is not None:
-            tools_changed = runtime_tools is not None
-            structured_output_changed = runtime_structured_output is not None
-
-            if self.warn_runtime_tools_and_structure_changed:
+        if self.warn_runtime_tools_and_structure_changed and (
+            runtime_tools is not None or runtime_structured_output is not None
+        ):
+            tools_changed = False
+            structured_output_changed = False
+
+            if runtime_tools is not None:

Tests

Added test_azure_ai_client_runtime_warning.py with tests covering:

…t#4681)

Adds unit tests that verify the runtime tools/structured_output
warning is only emitted when warn_runtime_tools_and_structure_changed
is True and the tool set actually differs from the creation-time
configuration.
…ure_changed flag

When `use_latest_version=True` fetches an existing agent instead of creating
one, `warn_runtime_tools_and_structure_changed` stays False. The old code
still set `tools_changed = runtime_tools is not None`, which is always True
(the framework always populates tools), emitting a spurious warning on every
request.

Move the `warn_runtime_tools_and_structure_changed` check to be the outer
guard so the warning is only emitted after the client has actually created an
agent and can compare the creation-time tool set against runtime tools.

Fixes microsoft#4681
Copilot AI review requested due to automatic review settings March 15, 2026 20:16
@markwallace-microsoft markwallace-microsoft added documentation Improvements or additions to documentation python labels Mar 15, 2026
@github-actions github-actions bot changed the title fix: AzureAIClient always shows unsupported warning (#4681) Python: fix: AzureAIClient always shows unsupported warning (#4681) Mar 15, 2026
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

Fixes a spurious AzureAIClient warning that was emitted on every request (notably in the use_latest_version=True path) by only performing the runtime-tools/structured-output mismatch warning logic when the client actually created the agent and can compare against creation-time settings.

Changes:

  • Gate the runtime warning behind warn_runtime_tools_and_structure_changed and compare tool/signature deltas only when tracking is enabled.
  • Add unit tests covering warning/no-warning scenarios and ensuring agent-level keys are stripped from run_options.
  • Add a contribution log markdown file (appears unrelated to the PR purpose).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
python/packages/azure-ai/agent_framework_azure_ai/_client.py Fixes warning logic so it only triggers when tracking agent creation-time config and actual mismatches occur.
python/packages/azure-ai/tests/test_azure_ai_client_runtime_warning.py Adds regression/unit tests for the warning behavior and option stripping.
contribution-logs/2026-03-14.md Adds non-functional contribution status content (unrelated to the described fix).

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +4 to +6
from collections.abc import Mapping
from typing import Any
from unittest.mock import MagicMock
Comment on lines +1 to +20
# 📋 Open Source Contribution Status — March 14, 2026

**Date:** March 14, 2026
**Contributor:** [@LEDazzio01](https://github.com/LEDazzio01)

---

## Today's Actions

### microsoft/agent-framework — Issues #4701 & #4695

| Time | Action |
|------|--------|
| ~12:00 PM | Investigated open issues in `microsoft/agent-framework`; selected #4701 and #4695 |
| ~12:15 PM | Identified root cause for #4701: `_prepare_content_for_openai()` in `_responses_client.py` produces `"status": None` for `function_call` items and omits `status` entirely for `function_call_output` items |
| ~12:30 PM | Implemented fix: `function_call` status defaults to `"completed"` when absent; `function_call_output` always includes `"status": "completed"` |
| ~12:45 PM | Added 4 unit tests in `test_openai_responses_client.py` covering default status, explicit status preservation, and `None` result handling |
| ~1:08 PM | Pushed commit `1ba7fc1d8` to `fix/4701-responses-api-missing-status-field` branch |
| ~1:10 PM | Created [PR #4703](https://github.com/microsoft/agent-framework/pull/4703) — Copilot reviewed 2/2 files, generated no comments ✅ |
| ~1:15 PM | Began deep analysis of #4695 (duplicate handoff messages) — read `_handoff.py` (52KB), `_agent_executor.py`, `_orchestrator_helpers.py` |
Copy link
Contributor Author

@LEDazzio01 LEDazzio01 left a comment

Choose a reason for hiding this comment

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

Thanks for the review! Fixed the unused imports (Mapping, MagicMock) in commit fe8a84c. The contribution-logs/2026-03-14.md is a stale artifact from the fork's main branch — will sync the fork to remove it from the diff.

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

Labels

documentation Improvements or additions to documentation python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: always show warning: "AzureAIClient does not support runtime tools or structured_output overrides after agent creation."

3 participants