Python: [BREAKING]: removed display_name, renamed context_providers, middleware and AggregateContextProvider (#3139)

* removed display_name, renamed context_providers, middleware and AggregateContextProvider

* fixes

* fixed test

* testfix

* removed mistakenly put back test

* updated new test

* rename middlewares to middleware

* middleware fixes
This commit is contained in:
Eduard van Valkenburg
2026-01-13 03:24:07 +01:00
committed by GitHub
Unverified
parent ef44fb4960
commit 203fb7b1c4
80 changed files with 596 additions and 838 deletions
-1
View File
@@ -1 +0,0 @@
# Copyright (c) Microsoft. All rights reserved.
@@ -9,13 +9,13 @@ from typing import Any
from agent_framework import (
ChatMessage,
ChatOptions,
ChatResponse,
ChatResponseUpdate,
FunctionCallContent,
Role,
TextContent,
ai_function,
)
from agent_framework._types import ChatResponse
from pytest import MonkeyPatch
from agent_framework_ag_ui._client import AGUIChatClient, ServerFunctionCallContent
@@ -9,12 +9,11 @@ from pathlib import Path
from typing import Any
import pytest
from agent_framework import ChatAgent, ChatMessage, ChatOptions, TextContent
from agent_framework._types import ChatResponseUpdate
from agent_framework import ChatAgent, ChatMessage, ChatOptions, ChatResponseUpdate, TextContent
from pydantic import BaseModel
sys.path.insert(0, str(Path(__file__).parent))
from test_helpers_ag_ui import StreamingChatClientStub
from utils_test_ag_ui import StreamingChatClientStub
async def test_agent_initialization_basic():
@@ -3,8 +3,7 @@
"""Tests for document writer predictive state flow with confirm_changes."""
from ag_ui.core import EventType, StateDeltaEvent, ToolCallArgsEvent, ToolCallEndEvent, ToolCallStartEvent
from agent_framework import FunctionCallContent, FunctionResultContent, TextContent
from agent_framework._types import AgentRunResponseUpdate
from agent_framework import AgentRunResponseUpdate, FunctionCallContent, FunctionResultContent, TextContent
from agent_framework_ag_ui._events import AgentFrameworkEventBridge
+2 -3
View File
@@ -6,8 +6,7 @@ import json
import sys
from pathlib import Path
from agent_framework import ChatAgent, TextContent
from agent_framework._types import ChatResponseUpdate
from agent_framework import ChatAgent, ChatResponseUpdate, TextContent
from fastapi import FastAPI
from fastapi.testclient import TestClient
@@ -15,7 +14,7 @@ from agent_framework_ag_ui._agent import AgentFrameworkAgent
from agent_framework_ag_ui._endpoint import add_agent_framework_fastapi_endpoint
sys.path.insert(0, str(Path(__file__).parent))
from test_helpers_ag_ui import StreamingChatClientStub, stream_from_updates
from utils_test_ag_ui import StreamingChatClientStub, stream_from_updates
def build_chat_client(response_text: str = "Test response") -> StreamingChatClientStub:
@@ -2,8 +2,7 @@
"""Tests for human in the loop (function approval requests)."""
from agent_framework import FunctionApprovalRequestContent, FunctionCallContent
from agent_framework._types import AgentRunResponseUpdate
from agent_framework import AgentRunResponseUpdate, FunctionApprovalRequestContent, FunctionCallContent
from agent_framework_ag_ui._events import AgentFrameworkEventBridge
@@ -6,8 +6,7 @@ from collections.abc import AsyncGenerator
from types import SimpleNamespace
from typing import Any
from agent_framework import AgentRunResponseUpdate, TextContent, ai_function
from agent_framework._tools import FunctionInvocationConfiguration
from agent_framework import AgentRunResponseUpdate, FunctionInvocationConfiguration, TextContent, ai_function
from agent_framework_ag_ui._agent import AgentConfig
from agent_framework_ag_ui._orchestrators import DefaultOrchestrator, ExecutionContext
@@ -20,7 +20,7 @@ from agent_framework_ag_ui._agent import AgentConfig
from agent_framework_ag_ui._orchestrators import DefaultOrchestrator, HumanInTheLoopOrchestrator
sys.path.insert(0, str(Path(__file__).parent))
from test_helpers_ag_ui import StubAgent, TestExecutionContext
from utils_test_ag_ui import StubAgent, TestExecutionContext
@ai_function(approval_mode="always_require")
@@ -8,14 +8,13 @@ from typing import Any
import pytest
from ag_ui.core import StateSnapshotEvent
from agent_framework import ChatAgent, TextContent
from agent_framework._types import ChatResponseUpdate
from agent_framework import ChatAgent, ChatResponseUpdate, TextContent
from agent_framework_ag_ui._agent import AgentFrameworkAgent
from agent_framework_ag_ui._events import AgentFrameworkEventBridge
sys.path.insert(0, str(Path(__file__).parent))
from test_helpers_ag_ui import StreamingChatClientStub, stream_from_updates
from utils_test_ag_ui import StreamingChatClientStub, stream_from_updates
@pytest.fixture
@@ -8,12 +8,11 @@ from collections.abc import AsyncIterator, MutableSequence
from pathlib import Path
from typing import Any
from agent_framework import ChatAgent, ChatMessage, ChatOptions, TextContent
from agent_framework._types import ChatResponseUpdate
from agent_framework import ChatAgent, ChatMessage, ChatOptions, ChatResponseUpdate, TextContent
from pydantic import BaseModel
sys.path.insert(0, str(Path(__file__).parent))
from test_helpers_ag_ui import StreamingChatClientStub, stream_from_updates
from utils_test_ag_ui import StreamingChatClientStub, stream_from_updates
class RecipeOutput(BaseModel):
@@ -11,12 +11,13 @@ from agent_framework import (
AgentRunResponse,
AgentRunResponseUpdate,
AgentThread,
BaseChatClient,
ChatMessage,
ChatOptions,
ChatResponse,
ChatResponseUpdate,
TextContent,
)
from agent_framework._clients import BaseChatClient
from agent_framework._types import ChatResponse, ChatResponseUpdate
from agent_framework_ag_ui._message_adapters import _deduplicate_messages, _sanitize_tool_history
from agent_framework_ag_ui._orchestrators import ExecutionContext
@@ -79,31 +80,15 @@ class StubAgent(AgentProtocol):
chat_options: Any | None = None,
chat_client: Any | None = None,
) -> None:
self._id = agent_id
self._name = agent_name
self._description = "stub agent"
self.id = agent_id
self.name = agent_name
self.description = "stub agent"
self.updates = updates or [AgentRunResponseUpdate(contents=[TextContent(text="response")], role="assistant")]
self.chat_options = chat_options or SimpleNamespace(tools=None, response_format=None)
self.chat_client = chat_client or SimpleNamespace(function_invocation_configuration=None)
self.messages_received: list[Any] = []
self.tools_received: list[Any] | None = None
@property
def id(self) -> str:
return self._id
@property
def name(self) -> str | None:
return self._name
@property
def display_name(self) -> str:
return self._name or self._id
@property
def description(self) -> str | None:
return self._description
async def run(
self,
messages: str | ChatMessage | list[str] | list[ChatMessage] | None = None,