From 0b59c90c1432747a01d4f2ff4c567f13c11bc71c Mon Sep 17 00:00:00 2001 From: Evan Mattson Date: Thu, 23 Apr 2026 19:27:33 +0900 Subject: [PATCH 1/2] Python: Foundry: make response tool sanitizer internal, drop TOOLBOXES warning sanitize_foundry_response_tool runs on every tool passed to the Foundry Responses API, so its @experimental(TOOLBOXES) decorator was emitting a [TOOLBOXES] ExperimentalWarning for any FoundryChatClient call, even when no toolbox was involved. The function isn't in __all__ and has no external callers. Rename to _sanitize_foundry_response_tool and drop the decorator; the actual toolbox-facing public helpers remain gated. --- python/packages/foundry/agent_framework_foundry/_agent.py | 4 ++-- .../packages/foundry/agent_framework_foundry/_chat_client.py | 4 ++-- python/packages/foundry/agent_framework_foundry/_tools.py | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/python/packages/foundry/agent_framework_foundry/_agent.py b/python/packages/foundry/agent_framework_foundry/_agent.py index 0c7f93ba1f..2270e81223 100644 --- a/python/packages/foundry/agent_framework_foundry/_agent.py +++ b/python/packages/foundry/agent_framework_foundry/_agent.py @@ -34,7 +34,7 @@ from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential -from ._tools import sanitize_foundry_response_tool +from ._tools import _sanitize_foundry_response_tool if sys.version_info >= (3, 13): from typing import TypeVar # type: ignore # pragma: no cover @@ -321,7 +321,7 @@ def _prepare_tools_for_openai( surface. """ response_tools = super()._prepare_tools_for_openai(tools) - return [sanitize_foundry_response_tool(tool_item) for tool_item in response_tools] + return [_sanitize_foundry_response_tool(tool_item) for tool_item in response_tools] def _prepare_messages_for_azure_ai(self, messages: Sequence[Message]) -> tuple[list[Message], str | None]: """Extract system/developer messages as instructions for Azure AI. diff --git a/python/packages/foundry/agent_framework_foundry/_chat_client.py b/python/packages/foundry/agent_framework_foundry/_chat_client.py index 735ba9fb57..c687c123a3 100644 --- a/python/packages/foundry/agent_framework_foundry/_chat_client.py +++ b/python/packages/foundry/agent_framework_foundry/_chat_client.py @@ -33,7 +33,7 @@ from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential -from ._tools import fetch_toolbox, sanitize_foundry_response_tool +from ._tools import _sanitize_foundry_response_tool, fetch_toolbox if sys.version_info >= (3, 13): from typing import TypeVar # type: ignore # pragma: no cover @@ -235,7 +235,7 @@ def _prepare_tools_for_openai( them downstream. """ response_tools = super()._prepare_tools_for_openai(tools) - return [sanitize_foundry_response_tool(tool_item) for tool_item in response_tools] + return [_sanitize_foundry_response_tool(tool_item) for tool_item in response_tools] async def configure_azure_monitor( self, diff --git a/python/packages/foundry/agent_framework_foundry/_tools.py b/python/packages/foundry/agent_framework_foundry/_tools.py index 4c5956fcfe..e182db0afa 100644 --- a/python/packages/foundry/agent_framework_foundry/_tools.py +++ b/python/packages/foundry/agent_framework_foundry/_tools.py @@ -155,8 +155,7 @@ def _validate_hosted_tool_payload(sanitized: Mapping[str, Any]) -> None: ) -@experimental(feature_id=ExperimentalFeature.TOOLBOXES) -def sanitize_foundry_response_tool(tool_item: Any) -> Any: +def _sanitize_foundry_response_tool(tool_item: Any) -> Any: """Return a Responses-API-safe tool payload for Foundry hosted tools. Reconciles known mismatches between toolbox reads and the Responses API: From 09d1f8a226f31c2dd83b3d5343dd2a1094e8a1d3 Mon Sep 17 00:00:00 2001 From: Evan Mattson Date: Thu, 23 Apr 2026 19:31:45 +0900 Subject: [PATCH 2/2] Python: Foundry: silence pyright on intentional cross-module private import --- python/packages/foundry/agent_framework_foundry/_agent.py | 2 +- python/packages/foundry/agent_framework_foundry/_chat_client.py | 2 +- python/packages/foundry/agent_framework_foundry/_tools.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/python/packages/foundry/agent_framework_foundry/_agent.py b/python/packages/foundry/agent_framework_foundry/_agent.py index 2270e81223..626881b3ac 100644 --- a/python/packages/foundry/agent_framework_foundry/_agent.py +++ b/python/packages/foundry/agent_framework_foundry/_agent.py @@ -34,7 +34,7 @@ from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential -from ._tools import _sanitize_foundry_response_tool +from ._tools import _sanitize_foundry_response_tool # pyright: ignore[reportPrivateUsage] if sys.version_info >= (3, 13): from typing import TypeVar # type: ignore # pragma: no cover diff --git a/python/packages/foundry/agent_framework_foundry/_chat_client.py b/python/packages/foundry/agent_framework_foundry/_chat_client.py index c687c123a3..353268a129 100644 --- a/python/packages/foundry/agent_framework_foundry/_chat_client.py +++ b/python/packages/foundry/agent_framework_foundry/_chat_client.py @@ -33,7 +33,7 @@ from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential -from ._tools import _sanitize_foundry_response_tool, fetch_toolbox +from ._tools import _sanitize_foundry_response_tool, fetch_toolbox # pyright: ignore[reportPrivateUsage] if sys.version_info >= (3, 13): from typing import TypeVar # type: ignore # pragma: no cover diff --git a/python/packages/foundry/agent_framework_foundry/_tools.py b/python/packages/foundry/agent_framework_foundry/_tools.py index e182db0afa..40b8bf0905 100644 --- a/python/packages/foundry/agent_framework_foundry/_tools.py +++ b/python/packages/foundry/agent_framework_foundry/_tools.py @@ -155,7 +155,7 @@ def _validate_hosted_tool_payload(sanitized: Mapping[str, Any]) -> None: ) -def _sanitize_foundry_response_tool(tool_item: Any) -> Any: +def _sanitize_foundry_response_tool(tool_item: Any) -> Any: # pyright: ignore[reportUnusedFunction] """Return a Responses-API-safe tool payload for Foundry hosted tools. Reconciles known mismatches between toolbox reads and the Responses API: