From c3830cd71267c1cebf843503435cdd9167b53f5c Mon Sep 17 00:00:00 2001 From: Brandon McConnell Date: Wed, 19 Nov 2025 01:17:00 -0500 Subject: [PATCH 1/5] chore: tidy imports --- python/packages/ag-ui/README.md | 4 +- .../agent_framework_ag_ui_examples/README.md | 10 ++--- .../agents/document_writer_agent.py | 4 +- .../agents/human_in_the_loop_agent.py | 2 +- .../agents/recipe_agent.py | 4 +- .../agents/research_assistant_agent.py | 4 +- .../agents/simple_agent.py | 2 +- .../agents/task_planner_agent.py | 4 +- .../agents/task_steps_agent.py | 4 +- .../agents/ui_generator_agent.py | 4 +- .../agents/weather_agent.py | 2 +- .../server/api/backend_tool_rendering.py | 2 +- .../server/main.py | 2 +- .../packages/ag-ui/getting_started/client.py | 2 +- .../ag-ui/getting_started/client_advanced.py | 2 +- .../getting_started/client_with_agent.py | 2 +- .../tests/test_agent_wrapper_comprehensive.py | 40 +++++++++---------- .../ag-ui/tests/test_structured_output.py | 14 +++---- .../_callbacks.py | 5 --- .../agent_framework_azurefunctions/_errors.py | 3 -- .../agent_framework_azurefunctions/_models.py | 2 - .../core/agent_framework/ag_ui/__init__.pyi | 2 +- .../core/agent_framework/observability.py | 2 +- .../core/tests/core/test_middleware.py | 2 +- .../devui/agent_framework_devui/_discovery.py | 2 - .../models/_discovery_models.py | 2 - .../models/_openai_custom.py | 2 - .../purview/agent_framework_purview/_cache.py | 2 - .../agent_framework_purview/_client.py | 1 - .../agent_framework_purview/_exceptions.py | 2 - .../agent_framework_purview/_middleware.py | 1 - .../agent_framework_purview/_models.py | 2 - .../agent_framework_purview/_processor.py | 1 - .../agent_framework_purview/_settings.py | 2 - .../_chat_message_store.py | 2 - .../purview_agent/sample_purview_agent.py | 1 - 36 files changed, 57 insertions(+), 87 deletions(-) diff --git a/python/packages/ag-ui/README.md b/python/packages/ag-ui/README.md index 2b02b61090..1e3d6b567f 100644 --- a/python/packages/ag-ui/README.md +++ b/python/packages/ag-ui/README.md @@ -16,7 +16,7 @@ pip install agent-framework-ag-ui from fastapi import FastAPI from agent_framework import ChatAgent from agent_framework.azure import AzureOpenAIChatClient -from agent_framework_ag_ui import add_agent_framework_fastapi_endpoint +from agent_framework.ag_ui import add_agent_framework_fastapi_endpoint # Create your agent agent = ChatAgent( @@ -41,7 +41,7 @@ add_agent_framework_fastapi_endpoint(app, agent, "/") ```python import asyncio from agent_framework import TextContent -from agent_framework_ag_ui import AGUIChatClient +from agent_framework.ag_ui import AGUIChatClient async def main(): async with AGUIChatClient(endpoint="http://localhost:8000/") as client: diff --git a/python/packages/ag-ui/agent_framework_ag_ui_examples/README.md b/python/packages/ag-ui/agent_framework_ag_ui_examples/README.md index aed0f39b42..620f18dbbf 100644 --- a/python/packages/ag-ui/agent_framework_ag_ui_examples/README.md +++ b/python/packages/ag-ui/agent_framework_ag_ui_examples/README.md @@ -18,7 +18,7 @@ All example agents are factory functions that accept any `ChatClientProtocol`-co from fastapi import FastAPI from agent_framework.azure import AzureOpenAIChatClient from agent_framework.openai import OpenAIChatClient -from agent_framework_ag_ui import add_agent_framework_fastapi_endpoint +from agent_framework.ag_ui import add_agent_framework_fastapi_endpoint from agent_framework_ag_ui_examples.agents import simple_agent, weather_agent app = FastAPI() @@ -40,7 +40,7 @@ add_agent_framework_fastapi_endpoint(app, weather_agent(openai_client), "/weathe from fastapi import FastAPI from agent_framework import ChatAgent from agent_framework.azure import AzureOpenAIChatClient -from agent_framework_ag_ui import add_agent_framework_fastapi_endpoint +from agent_framework.ag_ui import add_agent_framework_fastapi_endpoint # Create your agent agent = ChatAgent( @@ -136,7 +136,7 @@ The server exposes endpoints at: ```python from fastapi import FastAPI from agent_framework.azure import AzureOpenAIChatClient -from agent_framework_ag_ui import add_agent_framework_fastapi_endpoint +from agent_framework.ag_ui import add_agent_framework_fastapi_endpoint from agent_framework_ag_ui_examples.agents import ( simple_agent, weather_agent, @@ -188,8 +188,8 @@ You can create your own agent factories following the same pattern as the exampl ```python from agent_framework import ChatAgent, ai_function -from agent_framework._clients import ChatClientProtocol -from agent_framework_ag_ui import AgentFrameworkAgent +from agent_framework import ChatClientProtocol +from agent_framework.ag_ui import AgentFrameworkAgent @ai_function def my_tool(param: str) -> str: diff --git a/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/document_writer_agent.py b/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/document_writer_agent.py index 72623379ed..bea0932273 100644 --- a/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/document_writer_agent.py +++ b/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/document_writer_agent.py @@ -3,9 +3,9 @@ """Example agent demonstrating predictive state updates with document writing.""" from agent_framework import ChatAgent, ai_function -from agent_framework._clients import ChatClientProtocol +from agent_framework import ChatClientProtocol -from agent_framework_ag_ui import AgentFrameworkAgent, DocumentWriterConfirmationStrategy +from agent_framework.ag_ui import AgentFrameworkAgent, DocumentWriterConfirmationStrategy @ai_function diff --git a/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/human_in_the_loop_agent.py b/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/human_in_the_loop_agent.py index 8b178476af..b01ce337b6 100644 --- a/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/human_in_the_loop_agent.py +++ b/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/human_in_the_loop_agent.py @@ -5,7 +5,7 @@ from enum import Enum from agent_framework import ChatAgent, ai_function -from agent_framework._clients import ChatClientProtocol +from agent_framework import ChatClientProtocol from pydantic import BaseModel, Field diff --git a/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/recipe_agent.py b/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/recipe_agent.py index e39fb8c75e..d419b1b9b8 100644 --- a/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/recipe_agent.py +++ b/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/recipe_agent.py @@ -5,10 +5,10 @@ from enum import Enum from agent_framework import ChatAgent, ai_function -from agent_framework._clients import ChatClientProtocol +from agent_framework import ChatClientProtocol from pydantic import BaseModel, Field -from agent_framework_ag_ui import AgentFrameworkAgent, RecipeConfirmationStrategy +from agent_framework.ag_ui import AgentFrameworkAgent, RecipeConfirmationStrategy class SkillLevel(str, Enum): diff --git a/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/research_assistant_agent.py b/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/research_assistant_agent.py index 767ed1d961..bbfc7a124e 100644 --- a/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/research_assistant_agent.py +++ b/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/research_assistant_agent.py @@ -5,9 +5,9 @@ import asyncio from agent_framework import ChatAgent, ai_function -from agent_framework._clients import ChatClientProtocol +from agent_framework import ChatClientProtocol -from agent_framework_ag_ui import AgentFrameworkAgent +from agent_framework.ag_ui import AgentFrameworkAgent @ai_function diff --git a/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/simple_agent.py b/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/simple_agent.py index bb63170399..1c74062272 100644 --- a/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/simple_agent.py +++ b/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/simple_agent.py @@ -3,7 +3,7 @@ """Simple agentic chat example (Feature 1: Agentic Chat).""" from agent_framework import ChatAgent -from agent_framework._clients import ChatClientProtocol +from agent_framework import ChatClientProtocol def simple_agent(chat_client: ChatClientProtocol) -> ChatAgent: diff --git a/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/task_planner_agent.py b/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/task_planner_agent.py index f9eea2669b..38b50ea85a 100644 --- a/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/task_planner_agent.py +++ b/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/task_planner_agent.py @@ -3,9 +3,9 @@ """Example agent demonstrating human-in-the-loop with function approvals.""" from agent_framework import ChatAgent, ai_function -from agent_framework._clients import ChatClientProtocol +from agent_framework import ChatClientProtocol -from agent_framework_ag_ui import AgentFrameworkAgent, TaskPlannerConfirmationStrategy +from agent_framework.ag_ui import AgentFrameworkAgent, TaskPlannerConfirmationStrategy @ai_function(approval_mode="always_require") diff --git a/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/task_steps_agent.py b/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/task_steps_agent.py index 332e416215..be41e58455 100644 --- a/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/task_steps_agent.py +++ b/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/task_steps_agent.py @@ -19,10 +19,10 @@ ToolCallStartEvent, ) from agent_framework import ChatAgent, ai_function -from agent_framework._clients import ChatClientProtocol +from agent_framework import ChatClientProtocol from pydantic import BaseModel, Field -from agent_framework_ag_ui import AgentFrameworkAgent +from agent_framework.ag_ui import AgentFrameworkAgent class StepStatus(str, Enum): diff --git a/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/ui_generator_agent.py b/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/ui_generator_agent.py index 12f1a9341e..dbab376e02 100644 --- a/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/ui_generator_agent.py +++ b/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/ui_generator_agent.py @@ -5,9 +5,9 @@ from typing import Any from agent_framework import AIFunction, ChatAgent -from agent_framework._clients import ChatClientProtocol +from agent_framework import ChatClientProtocol -from agent_framework_ag_ui import AgentFrameworkAgent +from agent_framework.ag_ui import AgentFrameworkAgent # Declaration-only tools (func=None) - actual rendering happens on the client side generate_haiku = AIFunction[Any, str]( diff --git a/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/weather_agent.py b/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/weather_agent.py index e48a9cab50..b066ff166f 100644 --- a/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/weather_agent.py +++ b/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/weather_agent.py @@ -5,7 +5,7 @@ from typing import Any from agent_framework import ChatAgent, ai_function -from agent_framework._clients import ChatClientProtocol +from agent_framework import ChatClientProtocol @ai_function diff --git a/python/packages/ag-ui/agent_framework_ag_ui_examples/server/api/backend_tool_rendering.py b/python/packages/ag-ui/agent_framework_ag_ui_examples/server/api/backend_tool_rendering.py index 0ff360efb2..557a18454b 100644 --- a/python/packages/ag-ui/agent_framework_ag_ui_examples/server/api/backend_tool_rendering.py +++ b/python/packages/ag-ui/agent_framework_ag_ui_examples/server/api/backend_tool_rendering.py @@ -5,7 +5,7 @@ from agent_framework.azure import AzureOpenAIChatClient from fastapi import FastAPI -from agent_framework_ag_ui import add_agent_framework_fastapi_endpoint +from agent_framework.ag_ui import add_agent_framework_fastapi_endpoint from ...agents.weather_agent import weather_agent diff --git a/python/packages/ag-ui/agent_framework_ag_ui_examples/server/main.py b/python/packages/ag-ui/agent_framework_ag_ui_examples/server/main.py index e633268c50..efb5a86527 100644 --- a/python/packages/ag-ui/agent_framework_ag_ui_examples/server/main.py +++ b/python/packages/ag-ui/agent_framework_ag_ui_examples/server/main.py @@ -10,7 +10,7 @@ from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware -from agent_framework_ag_ui import add_agent_framework_fastapi_endpoint +from agent_framework.ag_ui import add_agent_framework_fastapi_endpoint from ..agents.document_writer_agent import document_writer_agent from ..agents.human_in_the_loop_agent import human_in_the_loop_agent diff --git a/python/packages/ag-ui/getting_started/client.py b/python/packages/ag-ui/getting_started/client.py index 621d8536cd..61bdf0bfb3 100644 --- a/python/packages/ag-ui/getting_started/client.py +++ b/python/packages/ag-ui/getting_started/client.py @@ -10,7 +10,7 @@ import asyncio import os -from agent_framework_ag_ui import AGUIChatClient +from agent_framework.ag_ui import AGUIChatClient async def main(): diff --git a/python/packages/ag-ui/getting_started/client_advanced.py b/python/packages/ag-ui/getting_started/client_advanced.py index cb45a0b8da..17c8f86668 100644 --- a/python/packages/ag-ui/getting_started/client_advanced.py +++ b/python/packages/ag-ui/getting_started/client_advanced.py @@ -14,7 +14,7 @@ from agent_framework import ai_function -from agent_framework_ag_ui import AGUIChatClient +from agent_framework.ag_ui import AGUIChatClient @ai_function diff --git a/python/packages/ag-ui/getting_started/client_with_agent.py b/python/packages/ag-ui/getting_started/client_with_agent.py index ac69189b53..445f1472c7 100644 --- a/python/packages/ag-ui/getting_started/client_with_agent.py +++ b/python/packages/ag-ui/getting_started/client_with_agent.py @@ -24,7 +24,7 @@ from agent_framework import ChatAgent, FunctionCallContent, FunctionResultContent, TextContent, ai_function -from agent_framework_ag_ui import AGUIChatClient +from agent_framework.ag_ui import AGUIChatClient # Enable debug logging logging.basicConfig( diff --git a/python/packages/ag-ui/tests/test_agent_wrapper_comprehensive.py b/python/packages/ag-ui/tests/test_agent_wrapper_comprehensive.py index 4b5b770509..dbf0160ae6 100644 --- a/python/packages/ag-ui/tests/test_agent_wrapper_comprehensive.py +++ b/python/packages/ag-ui/tests/test_agent_wrapper_comprehensive.py @@ -11,7 +11,7 @@ async def test_agent_initialization_basic(): """Test basic agent initialization without state schema.""" - from agent_framework_ag_ui import AgentFrameworkAgent + from agent_framework.ag_ui import AgentFrameworkAgent class MockChatClient: async def get_streaming_response(self, messages, chat_options, **kwargs): @@ -28,7 +28,7 @@ async def get_streaming_response(self, messages, chat_options, **kwargs): async def test_agent_initialization_with_state_schema(): """Test agent initialization with state_schema.""" - from agent_framework_ag_ui import AgentFrameworkAgent + from agent_framework.ag_ui import AgentFrameworkAgent class MockChatClient: async def get_streaming_response(self, messages, chat_options, **kwargs): @@ -43,7 +43,7 @@ async def get_streaming_response(self, messages, chat_options, **kwargs): async def test_agent_initialization_with_predict_state_config(): """Test agent initialization with predict_state_config.""" - from agent_framework_ag_ui import AgentFrameworkAgent + from agent_framework.ag_ui import AgentFrameworkAgent class MockChatClient: async def get_streaming_response(self, messages, chat_options, **kwargs): @@ -58,7 +58,7 @@ async def get_streaming_response(self, messages, chat_options, **kwargs): async def test_run_started_event_emission(): """Test RunStartedEvent is emitted at start of run.""" - from agent_framework_ag_ui import AgentFrameworkAgent + from agent_framework.ag_ui import AgentFrameworkAgent class MockChatClient: async def get_streaming_response(self, messages, chat_options, **kwargs): @@ -81,7 +81,7 @@ async def get_streaming_response(self, messages, chat_options, **kwargs): async def test_predict_state_custom_event_emission(): """Test PredictState CustomEvent is emitted when predict_state_config is present.""" - from agent_framework_ag_ui import AgentFrameworkAgent + from agent_framework.ag_ui import AgentFrameworkAgent class MockChatClient: async def get_streaming_response(self, messages, chat_options, **kwargs): @@ -112,7 +112,7 @@ async def get_streaming_response(self, messages, chat_options, **kwargs): async def test_initial_state_snapshot_with_schema(): """Test initial StateSnapshotEvent emission when state_schema present.""" - from agent_framework_ag_ui import AgentFrameworkAgent + from agent_framework.ag_ui import AgentFrameworkAgent class MockChatClient: async def get_streaming_response(self, messages, chat_options, **kwargs): @@ -141,7 +141,7 @@ async def get_streaming_response(self, messages, chat_options, **kwargs): async def test_state_initialization_object_type(): """Test state initialization with object type in schema.""" - from agent_framework_ag_ui import AgentFrameworkAgent + from agent_framework.ag_ui import AgentFrameworkAgent class MockChatClient: async def get_streaming_response(self, messages, chat_options, **kwargs): @@ -167,7 +167,7 @@ async def get_streaming_response(self, messages, chat_options, **kwargs): async def test_state_initialization_array_type(): """Test state initialization with array type in schema.""" - from agent_framework_ag_ui import AgentFrameworkAgent + from agent_framework.ag_ui import AgentFrameworkAgent class MockChatClient: async def get_streaming_response(self, messages, chat_options, **kwargs): @@ -193,7 +193,7 @@ async def get_streaming_response(self, messages, chat_options, **kwargs): async def test_run_finished_event_emission(): """Test RunFinishedEvent is emitted at end of run.""" - from agent_framework_ag_ui import AgentFrameworkAgent + from agent_framework.ag_ui import AgentFrameworkAgent class MockChatClient: async def get_streaming_response(self, messages, chat_options, **kwargs): @@ -214,7 +214,7 @@ async def get_streaming_response(self, messages, chat_options, **kwargs): async def test_tool_result_confirm_changes_accepted(): """Test confirm_changes tool result handling when accepted.""" - from agent_framework_ag_ui import AgentFrameworkAgent + from agent_framework.ag_ui import AgentFrameworkAgent class MockChatClient: async def get_streaming_response(self, messages, chat_options, **kwargs): @@ -260,7 +260,7 @@ async def get_streaming_response(self, messages, chat_options, **kwargs): async def test_tool_result_confirm_changes_rejected(): """Test confirm_changes tool result handling when rejected.""" - from agent_framework_ag_ui import AgentFrameworkAgent + from agent_framework.ag_ui import AgentFrameworkAgent class MockChatClient: async def get_streaming_response(self, messages, chat_options, **kwargs): @@ -293,7 +293,7 @@ async def get_streaming_response(self, messages, chat_options, **kwargs): async def test_tool_result_function_approval_accepted(): """Test function approval tool result when steps are accepted.""" - from agent_framework_ag_ui import AgentFrameworkAgent + from agent_framework.ag_ui import AgentFrameworkAgent class MockChatClient: async def get_streaming_response(self, messages, chat_options, **kwargs): @@ -338,7 +338,7 @@ async def get_streaming_response(self, messages, chat_options, **kwargs): async def test_tool_result_function_approval_rejected(): """Test function approval tool result when rejected.""" - from agent_framework_ag_ui import AgentFrameworkAgent + from agent_framework.ag_ui import AgentFrameworkAgent class MockChatClient: async def get_streaming_response(self, messages, chat_options, **kwargs): @@ -374,7 +374,7 @@ async def get_streaming_response(self, messages, chat_options, **kwargs): async def test_thread_metadata_tracking(): """Test that thread metadata includes ag_ui_thread_id and ag_ui_run_id.""" - from agent_framework_ag_ui import AgentFrameworkAgent + from agent_framework.ag_ui import AgentFrameworkAgent thread_metadata = {} @@ -405,7 +405,7 @@ async def get_streaming_response(self, messages, chat_options, **kwargs): async def test_state_context_injection(): """Test that current state is injected into thread metadata.""" - from agent_framework_ag_ui import AgentFrameworkAgent + from agent_framework.ag_ui import AgentFrameworkAgent thread_metadata = {} @@ -436,7 +436,7 @@ async def get_streaming_response(self, messages, chat_options, **kwargs): async def test_no_messages_provided(): """Test handling when no messages are provided.""" - from agent_framework_ag_ui import AgentFrameworkAgent + from agent_framework.ag_ui import AgentFrameworkAgent class MockChatClient: async def get_streaming_response(self, messages, chat_options, **kwargs): @@ -459,7 +459,7 @@ async def get_streaming_response(self, messages, chat_options, **kwargs): async def test_message_end_event_emission(): """Test TextMessageEndEvent is emitted for assistant messages.""" - from agent_framework_ag_ui import AgentFrameworkAgent + from agent_framework.ag_ui import AgentFrameworkAgent class MockChatClient: async def get_streaming_response(self, messages, chat_options, **kwargs): @@ -486,7 +486,7 @@ async def get_streaming_response(self, messages, chat_options, **kwargs): async def test_error_handling_with_exception(): """Test that exceptions during agent execution are re-raised.""" - from agent_framework_ag_ui import AgentFrameworkAgent + from agent_framework.ag_ui import AgentFrameworkAgent class FailingChatClient: async def get_streaming_response(self, messages, chat_options, **kwargs): @@ -506,7 +506,7 @@ async def get_streaming_response(self, messages, chat_options, **kwargs): async def test_json_decode_error_in_tool_result(): """Test handling of orphaned tool result - should be sanitized out.""" - from agent_framework_ag_ui import AgentFrameworkAgent + from agent_framework.ag_ui import AgentFrameworkAgent class MockChatClient: async def get_streaming_response(self, messages, chat_options, **kwargs): @@ -543,7 +543,7 @@ async def get_streaming_response(self, messages, chat_options, **kwargs): async def test_suppressed_summary_with_document_state(): """Test suppressed summary uses document state for confirmation message.""" - from agent_framework_ag_ui import AgentFrameworkAgent, DocumentWriterConfirmationStrategy + from agent_framework.ag_ui import AgentFrameworkAgent, DocumentWriterConfirmationStrategy class MockChatClient: async def get_streaming_response(self, messages, chat_options, **kwargs): diff --git a/python/packages/ag-ui/tests/test_structured_output.py b/python/packages/ag-ui/tests/test_structured_output.py index 878002a8e1..10307356a5 100644 --- a/python/packages/ag-ui/tests/test_structured_output.py +++ b/python/packages/ag-ui/tests/test_structured_output.py @@ -32,7 +32,7 @@ class GenericOutput(BaseModel): async def test_structured_output_with_recipe(): """Test structured output processing with recipe state.""" - from agent_framework_ag_ui import AgentFrameworkAgent + from agent_framework.ag_ui import AgentFrameworkAgent class MockChatClient: async def get_streaming_response(self, messages, chat_options, **kwargs): @@ -70,7 +70,7 @@ async def get_streaming_response(self, messages, chat_options, **kwargs): async def test_structured_output_with_steps(): """Test structured output processing with steps state.""" - from agent_framework_ag_ui import AgentFrameworkAgent + from agent_framework.ag_ui import AgentFrameworkAgent class MockChatClient: async def get_streaming_response(self, messages, chat_options, **kwargs): @@ -109,7 +109,7 @@ async def get_streaming_response(self, messages, chat_options, **kwargs): async def test_structured_output_with_no_schema_match(): """Test structured output when response fields don't match state_schema keys.""" - from agent_framework_ag_ui import AgentFrameworkAgent + from agent_framework.ag_ui import AgentFrameworkAgent class MockChatClient: async def get_streaming_response(self, messages, chat_options, **kwargs): @@ -138,7 +138,7 @@ async def get_streaming_response(self, messages, chat_options, **kwargs): async def test_structured_output_without_schema(): """Test structured output without state_schema treats all fields as state.""" - from agent_framework_ag_ui import AgentFrameworkAgent + from agent_framework.ag_ui import AgentFrameworkAgent class DataOutput(BaseModel): """Output with data and info fields.""" @@ -175,7 +175,7 @@ async def get_streaming_response(self, messages, chat_options, **kwargs): async def test_no_structured_output_when_no_response_format(): """Test that structured output path is skipped when no response_format.""" - from agent_framework_ag_ui import AgentFrameworkAgent + from agent_framework.ag_ui import AgentFrameworkAgent class MockChatClient: async def get_streaming_response(self, messages, chat_options, **kwargs): @@ -200,7 +200,7 @@ async def get_streaming_response(self, messages, chat_options, **kwargs): async def test_structured_output_with_message_field(): """Test structured output that includes a message field.""" - from agent_framework_ag_ui import AgentFrameworkAgent + from agent_framework.ag_ui import AgentFrameworkAgent class MockChatClient: async def get_streaming_response(self, messages, chat_options, **kwargs): @@ -234,7 +234,7 @@ async def get_streaming_response(self, messages, chat_options, **kwargs): async def test_empty_updates_no_structured_processing(): """Test that empty updates don't trigger structured output processing.""" - from agent_framework_ag_ui import AgentFrameworkAgent + from agent_framework.ag_ui import AgentFrameworkAgent class MockChatClient: async def get_streaming_response(self, messages, chat_options, **kwargs): diff --git a/python/packages/azurefunctions/agent_framework_azurefunctions/_callbacks.py b/python/packages/azurefunctions/agent_framework_azurefunctions/_callbacks.py index 31b31111ac..4f79b1fed5 100644 --- a/python/packages/azurefunctions/agent_framework_azurefunctions/_callbacks.py +++ b/python/packages/azurefunctions/agent_framework_azurefunctions/_callbacks.py @@ -6,14 +6,9 @@ invoked during durable entity execution. """ -from __future__ import annotations - from dataclasses import dataclass from typing import Protocol -from agent_framework import AgentRunResponse, AgentRunResponseUpdate - - @dataclass(frozen=True) class AgentCallbackContext: """Context supplied to callback invocations.""" diff --git a/python/packages/azurefunctions/agent_framework_azurefunctions/_errors.py b/python/packages/azurefunctions/agent_framework_azurefunctions/_errors.py index b2f96c7ebb..849784f3a0 100644 --- a/python/packages/azurefunctions/agent_framework_azurefunctions/_errors.py +++ b/python/packages/azurefunctions/agent_framework_azurefunctions/_errors.py @@ -2,9 +2,6 @@ """Custom exception types for the durable agent framework.""" -from __future__ import annotations - - class IncomingRequestError(ValueError): """Raised when an incoming HTTP request cannot be parsed or validated.""" diff --git a/python/packages/azurefunctions/agent_framework_azurefunctions/_models.py b/python/packages/azurefunctions/agent_framework_azurefunctions/_models.py index 015ca40754..1bcaeb68d0 100644 --- a/python/packages/azurefunctions/agent_framework_azurefunctions/_models.py +++ b/python/packages/azurefunctions/agent_framework_azurefunctions/_models.py @@ -5,8 +5,6 @@ This module defines the request and response models used by the framework. """ -from __future__ import annotations - import inspect import uuid from collections.abc import MutableMapping diff --git a/python/packages/core/agent_framework/ag_ui/__init__.pyi b/python/packages/core/agent_framework/ag_ui/__init__.pyi index 201e1a0256..1a8bd9588b 100644 --- a/python/packages/core/agent_framework/ag_ui/__init__.pyi +++ b/python/packages/core/agent_framework/ag_ui/__init__.pyi @@ -1,6 +1,6 @@ # Copyright (c) Microsoft. All rights reserved. -from agent_framework_ag_ui import ( +from agent_framework.ag_ui import ( AgentFrameworkAgent, AGUIChatClient, AGUIEventConverter, diff --git a/python/packages/core/agent_framework/observability.py b/python/packages/core/agent_framework/observability.py index 3e44fae23c..8d465a7f55 100644 --- a/python/packages/core/agent_framework/observability.py +++ b/python/packages/core/agent_framework/observability.py @@ -1021,7 +1021,7 @@ def use_observability( .. code-block:: python from agent_framework import use_observability, setup_observability - from agent_framework._clients import ChatClientProtocol + from agent_framework import ChatClientProtocol # Decorate a custom chat client class diff --git a/python/packages/core/tests/core/test_middleware.py b/python/packages/core/tests/core/test_middleware.py index 8f0d67aa18..a84c8927d0 100644 --- a/python/packages/core/tests/core/test_middleware.py +++ b/python/packages/core/tests/core/test_middleware.py @@ -1693,7 +1693,7 @@ def mock_function() -> AIFunction[Any, Any]: @pytest.fixture def mock_chat_client() -> Any: """Mock chat client for testing.""" - from agent_framework._clients import ChatClientProtocol + from agent_framework import ChatClientProtocol client = MagicMock(spec=ChatClientProtocol) client.service_url = MagicMock(return_value="mock://test") diff --git a/python/packages/devui/agent_framework_devui/_discovery.py b/python/packages/devui/agent_framework_devui/_discovery.py index 99265b5d52..d7af6159fd 100644 --- a/python/packages/devui/agent_framework_devui/_discovery.py +++ b/python/packages/devui/agent_framework_devui/_discovery.py @@ -2,8 +2,6 @@ """Agent Framework entity discovery implementation.""" -from __future__ import annotations - import ast import importlib import importlib.util diff --git a/python/packages/devui/agent_framework_devui/models/_discovery_models.py b/python/packages/devui/agent_framework_devui/models/_discovery_models.py index cdb5d0619c..382639b277 100644 --- a/python/packages/devui/agent_framework_devui/models/_discovery_models.py +++ b/python/packages/devui/agent_framework_devui/models/_discovery_models.py @@ -2,8 +2,6 @@ """Discovery API models for entity information.""" -from __future__ import annotations - import re from typing import Any diff --git a/python/packages/devui/agent_framework_devui/models/_openai_custom.py b/python/packages/devui/agent_framework_devui/models/_openai_custom.py index f82ef90b72..c0c12e637e 100644 --- a/python/packages/devui/agent_framework_devui/models/_openai_custom.py +++ b/python/packages/devui/agent_framework_devui/models/_openai_custom.py @@ -6,8 +6,6 @@ to support Agent Framework specific features like workflows and traces. """ -from __future__ import annotations - from dataclasses import dataclass from typing import Any, Literal diff --git a/python/packages/purview/agent_framework_purview/_cache.py b/python/packages/purview/agent_framework_purview/_cache.py index 5f9f6fe5bb..d559895a63 100644 --- a/python/packages/purview/agent_framework_purview/_cache.py +++ b/python/packages/purview/agent_framework_purview/_cache.py @@ -1,8 +1,6 @@ # Copyright (c) Microsoft. All rights reserved. """Cache provider for Purview data.""" -from __future__ import annotations - import hashlib import heapq import json diff --git a/python/packages/purview/agent_framework_purview/_client.py b/python/packages/purview/agent_framework_purview/_client.py index 2ed37722cf..351c1a6bee 100644 --- a/python/packages/purview/agent_framework_purview/_client.py +++ b/python/packages/purview/agent_framework_purview/_client.py @@ -1,5 +1,4 @@ # Copyright (c) Microsoft. All rights reserved. -from __future__ import annotations import base64 import inspect diff --git a/python/packages/purview/agent_framework_purview/_exceptions.py b/python/packages/purview/agent_framework_purview/_exceptions.py index 8ddaf5bc28..6f917dee79 100644 --- a/python/packages/purview/agent_framework_purview/_exceptions.py +++ b/python/packages/purview/agent_framework_purview/_exceptions.py @@ -1,8 +1,6 @@ # Copyright (c) Microsoft. All rights reserved. """Purview specific exceptions (minimal error shaping).""" -from __future__ import annotations - from agent_framework.exceptions import ServiceResponseException __all__ = [ diff --git a/python/packages/purview/agent_framework_purview/_middleware.py b/python/packages/purview/agent_framework_purview/_middleware.py index da43d8d9f4..108cf40410 100644 --- a/python/packages/purview/agent_framework_purview/_middleware.py +++ b/python/packages/purview/agent_framework_purview/_middleware.py @@ -1,5 +1,4 @@ # Copyright (c) Microsoft. All rights reserved. -from __future__ import annotations from collections.abc import Awaitable, Callable diff --git a/python/packages/purview/agent_framework_purview/_models.py b/python/packages/purview/agent_framework_purview/_models.py index 0ee502da1a..e361916cbd 100644 --- a/python/packages/purview/agent_framework_purview/_models.py +++ b/python/packages/purview/agent_framework_purview/_models.py @@ -2,8 +2,6 @@ """Unified Purview model definitions and public export surface.""" -from __future__ import annotations - from collections.abc import Mapping, MutableMapping, Sequence from datetime import datetime from enum import Enum, Flag, auto diff --git a/python/packages/purview/agent_framework_purview/_processor.py b/python/packages/purview/agent_framework_purview/_processor.py index 44163dc2f6..0e197b78c0 100644 --- a/python/packages/purview/agent_framework_purview/_processor.py +++ b/python/packages/purview/agent_framework_purview/_processor.py @@ -1,5 +1,4 @@ # Copyright (c) Microsoft. All rights reserved. -from __future__ import annotations import asyncio import uuid diff --git a/python/packages/purview/agent_framework_purview/_settings.py b/python/packages/purview/agent_framework_purview/_settings.py index 3e3d13ada6..529b1399aa 100644 --- a/python/packages/purview/agent_framework_purview/_settings.py +++ b/python/packages/purview/agent_framework_purview/_settings.py @@ -1,7 +1,5 @@ # Copyright (c) Microsoft. All rights reserved. -from __future__ import annotations - from enum import Enum from agent_framework._pydantic import AFBaseSettings diff --git a/python/packages/redis/agent_framework_redis/_chat_message_store.py b/python/packages/redis/agent_framework_redis/_chat_message_store.py index 4c83dcc86f..e5bb8453ff 100644 --- a/python/packages/redis/agent_framework_redis/_chat_message_store.py +++ b/python/packages/redis/agent_framework_redis/_chat_message_store.py @@ -1,7 +1,5 @@ # Copyright (c) Microsoft. All rights reserved. -from __future__ import annotations - from collections.abc import Sequence from typing import Any from uuid import uuid4 diff --git a/python/samples/getting_started/purview_agent/sample_purview_agent.py b/python/samples/getting_started/purview_agent/sample_purview_agent.py index 4d9b0d612c..041fe627a3 100644 --- a/python/samples/getting_started/purview_agent/sample_purview_agent.py +++ b/python/samples/getting_started/purview_agent/sample_purview_agent.py @@ -20,7 +20,6 @@ - PURVIEW_CERT_PASSWORD (optional) - PURVIEW_DEFAULT_USER_ID (optional, user ID for Purview evaluation) """ -from __future__ import annotations import asyncio import os From c80fcf82c336cc2d1ca7679f6ce1f435757eb070 Mon Sep 17 00:00:00 2001 From: Brandon McConnell Date: Wed, 19 Nov 2025 01:54:29 -0500 Subject: [PATCH 2/5] Update python/packages/azurefunctions/agent_framework_azurefunctions/_errors.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../azurefunctions/agent_framework_azurefunctions/_errors.py | 1 - 1 file changed, 1 deletion(-) diff --git a/python/packages/azurefunctions/agent_framework_azurefunctions/_errors.py b/python/packages/azurefunctions/agent_framework_azurefunctions/_errors.py index 849784f3a0..79e516c8be 100644 --- a/python/packages/azurefunctions/agent_framework_azurefunctions/_errors.py +++ b/python/packages/azurefunctions/agent_framework_azurefunctions/_errors.py @@ -1,7 +1,6 @@ # Copyright (c) Microsoft. All rights reserved. """Custom exception types for the durable agent framework.""" - class IncomingRequestError(ValueError): """Raised when an incoming HTTP request cannot be parsed or validated.""" From 22cc26d7c4cd7c307e29b8665708d900d9a396e5 Mon Sep 17 00:00:00 2001 From: Brandon McConnell Date: Wed, 19 Nov 2025 01:55:45 -0500 Subject: [PATCH 3/5] Update python/packages/azurefunctions/agent_framework_azurefunctions/_callbacks.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../azurefunctions/agent_framework_azurefunctions/_callbacks.py | 1 + 1 file changed, 1 insertion(+) diff --git a/python/packages/azurefunctions/agent_framework_azurefunctions/_callbacks.py b/python/packages/azurefunctions/agent_framework_azurefunctions/_callbacks.py index 4f79b1fed5..d0683ba126 100644 --- a/python/packages/azurefunctions/agent_framework_azurefunctions/_callbacks.py +++ b/python/packages/azurefunctions/agent_framework_azurefunctions/_callbacks.py @@ -8,6 +8,7 @@ from dataclasses import dataclass from typing import Protocol +from agent_framework import AgentRunResponse, AgentRunResponseUpdate @dataclass(frozen=True) class AgentCallbackContext: From 2a3a3830eb74b16ef4377336998f9d1d9daf0c91 Mon Sep 17 00:00:00 2001 From: Brandon McConnell Date: Wed, 19 Nov 2025 02:01:41 -0500 Subject: [PATCH 4/5] chore: revert stub file change --- python/packages/core/agent_framework/ag_ui/__init__.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/packages/core/agent_framework/ag_ui/__init__.pyi b/python/packages/core/agent_framework/ag_ui/__init__.pyi index 1a8bd9588b..201e1a0256 100644 --- a/python/packages/core/agent_framework/ag_ui/__init__.pyi +++ b/python/packages/core/agent_framework/ag_ui/__init__.pyi @@ -1,6 +1,6 @@ # Copyright (c) Microsoft. All rights reserved. -from agent_framework.ag_ui import ( +from agent_framework_ag_ui import ( AgentFrameworkAgent, AGUIChatClient, AGUIEventConverter, From 08964442797b5293c09a962ca4ea9f4ad7dd2948 Mon Sep 17 00:00:00 2001 From: Brandon McConnell Date: Wed, 19 Nov 2025 02:34:00 -0500 Subject: [PATCH 5/5] chore: trigger pre-commit hook, re-add `annotations` import --- .../agents/document_writer_agent.py | 4 +- .../agents/human_in_the_loop_agent.py | 3 +- .../agents/recipe_agent.py | 6 +- .../agents/research_assistant_agent.py | 4 +- .../agents/simple_agent.py | 3 +- .../agents/task_planner_agent.py | 4 +- .../agents/task_steps_agent.py | 6 +- .../agents/ui_generator_agent.py | 4 +- .../agents/weather_agent.py | 3 +- .../server/api/backend_tool_rendering.py | 3 +- .../server/main.py | 3 +- .../ag-ui/getting_started/client_advanced.py | 1 - .../getting_started/client_with_agent.py | 1 - .../_callbacks.py | 2 + .../agent_framework_azurefunctions/_errors.py | 2 + .../agent_framework_azurefunctions/_models.py | 2 + .../models/_openai_custom.py | 2 + .../agent_framework_purview/_models.py | 2 + .../_chat_message_store.py | 2 + .../samples/demos/chatkit-integration/app.py | 2 +- .../ollama/ollama_with_openai_chat_client.py | 4 +- .../01_single_agent/function_app.py | 2 + .../function_app.py | 1 + .../function_app.py | 2 +- .../devui/weather_agent_azure/agent.py | 4 +- .../multimodal_input/azure_chat_multimodal.py | 2 + .../purview_agent/sample_purview_agent.py | 23 +++--- ...ion_from_dict_with_dependency_injection.py | 2 +- .../ai_function_with_approval_and_threads.py | 6 +- .../azure_ai_agent/01_basic_azure_ai_agent.py | 40 +++++----- ...02_azure_ai_agent_with_code_interpreter.py | 54 +++++++------- ...03_azure_ai_agent_threads_and_followups.py | 74 +++++++++---------- .../getting_started/test_agent_samples.py | 24 +++--- python/uv.lock | 30 ++++---- 34 files changed, 160 insertions(+), 167 deletions(-) diff --git a/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/document_writer_agent.py b/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/document_writer_agent.py index bea0932273..bddc51846b 100644 --- a/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/document_writer_agent.py +++ b/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/document_writer_agent.py @@ -2,9 +2,7 @@ """Example agent demonstrating predictive state updates with document writing.""" -from agent_framework import ChatAgent, ai_function -from agent_framework import ChatClientProtocol - +from agent_framework import ChatAgent, ChatClientProtocol, ai_function from agent_framework.ag_ui import AgentFrameworkAgent, DocumentWriterConfirmationStrategy diff --git a/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/human_in_the_loop_agent.py b/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/human_in_the_loop_agent.py index b01ce337b6..abbd113418 100644 --- a/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/human_in_the_loop_agent.py +++ b/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/human_in_the_loop_agent.py @@ -4,8 +4,7 @@ from enum import Enum -from agent_framework import ChatAgent, ai_function -from agent_framework import ChatClientProtocol +from agent_framework import ChatAgent, ChatClientProtocol, ai_function from pydantic import BaseModel, Field diff --git a/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/recipe_agent.py b/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/recipe_agent.py index d419b1b9b8..051937f2a9 100644 --- a/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/recipe_agent.py +++ b/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/recipe_agent.py @@ -4,11 +4,9 @@ from enum import Enum -from agent_framework import ChatAgent, ai_function -from agent_framework import ChatClientProtocol -from pydantic import BaseModel, Field - +from agent_framework import ChatAgent, ChatClientProtocol, ai_function from agent_framework.ag_ui import AgentFrameworkAgent, RecipeConfirmationStrategy +from pydantic import BaseModel, Field class SkillLevel(str, Enum): diff --git a/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/research_assistant_agent.py b/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/research_assistant_agent.py index bbfc7a124e..ad5c4f425c 100644 --- a/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/research_assistant_agent.py +++ b/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/research_assistant_agent.py @@ -4,9 +4,7 @@ import asyncio -from agent_framework import ChatAgent, ai_function -from agent_framework import ChatClientProtocol - +from agent_framework import ChatAgent, ChatClientProtocol, ai_function from agent_framework.ag_ui import AgentFrameworkAgent diff --git a/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/simple_agent.py b/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/simple_agent.py index 1c74062272..e4bffaea0d 100644 --- a/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/simple_agent.py +++ b/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/simple_agent.py @@ -2,8 +2,7 @@ """Simple agentic chat example (Feature 1: Agentic Chat).""" -from agent_framework import ChatAgent -from agent_framework import ChatClientProtocol +from agent_framework import ChatAgent, ChatClientProtocol def simple_agent(chat_client: ChatClientProtocol) -> ChatAgent: diff --git a/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/task_planner_agent.py b/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/task_planner_agent.py index 38b50ea85a..6609f06aa6 100644 --- a/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/task_planner_agent.py +++ b/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/task_planner_agent.py @@ -2,9 +2,7 @@ """Example agent demonstrating human-in-the-loop with function approvals.""" -from agent_framework import ChatAgent, ai_function -from agent_framework import ChatClientProtocol - +from agent_framework import ChatAgent, ChatClientProtocol, ai_function from agent_framework.ag_ui import AgentFrameworkAgent, TaskPlannerConfirmationStrategy diff --git a/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/task_steps_agent.py b/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/task_steps_agent.py index be41e58455..567dd348b4 100644 --- a/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/task_steps_agent.py +++ b/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/task_steps_agent.py @@ -18,11 +18,9 @@ TextMessageStartEvent, ToolCallStartEvent, ) -from agent_framework import ChatAgent, ai_function -from agent_framework import ChatClientProtocol -from pydantic import BaseModel, Field - +from agent_framework import ChatAgent, ChatClientProtocol, ai_function from agent_framework.ag_ui import AgentFrameworkAgent +from pydantic import BaseModel, Field class StepStatus(str, Enum): diff --git a/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/ui_generator_agent.py b/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/ui_generator_agent.py index dbab376e02..0a99e6f1a1 100644 --- a/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/ui_generator_agent.py +++ b/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/ui_generator_agent.py @@ -4,9 +4,7 @@ from typing import Any -from agent_framework import AIFunction, ChatAgent -from agent_framework import ChatClientProtocol - +from agent_framework import AIFunction, ChatAgent, ChatClientProtocol from agent_framework.ag_ui import AgentFrameworkAgent # Declaration-only tools (func=None) - actual rendering happens on the client side diff --git a/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/weather_agent.py b/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/weather_agent.py index b066ff166f..6edaa02616 100644 --- a/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/weather_agent.py +++ b/python/packages/ag-ui/agent_framework_ag_ui_examples/agents/weather_agent.py @@ -4,8 +4,7 @@ from typing import Any -from agent_framework import ChatAgent, ai_function -from agent_framework import ChatClientProtocol +from agent_framework import ChatAgent, ChatClientProtocol, ai_function @ai_function diff --git a/python/packages/ag-ui/agent_framework_ag_ui_examples/server/api/backend_tool_rendering.py b/python/packages/ag-ui/agent_framework_ag_ui_examples/server/api/backend_tool_rendering.py index 557a18454b..ae27a24a75 100644 --- a/python/packages/ag-ui/agent_framework_ag_ui_examples/server/api/backend_tool_rendering.py +++ b/python/packages/ag-ui/agent_framework_ag_ui_examples/server/api/backend_tool_rendering.py @@ -2,11 +2,10 @@ """Backend tool rendering endpoint.""" +from agent_framework.ag_ui import add_agent_framework_fastapi_endpoint from agent_framework.azure import AzureOpenAIChatClient from fastapi import FastAPI -from agent_framework.ag_ui import add_agent_framework_fastapi_endpoint - from ...agents.weather_agent import weather_agent diff --git a/python/packages/ag-ui/agent_framework_ag_ui_examples/server/main.py b/python/packages/ag-ui/agent_framework_ag_ui_examples/server/main.py index efb5a86527..ebfc42ea19 100644 --- a/python/packages/ag-ui/agent_framework_ag_ui_examples/server/main.py +++ b/python/packages/ag-ui/agent_framework_ag_ui_examples/server/main.py @@ -6,12 +6,11 @@ import os import uvicorn +from agent_framework.ag_ui import add_agent_framework_fastapi_endpoint from agent_framework.azure import AzureOpenAIChatClient from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware -from agent_framework.ag_ui import add_agent_framework_fastapi_endpoint - from ..agents.document_writer_agent import document_writer_agent from ..agents.human_in_the_loop_agent import human_in_the_loop_agent from ..agents.recipe_agent import recipe_agent diff --git a/python/packages/ag-ui/getting_started/client_advanced.py b/python/packages/ag-ui/getting_started/client_advanced.py index 17c8f86668..08698a80a0 100644 --- a/python/packages/ag-ui/getting_started/client_advanced.py +++ b/python/packages/ag-ui/getting_started/client_advanced.py @@ -13,7 +13,6 @@ import os from agent_framework import ai_function - from agent_framework.ag_ui import AGUIChatClient diff --git a/python/packages/ag-ui/getting_started/client_with_agent.py b/python/packages/ag-ui/getting_started/client_with_agent.py index 445f1472c7..91b099820b 100644 --- a/python/packages/ag-ui/getting_started/client_with_agent.py +++ b/python/packages/ag-ui/getting_started/client_with_agent.py @@ -23,7 +23,6 @@ import os from agent_framework import ChatAgent, FunctionCallContent, FunctionResultContent, TextContent, ai_function - from agent_framework.ag_ui import AGUIChatClient # Enable debug logging diff --git a/python/packages/azurefunctions/agent_framework_azurefunctions/_callbacks.py b/python/packages/azurefunctions/agent_framework_azurefunctions/_callbacks.py index d0683ba126..3e38cdb6ec 100644 --- a/python/packages/azurefunctions/agent_framework_azurefunctions/_callbacks.py +++ b/python/packages/azurefunctions/agent_framework_azurefunctions/_callbacks.py @@ -8,8 +8,10 @@ from dataclasses import dataclass from typing import Protocol + from agent_framework import AgentRunResponse, AgentRunResponseUpdate + @dataclass(frozen=True) class AgentCallbackContext: """Context supplied to callback invocations.""" diff --git a/python/packages/azurefunctions/agent_framework_azurefunctions/_errors.py b/python/packages/azurefunctions/agent_framework_azurefunctions/_errors.py index 79e516c8be..f4f38d32c3 100644 --- a/python/packages/azurefunctions/agent_framework_azurefunctions/_errors.py +++ b/python/packages/azurefunctions/agent_framework_azurefunctions/_errors.py @@ -1,6 +1,8 @@ # Copyright (c) Microsoft. All rights reserved. """Custom exception types for the durable agent framework.""" + + class IncomingRequestError(ValueError): """Raised when an incoming HTTP request cannot be parsed or validated.""" diff --git a/python/packages/azurefunctions/agent_framework_azurefunctions/_models.py b/python/packages/azurefunctions/agent_framework_azurefunctions/_models.py index 1bcaeb68d0..015ca40754 100644 --- a/python/packages/azurefunctions/agent_framework_azurefunctions/_models.py +++ b/python/packages/azurefunctions/agent_framework_azurefunctions/_models.py @@ -5,6 +5,8 @@ This module defines the request and response models used by the framework. """ +from __future__ import annotations + import inspect import uuid from collections.abc import MutableMapping diff --git a/python/packages/devui/agent_framework_devui/models/_openai_custom.py b/python/packages/devui/agent_framework_devui/models/_openai_custom.py index c0c12e637e..f82ef90b72 100644 --- a/python/packages/devui/agent_framework_devui/models/_openai_custom.py +++ b/python/packages/devui/agent_framework_devui/models/_openai_custom.py @@ -6,6 +6,8 @@ to support Agent Framework specific features like workflows and traces. """ +from __future__ import annotations + from dataclasses import dataclass from typing import Any, Literal diff --git a/python/packages/purview/agent_framework_purview/_models.py b/python/packages/purview/agent_framework_purview/_models.py index e361916cbd..0ee502da1a 100644 --- a/python/packages/purview/agent_framework_purview/_models.py +++ b/python/packages/purview/agent_framework_purview/_models.py @@ -2,6 +2,8 @@ """Unified Purview model definitions and public export surface.""" +from __future__ import annotations + from collections.abc import Mapping, MutableMapping, Sequence from datetime import datetime from enum import Enum, Flag, auto diff --git a/python/packages/redis/agent_framework_redis/_chat_message_store.py b/python/packages/redis/agent_framework_redis/_chat_message_store.py index e5bb8453ff..4c83dcc86f 100644 --- a/python/packages/redis/agent_framework_redis/_chat_message_store.py +++ b/python/packages/redis/agent_framework_redis/_chat_message_store.py @@ -1,5 +1,7 @@ # Copyright (c) Microsoft. All rights reserved. +from __future__ import annotations + from collections.abc import Sequence from typing import Any from uuid import uuid4 diff --git a/python/samples/demos/chatkit-integration/app.py b/python/samples/demos/chatkit-integration/app.py index 61f8ffd976..a83ddf0451 100644 --- a/python/samples/demos/chatkit-integration/app.py +++ b/python/samples/demos/chatkit-integration/app.py @@ -250,7 +250,7 @@ async def _update_thread_title( context: The context dictionary. """ logger.info(f"Attempting to update thread title for thread: {thread.id}") - + if not thread_items: logger.debug("No thread items available for title generation") return diff --git a/python/samples/getting_started/agents/ollama/ollama_with_openai_chat_client.py b/python/samples/getting_started/agents/ollama/ollama_with_openai_chat_client.py index ae222091ac..41d1a134ad 100644 --- a/python/samples/getting_started/agents/ollama/ollama_with_openai_chat_client.py +++ b/python/samples/getting_started/agents/ollama/ollama_with_openai_chat_client.py @@ -33,7 +33,7 @@ async def non_streaming_example() -> None: print("=== Non-streaming Response Example ===") agent = OpenAIChatClient( - api_key="ollama", # Just a placeholder, Ollama doesn't require API key + api_key="ollama", # Just a placeholder, Ollama doesn't require API key base_url=os.getenv("OLLAMA_ENDPOINT"), model_id=os.getenv("OLLAMA_MODEL"), ).create_agent( @@ -53,7 +53,7 @@ async def streaming_example() -> None: print("=== Streaming Response Example ===") agent = OpenAIChatClient( - api_key="ollama", # Just a placeholder, Ollama doesn't require API key + api_key="ollama", # Just a placeholder, Ollama doesn't require API key base_url=os.getenv("OLLAMA_ENDPOINT"), model_id=os.getenv("OLLAMA_MODEL"), ).create_agent( diff --git a/python/samples/getting_started/azure_functions/01_single_agent/function_app.py b/python/samples/getting_started/azure_functions/01_single_agent/function_app.py index 1fafdfbddc..9225fbd301 100644 --- a/python/samples/getting_started/azure_functions/01_single_agent/function_app.py +++ b/python/samples/getting_started/azure_functions/01_single_agent/function_app.py @@ -10,6 +10,8 @@ from agent_framework.azure import AgentFunctionApp, AzureOpenAIChatClient from azure.identity import AzureCliCredential + + # 1. Instantiate the agent with the chosen deployment and instructions. def _create_agent() -> Any: """Create the Joker agent.""" diff --git a/python/samples/getting_started/azure_functions/06_multi_agent_orchestration_conditionals/function_app.py b/python/samples/getting_started/azure_functions/06_multi_agent_orchestration_conditionals/function_app.py index 84d114b3b5..d32884014f 100644 --- a/python/samples/getting_started/azure_functions/06_multi_agent_orchestration_conditionals/function_app.py +++ b/python/samples/getting_started/azure_functions/06_multi_agent_orchestration_conditionals/function_app.py @@ -40,6 +40,7 @@ class EmailPayload(BaseModel): email_id: str email_content: str + # 2. Instantiate both agents so they can be registered with AgentFunctionApp. def _create_agents() -> list[Any]: chat_client = AzureOpenAIChatClient(credential=AzureCliCredential()) diff --git a/python/samples/getting_started/azure_functions/07_single_agent_orchestration_hitl/function_app.py b/python/samples/getting_started/azure_functions/07_single_agent_orchestration_hitl/function_app.py index 7257ff7831..69b2e3fae9 100644 --- a/python/samples/getting_started/azure_functions/07_single_agent_orchestration_hitl/function_app.py +++ b/python/samples/getting_started/azure_functions/07_single_agent_orchestration_hitl/function_app.py @@ -275,7 +275,7 @@ async def get_orchestration_status( show_history_output=False, show_input=True, ) - + # Check if status is None or if the instance doesn't exist (runtime_status is None) if status is None or getattr(status, "runtime_status", None) is None: return func.HttpResponse( diff --git a/python/samples/getting_started/devui/weather_agent_azure/agent.py b/python/samples/getting_started/devui/weather_agent_azure/agent.py index 40310cb640..4616b4971a 100644 --- a/python/samples/getting_started/devui/weather_agent_azure/agent.py +++ b/python/samples/getting_started/devui/weather_agent_azure/agent.py @@ -15,9 +15,9 @@ FunctionInvocationContext, Role, TextContent, + ai_function, chat_middleware, function_middleware, - ai_function ) from agent_framework.azure import AzureOpenAIChatClient from agent_framework_devui import register_cleanup @@ -122,6 +122,7 @@ def get_forecast( return f"Weather forecast for {location}:\n" + "\n".join(forecast) + @ai_function(approval_mode="always_require") def send_email( recipient: Annotated[str, "The email address of the recipient."], @@ -131,6 +132,7 @@ def send_email( """Simulate sending an email.""" return f"Email sent to {recipient} with subject '{subject}'." + # Agent instance following Agent Framework conventions agent = ChatAgent( name="AzureWeatherAgent", diff --git a/python/samples/getting_started/multimodal_input/azure_chat_multimodal.py b/python/samples/getting_started/multimodal_input/azure_chat_multimodal.py index e6c0ffcb87..fb80d65ad1 100644 --- a/python/samples/getting_started/multimodal_input/azure_chat_multimodal.py +++ b/python/samples/getting_started/multimodal_input/azure_chat_multimodal.py @@ -13,6 +13,7 @@ def create_sample_image() -> str: png_data = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg==" return f"data:image/png;base64,{png_data}" + async def test_image() -> None: """Test image analysis with Azure OpenAI.""" # For authentication, run `az login` command in terminal or replace AzureCliCredential with preferred @@ -37,5 +38,6 @@ async def main() -> None: print("Testing image analysis (supported by Chat Completions API)") await test_image() + if __name__ == "__main__": asyncio.run(main()) diff --git a/python/samples/getting_started/purview_agent/sample_purview_agent.py b/python/samples/getting_started/purview_agent/sample_purview_agent.py index 041fe627a3..b9518edf08 100644 --- a/python/samples/getting_started/purview_agent/sample_purview_agent.py +++ b/python/samples/getting_started/purview_agent/sample_purview_agent.py @@ -27,18 +27,17 @@ from agent_framework import AgentRunResponse, ChatAgent, ChatMessage, Role from agent_framework.azure import AzureOpenAIChatClient +from agent_framework.microsoft import ( + PurviewChatPolicyMiddleware, + PurviewPolicyMiddleware, + PurviewSettings, +) from azure.identity import ( AzureCliCredential, CertificateCredential, InteractiveBrowserCredential, ) -from agent_framework.microsoft import ( - PurviewPolicyMiddleware, - PurviewChatPolicyMiddleware, - PurviewSettings, -) - JOKER_NAME = "Joker" JOKER_INSTRUCTIONS = "You are good at telling jokes. Keep responses concise." @@ -95,7 +94,6 @@ async def remove(self, key: str) -> None: print(f"[CustomCache] Removed key: {key[:50]}...") - def _get_env(name: str, *, required: bool = True, default: str | None = None) -> str: val = os.environ.get(name, default) if required and not val: @@ -175,7 +173,7 @@ async def run_with_chat_middleware() -> None: deployment = os.environ.get("AZURE_OPENAI_DEPLOYMENT_NAME", default="gpt-4o-mini") user_id = os.environ.get("PURVIEW_DEFAULT_USER_ID") - + chat_client = AzureOpenAIChatClient( deployment_name=deployment, endpoint=endpoint, @@ -215,6 +213,7 @@ async def run_with_chat_middleware() -> None: ) print("Second response (chat middleware):\n", second) + async def run_with_custom_cache_provider() -> None: """Demonstrate implementing and using a custom cache provider.""" endpoint = os.environ.get("AZURE_OPENAI_ENDPOINT") @@ -245,7 +244,7 @@ async def run_with_custom_cache_provider() -> None: print("-- Custom Cache Provider Path --") print("Using SimpleDictCacheProvider") - + first: AgentRunResponse = await agent.run( ChatMessage(role=Role.USER, text="Tell me a joke about a programmer.", additional_properties={"user_id": user_id}) ) @@ -255,7 +254,7 @@ async def run_with_custom_cache_provider() -> None: ChatMessage(role=Role.USER, text="That's hilarious! One more?", additional_properties={"user_id": user_id}) ) print("Second response (custom provider):\n", second) - + """Demonstrate using the default built-in cache.""" endpoint = os.environ.get("AZURE_OPENAI_ENDPOINT") if not endpoint: @@ -285,7 +284,7 @@ async def run_with_custom_cache_provider() -> None: print("-- Default Cache Path --") print("Using default InMemoryCacheProvider with settings-based configuration") - + first: AgentRunResponse = await agent.run( ChatMessage(role=Role.USER, text="Tell me a joke about AI.", additional_properties={"user_id": user_id}) ) @@ -299,7 +298,7 @@ async def run_with_custom_cache_provider() -> None: async def main() -> None: print("== Purview Agent Sample (Middleware with Automatic Caching) ==") - + try: await run_with_agent_middleware() except Exception as ex: # pragma: no cover - demo resilience diff --git a/python/samples/getting_started/tools/ai_function_from_dict_with_dependency_injection.py b/python/samples/getting_started/tools/ai_function_from_dict_with_dependency_injection.py index bff59f31d2..502f9e3ae3 100644 --- a/python/samples/getting_started/tools/ai_function_from_dict_with_dependency_injection.py +++ b/python/samples/getting_started/tools/ai_function_from_dict_with_dependency_injection.py @@ -50,7 +50,7 @@ def func(a, b) -> int: # Create the AIFunction tool using dependency injection # The 'definition' dictionary contains the serialized tool configuration, # while the actual function implementation is provided via dependencies. - # + # # Dependency structure: {"ai_function": {"name:add_numbers": {"func": func}}} # - "ai_function": matches the tool type identifier # - "name:add_numbers": instance-specific injection targeting tools with name="add_numbers" diff --git a/python/samples/getting_started/tools/ai_function_with_approval_and_threads.py b/python/samples/getting_started/tools/ai_function_with_approval_and_threads.py index 53e7f0c786..2da16a2101 100644 --- a/python/samples/getting_started/tools/ai_function_with_approval_and_threads.py +++ b/python/samples/getting_started/tools/ai_function_with_approval_and_threads.py @@ -45,7 +45,7 @@ async def approval_example() -> None: # Check for approval requests if result.user_input_requests: for request in result.user_input_requests: - print(f"\nApproval needed:") + print("\nApproval needed:") print(f" Function: {request.function_call.name}") print(f" Arguments: {request.function_call.arguments}") @@ -79,12 +79,12 @@ async def rejection_example() -> None: if result.user_input_requests: for request in result.user_input_requests: - print(f"\nApproval needed:") + print("\nApproval needed:") print(f" Function: {request.function_call.name}") print(f" Arguments: {request.function_call.arguments}") # User rejects - print(f" Decision: Rejected") + print(" Decision: Rejected") # Send rejection response rejection_response = request.create_response(approved=False) diff --git a/python/samples/semantic-kernel-migration/azure_ai_agent/01_basic_azure_ai_agent.py b/python/samples/semantic-kernel-migration/azure_ai_agent/01_basic_azure_ai_agent.py index d08a4ce5f0..c9b1fb50ee 100644 --- a/python/samples/semantic-kernel-migration/azure_ai_agent/01_basic_azure_ai_agent.py +++ b/python/samples/semantic-kernel-migration/azure_ai_agent/01_basic_azure_ai_agent.py @@ -13,32 +13,30 @@ async def run_semantic_kernel() -> None: from azure.identity.aio import AzureCliCredential from semantic_kernel.agents import AzureAIAgent, AzureAIAgentSettings - async with AzureCliCredential() as credential: - async with AzureAIAgent.create_client(credential=credential) as client: - settings = AzureAIAgentSettings() # Reads env vars for region/deployment. - # SK builds the remote agent definition then wraps it with AzureAIAgent. - definition = await client.agents.create_agent( - model=settings.model_deployment_name, - name="Support", - instructions="Answer customer questions in one paragraph.", - ) - agent = AzureAIAgent(client=client, definition=definition) - response = await agent.get_response("How do I upgrade my plan?") - print("[SK]", response.message.content) + async with AzureCliCredential() as credential, AzureAIAgent.create_client(credential=credential) as client: + settings = AzureAIAgentSettings() # Reads env vars for region/deployment. + # SK builds the remote agent definition then wraps it with AzureAIAgent. + definition = await client.agents.create_agent( + model=settings.model_deployment_name, + name="Support", + instructions="Answer customer questions in one paragraph.", + ) + agent = AzureAIAgent(client=client, definition=definition) + response = await agent.get_response("How do I upgrade my plan?") + print("[SK]", response.message.content) async def run_agent_framework() -> None: - from azure.identity.aio import AzureCliCredential from agent_framework.azure import AzureAIAgentClient + from azure.identity.aio import AzureCliCredential - async with AzureCliCredential() as credential: - async with AzureAIAgentClient(async_credential=credential).create_agent( - name="Support", - instructions="Answer customer questions in one paragraph.", - ) as agent: - # AF client returns an asynchronous context manager for remote agents. - reply = await agent.run("How do I upgrade my plan?") - print("[AF]", reply.text) + async with AzureCliCredential() as credential, AzureAIAgentClient(async_credential=credential).create_agent( + name="Support", + instructions="Answer customer questions in one paragraph.", + ) as agent: + # AF client returns an asynchronous context manager for remote agents. + reply = await agent.run("How do I upgrade my plan?") + print("[AF]", reply.text) async def main() -> None: diff --git a/python/samples/semantic-kernel-migration/azure_ai_agent/02_azure_ai_agent_with_code_interpreter.py b/python/samples/semantic-kernel-migration/azure_ai_agent/02_azure_ai_agent_with_code_interpreter.py index cf4a4d8ed0..76cbb3e47b 100644 --- a/python/samples/semantic-kernel-migration/azure_ai_agent/02_azure_ai_agent_with_code_interpreter.py +++ b/python/samples/semantic-kernel-migration/azure_ai_agent/02_azure_ai_agent_with_code_interpreter.py @@ -13,39 +13,37 @@ async def run_semantic_kernel() -> None: from azure.identity.aio import AzureCliCredential from semantic_kernel.agents import AzureAIAgent, AzureAIAgentSettings - async with AzureCliCredential() as credential: - async with AzureAIAgent.create_client(credential=credential) as client: - settings = AzureAIAgentSettings() - # Register the hosted code interpreter tool with the remote agent. - definition = await client.agents.create_agent( - model=settings.model_deployment_name, - name="Analyst", - instructions="Use the code interpreter for numeric work.", - tools=[{"type": "code_interpreter"}], - ) - agent = AzureAIAgent(client=client, definition=definition) - response = await agent.get_response( - "Use Python to compute 42 ** 2 and explain the result.", - ) - print("[SK]", response.message.content) + async with AzureCliCredential() as credential, AzureAIAgent.create_client(credential=credential) as client: + settings = AzureAIAgentSettings() + # Register the hosted code interpreter tool with the remote agent. + definition = await client.agents.create_agent( + model=settings.model_deployment_name, + name="Analyst", + instructions="Use the code interpreter for numeric work.", + tools=[{"type": "code_interpreter"}], + ) + agent = AzureAIAgent(client=client, definition=definition) + response = await agent.get_response( + "Use Python to compute 42 ** 2 and explain the result.", + ) + print("[SK]", response.message.content) async def run_agent_framework() -> None: - from azure.identity.aio import AzureCliCredential from agent_framework.azure import AzureAIAgentClient, HostedCodeInterpreterTool + from azure.identity.aio import AzureCliCredential - async with AzureCliCredential() as credential: - async with AzureAIAgentClient(async_credential=credential).create_agent( - name="Analyst", - instructions="Use the code interpreter for numeric work.", - tools=[HostedCodeInterpreterTool()], - ) as agent: - # HostedCodeInterpreterTool mirrors the built-in Azure AI capability. - reply = await agent.run( - "Use Python to compute 42 ** 2 and explain the result.", - tool_choice="auto", - ) - print("[AF]", reply.text) + async with AzureCliCredential() as credential, AzureAIAgentClient(async_credential=credential).create_agent( + name="Analyst", + instructions="Use the code interpreter for numeric work.", + tools=[HostedCodeInterpreterTool()], + ) as agent: + # HostedCodeInterpreterTool mirrors the built-in Azure AI capability. + reply = await agent.run( + "Use Python to compute 42 ** 2 and explain the result.", + tool_choice="auto", + ) + print("[AF]", reply.text) async def main() -> None: diff --git a/python/samples/semantic-kernel-migration/azure_ai_agent/03_azure_ai_agent_threads_and_followups.py b/python/samples/semantic-kernel-migration/azure_ai_agent/03_azure_ai_agent_threads_and_followups.py index 1b63324e34..d96215d319 100644 --- a/python/samples/semantic-kernel-migration/azure_ai_agent/03_azure_ai_agent_threads_and_followups.py +++ b/python/samples/semantic-kernel-migration/azure_ai_agent/03_azure_ai_agent_threads_and_followups.py @@ -8,53 +8,51 @@ async def run_semantic_kernel() -> None: from azure.identity.aio import AzureCliCredential from semantic_kernel.agents import AzureAIAgent, AzureAIAgentSettings, AzureAIAgentThread - async with AzureCliCredential() as credential: - async with AzureAIAgent.create_client(credential=credential) as client: - settings = AzureAIAgentSettings() - definition = await client.agents.create_agent( - model=settings.model_deployment_name, - name="Planner", - instructions="Track follow-up questions within the same thread.", - ) - agent = AzureAIAgent(client=client, definition=definition) + async with AzureCliCredential() as credential, AzureAIAgent.create_client(credential=credential) as client: + settings = AzureAIAgentSettings() + definition = await client.agents.create_agent( + model=settings.model_deployment_name, + name="Planner", + instructions="Track follow-up questions within the same thread.", + ) + agent = AzureAIAgent(client=client, definition=definition) - thread: AzureAIAgentThread | None = None - # SK returns the updated AzureAIAgentThread on each response. - first = await agent.get_response("Outline the onboarding checklist.", thread=thread) - thread = first.thread - print("[SK][turn1]", first.message.content) + thread: AzureAIAgentThread | None = None + # SK returns the updated AzureAIAgentThread on each response. + first = await agent.get_response("Outline the onboarding checklist.", thread=thread) + thread = first.thread + print("[SK][turn1]", first.message.content) - second = await agent.get_response( - "Highlight the items that require legal review.", - thread=thread, - ) - print("[SK][turn2]", second.message.content) - if thread is not None: - print("[SK][thread-id]", thread.id) + second = await agent.get_response( + "Highlight the items that require legal review.", + thread=thread, + ) + print("[SK][turn2]", second.message.content) + if thread is not None: + print("[SK][thread-id]", thread.id) async def run_agent_framework() -> None: - from azure.identity.aio import AzureCliCredential from agent_framework.azure import AzureAIAgentClient + from azure.identity.aio import AzureCliCredential - async with AzureCliCredential() as credential: - async with AzureAIAgentClient(async_credential=credential).create_agent( - name="Planner", - instructions="Track follow-up questions within the same thread.", - ) as agent: - thread = agent.get_new_thread() - # AF threads are explicit and can be serialized for external storage. - first = await agent.run("Outline the onboarding checklist.", thread=thread) - print("[AF][turn1]", first.text) + async with AzureCliCredential() as credential, AzureAIAgentClient(async_credential=credential).create_agent( + name="Planner", + instructions="Track follow-up questions within the same thread.", + ) as agent: + thread = agent.get_new_thread() + # AF threads are explicit and can be serialized for external storage. + first = await agent.run("Outline the onboarding checklist.", thread=thread) + print("[AF][turn1]", first.text) - second = await agent.run( - "Highlight the items that require legal review.", - thread=thread, - ) - print("[AF][turn2]", second.text) + second = await agent.run( + "Highlight the items that require legal review.", + thread=thread, + ) + print("[AF][turn2]", second.text) - serialized = await thread.serialize() - print("[AF][thread-json]", serialized) + serialized = await thread.serialize() + print("[AF][thread-json]", serialized) async def main() -> None: diff --git a/python/tests/samples/getting_started/test_agent_samples.py b/python/tests/samples/getting_started/test_agent_samples.py index 710a5604fc..e1a8595193 100644 --- a/python/tests/samples/getting_started/test_agent_samples.py +++ b/python/tests/samples/getting_started/test_agent_samples.py @@ -7,6 +7,18 @@ import pytest from pytest import MonkeyPatch, mark, param +from samples.getting_started.agents.azure_ai.azure_ai_with_function_tools import ( + mixed_tools_example as azure_ai_with_function_tools_mixed, +) +from samples.getting_started.agents.azure_ai.azure_ai_with_function_tools import ( + tools_on_agent_level as azure_ai_with_function_tools_agent, +) +from samples.getting_started.agents.azure_ai.azure_ai_with_function_tools import ( + tools_on_run_level as azure_ai_with_function_tools_run, +) +from samples.getting_started.agents.azure_ai.azure_ai_with_local_mcp import ( + main as azure_ai_with_local_mcp, +) from samples.getting_started.agents.azure_ai.azure_ai_basic import ( main as azure_ai_basic, @@ -20,18 +32,6 @@ from samples.getting_started.agents.azure_ai.azure_ai_with_explicit_settings import ( main as azure_ai_with_explicit_settings, ) -from samples.getting_started.agents.azure_ai.azure_ai_with_function_tools import ( - mixed_tools_example as azure_ai_with_function_tools_mixed, -) -from samples.getting_started.agents.azure_ai.azure_ai_with_function_tools import ( - tools_on_agent_level as azure_ai_with_function_tools_agent, -) -from samples.getting_started.agents.azure_ai.azure_ai_with_function_tools import ( - tools_on_run_level as azure_ai_with_function_tools_run, -) -from samples.getting_started.agents.azure_ai.azure_ai_with_local_mcp import ( - main as azure_ai_with_local_mcp, -) from samples.getting_started.agents.azure_ai.azure_ai_with_thread import ( main as azure_ai_with_thread, ) diff --git a/python/uv.lock b/python/uv.lock index 0e7cce14db..72aec2025f 100644 --- a/python/uv.lock +++ b/python/uv.lock @@ -3124,31 +3124,31 @@ wheels = [ [[package]] name = "microsoft-agents-activity" -version = "0.5.3" +version = "0.6.0" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "pydantic", marker = "sys_platform == 'darwin' or sys_platform == 'linux' or sys_platform == 'win32'" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/7e/51/2698980f425cda122f5b755a957c3c2db604c0b9a787c6add5aa4649c237/microsoft_agents_activity-0.5.3.tar.gz", hash = "sha256:d80b055591df561df8cebda9e1712012352581a396b36459133a951982b3a760", size = 55892, upload-time = "2025-10-31T15:40:49.332Z" } +sdist = { url = "https://files.pythonhosted.org/packages/cb/c5/ec0b5786257b88a21245d9485e864088cbdc60442e21b637cc1433f6061b/microsoft_agents_activity-0.6.0.tar.gz", hash = "sha256:9b23a44def700d1d18670e28e2e7e66e8679dfb902dadcd94902d5591cda65a4", size = 57481, upload-time = "2025-11-18T18:12:33.351Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/75/3d/9618243e7b6f1f6295642c4e2dfca65b3a37794efbe1bdec15f0a93827d9/microsoft_agents_activity-0.5.3-py3-none-any.whl", hash = "sha256:5ae2447ac47c32f03c614694f520817cd225c9c502ec08b90d448311fb5bf3b4", size = 127861, upload-time = "2025-10-31T15:40:57.628Z" }, + { url = "https://files.pythonhosted.org/packages/fe/6b/e07cbd310881eda75def2d13220f27648f8c2632b16244536d33069e6bd5/microsoft_agents_activity-0.6.0-py3-none-any.whl", hash = "sha256:bfcd0f55ac332320ca927f829f6fb200acff1bd61fb6aba9945906130fec7d06", size = 131093, upload-time = "2025-11-18T18:12:41.796Z" }, ] [[package]] name = "microsoft-agents-copilotstudio-client" -version = "0.5.3" +version = "0.6.0" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "microsoft-agents-hosting-core", marker = "sys_platform == 'darwin' or sys_platform == 'linux' or sys_platform == 'win32'" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/7e/22/109164fb585c4baee40d2372c5d76254ec4a28219908f11cd27ac92aa6c1/microsoft_agents_copilotstudio_client-0.5.3.tar.gz", hash = "sha256:a57ea6b3cb47dbb5ad22e59c986208ace6479e35da3f644e6346f4dfd85db57c", size = 11161, upload-time = "2025-10-31T15:40:51.444Z" } +sdist = { url = "https://files.pythonhosted.org/packages/88/23/67833eac41963a7a0110b8fe3b9329c65388ccf50f6b1f694e92e0cb3918/microsoft_agents_copilotstudio_client-0.6.0.tar.gz", hash = "sha256:2964e164cc0175614aa356aaab01fda48153961304f11cdaef2a45710d922805", size = 11756, upload-time = "2025-11-18T18:12:35.842Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/c4/65/984e139c85657ff0c8df0ed98a167c8b9434f4fd4f32862b4a6490b8c714/microsoft_agents_copilotstudio_client-0.5.3-py3-none-any.whl", hash = "sha256:6a36fce5c8c1a2df6f5142e35b12c69be80959ecff6d60cc309661018c40f00a", size = 11091, upload-time = "2025-10-31T15:40:59.718Z" }, + { url = "https://files.pythonhosted.org/packages/56/1f/75e8618bed71da736104d5d4c41137fdb28672660e0257d59ea6d6fd4029/microsoft_agents_copilotstudio_client-0.6.0-py3-none-any.whl", hash = "sha256:733affebee8b4e7d204e66ff91e3162d4f498f2944b45a19eec0a8234eea67b5", size = 12340, upload-time = "2025-11-18T18:12:43.572Z" }, ] [[package]] name = "microsoft-agents-hosting-core" -version = "0.5.3" +version = "0.6.0" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "azure-core", marker = "sys_platform == 'darwin' or sys_platform == 'linux' or sys_platform == 'win32'" }, @@ -3157,9 +3157,9 @@ dependencies = [ { name = "pyjwt", marker = "sys_platform == 'darwin' or sys_platform == 'linux' or sys_platform == 'win32'" }, { name = "python-dotenv", marker = "sys_platform == 'darwin' or sys_platform == 'linux' or sys_platform == 'win32'" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/b1/98/7755c07b2ae5faf3e4dc14b17e44680a600c8b840b3003fb326d5720dea1/microsoft_agents_hosting_core-0.5.3.tar.gz", hash = "sha256:b113d4ea5c9e555bbf61037bb2a1a7a3ce7e5e4a7a0f681a3bd4719ba72ff821", size = 81672, upload-time = "2025-10-31T15:40:53.557Z" } +sdist = { url = "https://files.pythonhosted.org/packages/ea/02/893e4a2f789b3c91550e6aefd53a9b88d3bea8f4f15ae1fee141691fb5fb/microsoft_agents_hosting_core-0.6.0.tar.gz", hash = "sha256:0331573dbc2ae8f4339658ed600676c3a4a76ade403b4adc49c4d38afd3fdc36", size = 82802, upload-time = "2025-11-18T18:12:37.518Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/95/57/c9e98475971c9da9cc9ff88195bbfcfae90dba511ebe14610be79f23ab3f/microsoft_agents_hosting_core-0.5.3-py3-none-any.whl", hash = "sha256:8c228a8814dcf1a86dd60e4c7574a2e86078962695fabd693a118097e703e982", size = 120668, upload-time = "2025-10-31T15:41:01.691Z" }, + { url = "https://files.pythonhosted.org/packages/8b/46/01d12043fc6e31c3cd894ef6d17d4586ea2a0a918c83842e2db5b8728f1c/microsoft_agents_hosting_core-0.6.0-py3-none-any.whl", hash = "sha256:9f07df7835a4c0f527b66e64e57dbfcbd9ec7c6140cc829f6e99f061b4084783", size = 122494, upload-time = "2025-11-18T18:12:45.639Z" }, ] [[package]] @@ -3642,7 +3642,7 @@ wheels = [ [[package]] name = "openai-agents" -version = "0.5.1" +version = "0.6.0" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "griffe", marker = "sys_platform == 'darwin' or sys_platform == 'linux' or sys_platform == 'win32'" }, @@ -3653,14 +3653,14 @@ dependencies = [ { name = "types-requests", marker = "sys_platform == 'darwin' or sys_platform == 'linux' or sys_platform == 'win32'" }, { name = "typing-extensions", marker = "sys_platform == 'darwin' or sys_platform == 'linux' or sys_platform == 'win32'" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/b8/1f/322595f9a7ffd48afe2449bb92090eb893ba6ae4475e3ee549f64566a3a1/openai_agents-0.5.1.tar.gz", hash = "sha256:e193cd3a1b0d4f9a3f3fa9c4011c0b1f8876fa5f38bde4ae41d6a834a5791124", size = 1990900, upload-time = "2025-11-13T17:59:36.173Z" } +sdist = { url = "https://files.pythonhosted.org/packages/f8/83/5004ab65dc5fdcf96c53b5a5f18de774897c70ee661320e366c64768f6ca/openai_agents-0.6.0.tar.gz", hash = "sha256:355d365a93c6d2457f2226ff7e9082db439d7776531d8a8d7635e45c59e3cc9a", size = 2009045, upload-time = "2025-11-18T19:06:55.988Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/10/ca/352a7167ac040f9e7d6765081f4021811914724303d1417525d50942e15e/openai_agents-0.5.1-py3-none-any.whl", hash = "sha256:7077c47d8e4230d788a18922df7cd69f13c3328a57744156195da4921c08c835", size = 231786, upload-time = "2025-11-13T17:59:32.691Z" }, + { url = "https://files.pythonhosted.org/packages/a1/f4/6418293ef0a1f9e57c261885a86ea2815d5ba385f1b4af5fa48608c1a0c2/openai_agents-0.6.0-py3-none-any.whl", hash = "sha256:a9928e5bea6938141de679ed7f6db9e9595aae05cd9de11b67ed3893a2c1ee07", size = 237412, upload-time = "2025-11-18T19:06:54.162Z" }, ] [[package]] name = "openai-chatkit" -version = "1.2.0" +version = "1.3.0" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "openai", marker = "sys_platform == 'darwin' or sys_platform == 'linux' or sys_platform == 'win32'" }, @@ -3668,9 +3668,9 @@ dependencies = [ { name = "pydantic", marker = "sys_platform == 'darwin' or sys_platform == 'linux' or sys_platform == 'win32'" }, { name = "uvicorn", marker = "sys_platform == 'darwin' or sys_platform == 'linux' or sys_platform == 'win32'" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/11/e1/c247260aa9b319109e88b9aef69d6497d881b1d8e1b464c502a3173f0482/openai_chatkit-1.2.0.tar.gz", hash = "sha256:4aa8b3ab5f525fd6e4b9e88d6bb6fab7d5a12a5e51e22d0753fa8835f79ce3c5", size = 50160, upload-time = "2025-11-13T20:46:05.775Z" } +sdist = { url = "https://files.pythonhosted.org/packages/2c/d9/4ceafc66c2cb6da308fdb6277d2d8cd52b5414cb9d45295e379ec7d7f1db/openai_chatkit-1.3.0.tar.gz", hash = "sha256:b09349f149dcc213edc1496a1b8c634689e1c38e17ad5bdba4a4f7962ac6f02e", size = 50130, upload-time = "2025-11-18T18:18:32.663Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/f4/b8/7f8c54db201dc73867ab83cd5781035845cb474dfe8e9760be69c19c337d/openai_chatkit-1.2.0-py3-none-any.whl", hash = "sha256:4a8b40a160cf7c32b48dd813e3977567a124bb851ba27c01098a7cb249b453ec", size = 35577, upload-time = "2025-11-13T20:46:04.17Z" }, + { url = "https://files.pythonhosted.org/packages/40/ea/c69e12cd2fe38841b39f5157db5851d1a3ac2a33d309d73e98bb8d7cd86b/openai_chatkit-1.3.0-py3-none-any.whl", hash = "sha256:a0c017dfa2ea4447cd2cc818215d16718fa9fa853a972bead2fa8102d4e85076", size = 35576, upload-time = "2025-11-18T18:18:31.285Z" }, ] [[package]]