diff --git a/python/packages/core/agent_framework/_telemetry.py b/python/packages/core/agent_framework/_telemetry.py index 6351b30bbb..a3b0f74146 100644 --- a/python/packages/core/agent_framework/_telemetry.py +++ b/python/packages/core/agent_framework/_telemetry.py @@ -33,7 +33,7 @@ _user_agent_prefixes: ContextVar[tuple[str, ...]] = ContextVar("_user_agent_pref @contextmanager -def user_agent_prefix(prefix: str) -> Generator[None, None, None]: +def user_agent_prefix(prefix: str) -> Generator[None]: """Context manager that adds a prefix to the user agent string for the current scope. This is useful for upstream layers that want to identify themselves in telemetry diff --git a/python/packages/foundry_hosting/agent_framework_foundry_hosting/_responses.py b/python/packages/foundry_hosting/agent_framework_foundry_hosting/_responses.py index 45c67b8137..0b8d80e8e7 100644 --- a/python/packages/foundry_hosting/agent_framework_foundry_hosting/_responses.py +++ b/python/packages/foundry_hosting/agent_framework_foundry_hosting/_responses.py @@ -81,7 +81,8 @@ from azure.ai.agentserver.responses.streaming._builders import ( ReasoningSummaryPartBuilder, TextContentBuilder, ) -from typing_extensions import Any, Sequence, cast +from typing_extensions import Any +from typing import Sequence, cast logger = logging.getLogger(__name__) @@ -379,7 +380,7 @@ class _OutputItemTracker: self._mcp_builder: OutputItemMcpCallBuilder | None = None self.needs_async = False - def handle(self, content: Content) -> Generator[ResponseStreamEvent, None, None]: + def handle(self, content: Content) -> Generator[ResponseStreamEvent]: """Process a content item, yielding sync events. Sets ``needs_async = True`` if the caller must also drain an @@ -424,13 +425,13 @@ class _OutputItemTracker: yield from self._close() self.needs_async = True - def close(self) -> Generator[ResponseStreamEvent, None, None]: + def close(self) -> Generator[ResponseStreamEvent]: """Close any remaining active builder.""" yield from self._close() # -- Private open/close helpers -- - def _open_message(self) -> Generator[ResponseStreamEvent, None, None]: + def _open_message(self) -> Generator[ResponseStreamEvent]: self._message_item = self._stream.add_output_item_message() self._text_content = self._message_item.add_text_content() self._active_type = "text" @@ -438,7 +439,7 @@ class _OutputItemTracker: yield self._message_item.emit_added() yield self._text_content.emit_added() - def _open_reasoning(self) -> Generator[ResponseStreamEvent, None, None]: + def _open_reasoning(self) -> Generator[ResponseStreamEvent]: self._reasoning_item = self._stream.add_output_item_reasoning_item() self._summary_part = self._reasoning_item.add_summary_part() self._active_type = "text_reasoning" @@ -446,7 +447,7 @@ class _OutputItemTracker: yield self._reasoning_item.emit_added() yield self._summary_part.emit_added() - def _open_function_call(self, content: Content) -> Generator[ResponseStreamEvent, None, None]: + def _open_function_call(self, content: Content) -> Generator[ResponseStreamEvent]: self._fc_builder = self._stream.add_output_item_function_call( name=content.name or "", call_id=content.call_id or "", @@ -455,7 +456,7 @@ class _OutputItemTracker: self._active_id = content.call_id yield self._fc_builder.emit_added() - def _open_mcp_call(self, content: Content) -> Generator[ResponseStreamEvent, None, None]: + def _open_mcp_call(self, content: Content) -> Generator[ResponseStreamEvent]: self._mcp_builder = self._stream.add_output_item_mcp_call( server_label=content.server_name or "default", name=content.tool_name or "", @@ -464,7 +465,7 @@ class _OutputItemTracker: self._active_id = f"{content.server_name or 'default'}::{content.tool_name}" yield self._mcp_builder.emit_added() - def _close(self) -> Generator[ResponseStreamEvent, None, None]: + def _close(self) -> Generator[ResponseStreamEvent]: accumulated = "".join(self._accumulated) if self._active_type == "text" and self._text_content and self._message_item: diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/02_local_tools/main.py b/python/samples/04-hosting/foundry-hosted-agents/responses/02_local_tools/main.py index adf01ee37b..7cba9b821e 100644 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/02_local_tools/main.py +++ b/python/samples/04-hosting/foundry-hosted-agents/responses/02_local_tools/main.py @@ -10,7 +10,7 @@ from agent_framework_foundry_hosting import ResponsesHostServer from azure.identity import AzureCliCredential from dotenv import load_dotenv from pydantic import Field -from typing_extensions import Annotated +from typing import Annotated # Load environment variables from .env file load_dotenv()