Python: fix: AzureAIClient always shows unsupported warning (#4681)#4712
Python: fix: AzureAIClient always shows unsupported warning (#4681)#4712LEDazzio01 wants to merge 7 commits intomicrosoft:mainfrom
Conversation
…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
There was a problem hiding this comment.
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_changedand 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.
| from collections.abc import Mapping | ||
| from typing import Any | ||
| from unittest.mock import MagicMock |
| # 📋 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` | |
Addresses Copilot review feedback.
LEDazzio01
left a comment
There was a problem hiding this comment.
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.
Summary
Fixes #4681
AzureAIClientalways emits a spurious warning:…even when the tool set hasn't actually changed.
Root Cause
In
_remove_agent_level_run_options(), whenwarn_runtime_tools_and_structure_changedisFalse(theuse_latest_versionpath that fetches an existing agent rather than creating one), the code sets:Since the framework always populates
runtime_tools, this is alwaysTrue, causing the warning on every single request — regardless of whether tools actually differ.Fix
Move the
warn_runtime_tools_and_structure_changedcheck to be the outer guard condition. When the flag isFalse(no agent was created by this client), we skip the entire warning block. WhenTrue, we compare the runtime tools against the creation-time set and only warn if they actually differ.Tests
Added
test_azure_ai_client_runtime_warning.pywith tests covering:warn_runtime_tools_and_structure_changedisFalse(regression test for Python: [Bug]: always show warning: "AzureAIClient does not support runtime tools or structured_output overrides after agent creation." #4681)run_options