Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
46b4e82
Refactor code structure for improved readability and maintainability
Dhanushree-Microsoft May 21, 2026
4e0a59a
refactor: remove ImportError handling for agent_framework imports
Dhanushree-Microsoft May 21, 2026
b6001e8
refactor: update Message stubs for consistency and clarity in tests
Dhanushree-Microsoft May 21, 2026
64c78f4
refactor: simplify client import handling in AgentFrameworkHelper
Dhanushree-Microsoft May 21, 2026
7e514c5
refactor: update exception handling in client creation tests to use I…
Dhanushree-Microsoft May 21, 2026
aab94b9
refactor: normalize executor_id handling in MigrationProcessor for im…
Dhanushree-Microsoft May 21, 2026
913bffa
refactor: streamline WorkflowEvent handling in GroupChatOrchestrator …
Dhanushree-Microsoft May 21, 2026
f64adcd
refactor: enhance AzureOpenAIResponseClientWithRetry for legacy param…
Dhanushree-Microsoft May 21, 2026
8371c22
fix: check credential value instead of key presence
Dhanushree-Microsoft Jun 4, 2026
1033890
fix: check credential value instead of key presence
Dhanushree-Microsoft Jun 4, 2026
359ed58
fix: resolve merge conflicts with dev branch
Jun 4, 2026
d86c63e
fix: address review comments - type annotations, test cleanup, and co…
Jun 4, 2026
d60d5b1
fix: use contents= for Message construction in agent-framework 1.3.0
Jun 4, 2026
cba537e
fix: add setup_module to prevent test ordering issues with Message patch
Jun 4, 2026
271fc27
fix: assert contents instead of text in input observer test
Jun 4, 2026
75b3e64
fix: set both text and contents on Message, restore copyright header
Jun 4, 2026
7c7dbe0
fix: handle agent-framework 1.3.0 Message contents across codebase
Dhanushree-Microsoft Jun 4, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion infra/vscode_web/endpoint-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
azure-ai-projects==1.0.0b12
azure-ai-projects==2.1.0
azure-identity==1.20.0
ansible-core~=2.17.0
2 changes: 1 addition & 1 deletion infra/vscode_web/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
azure-ai-projects==1.0.0b12
azure-ai-projects==2.1.0
azure-identity==1.20.0
ansible-core~=2.17.0
4 changes: 2 additions & 2 deletions src/processor/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"agent-framework==1.0.0b260107",
"agent-framework==1.3.0",
"aiohttp==3.13.5",
"art==6.5",
"azure-ai-agents==1.2.0b5",
"azure-ai-agents==1.2.0b6",
"azure-ai-inference==1.0.0b9",
"azure-ai-projects==2.1.0",
Comment thread
Dhanushree-Microsoft marked this conversation as resolved.
"azure-appconfiguration==1.8.0",
Comment thread
Dhanushree-Microsoft marked this conversation as resolved.
Expand Down
101 changes: 46 additions & 55 deletions src/processor/src/libs/agent_framework/agent_builder.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

"""Fluent builder for constructing ChatAgent instances with chainable configuration."""
"""Fluent builder for constructing Agent instances with chainable configuration."""

from collections.abc import Callable, MutableMapping, Sequence
from typing import Any, Literal

from agent_framework import (
AggregateContextProvider,
ChatAgent,
ChatClientProtocol,
ChatMessageStoreProtocol,
Agent,
AgentMiddleware,
BaseChatClient,
ChatMiddleware,
ContextProvider,
Middleware,
FunctionTool,
ToolMode,
ToolProtocol,
)
from pydantic import BaseModel

Expand All @@ -23,7 +22,7 @@


class AgentBuilder:
"""Fluent builder for creating ChatAgent instances with a chainable API.
"""Fluent builder for creating Agent instances with a chainable API.
This class provides two ways to create agents:
1. Fluent API with method chaining (recommended for readability)
Expand Down Expand Up @@ -59,7 +58,7 @@ class AgentBuilder:
)
"""

def __init__(self, chat_client: ChatClientProtocol):
def __init__(self, chat_client: BaseChatClient):
"""Initialize the builder with a chat client.
Args:
Expand All @@ -70,14 +69,15 @@ def __init__(self, chat_client: ChatClientProtocol):
self._id: str | None = None
self._name: str | None = None
self._description: str | None = None
self._chat_message_store_factory: (
Callable[[], ChatMessageStoreProtocol] | None
) = None
self._chat_message_store_factory: Callable[[], Any] | None = None
self._conversation_id: str | None = None
self._context_providers: (
ContextProvider | list[ContextProvider] | AggregateContextProvider | None
self._context_providers: ContextProvider | list[ContextProvider] | None = None
self._middleware: (
AgentMiddleware
| ChatMiddleware
| list[AgentMiddleware | ChatMiddleware]
| None
) = None
self._middleware: Middleware | list[Middleware] | None = None
self._frequency_penalty: float | None = None
self._logit_bias: dict[str | int, float] | None = None
self._max_tokens: int | None = None
Expand All @@ -93,10 +93,10 @@ def __init__(self, chat_client: ChatClientProtocol):
ToolMode | Literal["auto", "required", "none"] | dict[str, Any] | None
) = "auto"
self._tools: (
ToolProtocol
FunctionTool
| Callable[..., Any]
| MutableMapping[str, Any]
| Sequence[ToolProtocol | Callable[..., Any] | MutableMapping[str, Any]]
| Sequence[FunctionTool | Callable[..., Any] | MutableMapping[str, Any]]
| None
) = None
self._top_p: float | None = None
Expand Down Expand Up @@ -178,10 +178,10 @@ def with_max_tokens(self, max_tokens: int) -> "AgentBuilder":

def with_tools(
self,
tools: ToolProtocol
tools: FunctionTool
| Callable[..., Any]
| MutableMapping[str, Any]
| Sequence[ToolProtocol | Callable[..., Any] | MutableMapping[str, Any]],
| Sequence[FunctionTool | Callable[..., Any] | MutableMapping[str, Any]],
) -> "AgentBuilder":
"""Set the tools available to the agent.
Expand Down Expand Up @@ -210,7 +210,8 @@ def with_tool_choice(
return self

def with_middleware(
self, middleware: Middleware | list[Middleware]
self,
middleware: AgentMiddleware | ChatMiddleware | list[AgentMiddleware | ChatMiddleware],
) -> "AgentBuilder":
"""Set middleware for request/response processing.
Expand All @@ -225,9 +226,7 @@ def with_middleware(

def with_context_providers(
self,
context_providers: ContextProvider
| list[ContextProvider]
| AggregateContextProvider,
context_providers: ContextProvider | list[ContextProvider],
) -> "AgentBuilder":
"""Set context providers for additional conversation context.
Expand Down Expand Up @@ -385,7 +384,7 @@ def with_store(self, store: bool) -> "AgentBuilder":
return self

def with_message_store_factory(
self, factory: Callable[[], ChatMessageStoreProtocol]
self, factory: Callable[[], Any]
) -> "AgentBuilder":
"""Set the message store factory.
Expand Down Expand Up @@ -422,11 +421,11 @@ def with_kwargs(self, **kwargs: Any) -> "AgentBuilder":
self._kwargs.update(kwargs)
return self

def build(self) -> ChatAgent:
"""Build and return the configured ChatAgent.
def build(self) -> Agent:
"""Build and return the configured Agent.
Returns:
ChatAgent: Configured agent instance ready for use
Agent: Configured agent instance ready for use
Example:
.. code-block:: python
Expand All @@ -442,7 +441,7 @@ def build(self) -> ChatAgent:
async with agent:
response = await agent.run("Hello!")
"""
return ChatAgent(
return Agent(
chat_client=self._chat_client,
instructions=self._instructions,
id=self._id,
Expand Down Expand Up @@ -477,14 +476,10 @@ def create_agent_by_agentinfo(
agent_info: AgentInfo,
*,
id: str | None = None,
chat_message_store_factory: Callable[[], ChatMessageStoreProtocol]
| None = None,
chat_message_store_factory: Callable[[], Any] | None = None,
conversation_id: str | None = None,
context_providers: ContextProvider
| list[ContextProvider]
| AggregateContextProvider
| None = None,
middleware: Middleware | list[Middleware] | None = None,
context_providers: ContextProvider | list[ContextProvider] | None = None,
middleware: AgentMiddleware | ChatMiddleware | list[AgentMiddleware | ChatMiddleware] | None = None,
frequency_penalty: float | None = None,
logit_bias: dict[str | int, float] | None = None,
max_tokens: int | None = None,
Expand All @@ -500,20 +495,20 @@ def create_agent_by_agentinfo(
| Literal["auto", "required", "none"]
| dict[str, Any]
| None = "auto",
tools: ToolProtocol
tools: FunctionTool
| Callable[..., Any]
| MutableMapping[str, Any]
| Sequence[ToolProtocol | Callable[..., Any] | MutableMapping[str, Any]]
| Sequence[FunctionTool | Callable[..., Any] | MutableMapping[str, Any]]
| None = None,
top_p: float | None = None,
user: str | None = None,
additional_chat_options: dict[str, Any] | None = None,
**kwargs: Any,
) -> ChatAgent:
) -> Agent:
"""Create an agent using AgentInfo configuration with full parameter support.
This method creates a chat client from the service configuration and then
creates a ChatAgent with the specified parameters. Agent name, description,
creates a Agent with the specified parameters. Agent name, description,
and instructions are taken from AgentInfo but can be overridden via kwargs.
Args:
Expand Down Expand Up @@ -543,7 +538,7 @@ def create_agent_by_agentinfo(
**kwargs: Additional keyword arguments
Returns:
ChatAgent: Configured agent instance ready for use
Agent: Configured agent instance ready for use
Example:
.. code-block:: python
Expand Down Expand Up @@ -611,20 +606,16 @@ def create_agent_by_agentinfo(

@staticmethod
def create_agent(
chat_client: ChatClientProtocol,
chat_client: BaseChatClient,
instructions: str | None = None,
*,
id: str | None = None,
name: str | None = None,
description: str | None = None,
chat_message_store_factory: Callable[[], ChatMessageStoreProtocol]
| None = None,
chat_message_store_factory: Callable[[], Any] | None = None,
conversation_id: str | None = None,
context_providers: ContextProvider
| list[ContextProvider]
| AggregateContextProvider
| None = None,
middleware: Middleware | list[Middleware] | None = None,
context_providers: ContextProvider | list[ContextProvider] | None = None,
middleware: AgentMiddleware | ChatMiddleware | list[AgentMiddleware | ChatMiddleware] | None = None,
frequency_penalty: float | None = None,
logit_bias: dict[str | int, float] | None = None,
max_tokens: int | None = None,
Expand All @@ -640,19 +631,19 @@ def create_agent(
| Literal["auto", "required", "none"]
| dict[str, Any]
| None = "auto",
tools: ToolProtocol
tools: FunctionTool
| Callable[..., Any]
| MutableMapping[str, Any]
| Sequence[ToolProtocol | Callable[..., Any] | MutableMapping[str, Any]]
| Sequence[FunctionTool | Callable[..., Any] | MutableMapping[str, Any]]
| None = None,
top_p: float | None = None,
user: str | None = None,
additional_chat_options: dict[str, Any] | None = None,
**kwargs: Any,
) -> ChatAgent:
) -> Agent:
"""Create a Chat Client Agent.
Factory method that creates a ChatAgent instance with the specified configuration.
Factory method that creates a Agent instance with the specified configuration.
The agent uses a chat client to interact with language models and supports tools
(MCP tools, callable functions), context providers, middleware, and both streaming
and non-streaming responses.
Expand Down Expand Up @@ -686,7 +677,7 @@ def create_agent(
**kwargs: Additional keyword arguments
Returns:
ChatAgent: Configured chat agent instance that can be used directly or with async context manager
Agent: Configured chat agent instance that can be used directly or with async context manager
Examples:
Non-streaming example (from azure_response_client_basic.py):
Expand Down Expand Up @@ -761,10 +752,10 @@ def create_agent(
Note:
When the agent has MCP tools or needs proper resource cleanup, use it with
``async with`` to ensure proper initialization and cleanup via the ChatAgent's
``async with`` to ensure proper initialization and cleanup via the Agent's
async context manager protocol.
"""
return ChatAgent(
return Agent(
chat_client=chat_client,
instructions=instructions,
id=id,
Expand Down
27 changes: 15 additions & 12 deletions src/processor/src/libs/agent_framework/agent_framework_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
)

if TYPE_CHECKING:
from agent_framework.azure import (
AzureAIAgentClient,
AzureOpenAIAssistantsClient,
AzureOpenAIChatClient,
AzureOpenAIResponsesClient,
)
from agent_framework.azure import DurableAIAgentClient

# TODO: agent-framework 1.3.0 removed these azure clients with no replacement.
# from agent_framework.azure import AzureOpenAIAssistantsClient
# from agent_framework.azure import AzureOpenAIChatClient
# from agent_framework.azure import AzureOpenAIResponsesClient


class ClientType(Enum):
Expand Down Expand Up @@ -147,7 +147,7 @@ def create_client(
env_file_path: str | None = None,
env_file_encoding: str | None = None,
instruction_role: str | None = None,
) -> "AzureOpenAIChatClient":
) -> Any:
pass

@overload
Expand All @@ -171,7 +171,7 @@ def create_client(
async_client: object | None = None,
env_file_path: str | None = None,
env_file_encoding: str | None = None,
) -> "AzureOpenAIAssistantsClient":
) -> Any:
pass

@overload
Expand All @@ -193,7 +193,7 @@ def create_client(
env_file_path: str | None = None,
env_file_encoding: str | None = None,
instruction_role: str | None = None,
) -> "AzureOpenAIResponsesClient":
) -> Any:
pass

@overload
Expand Down Expand Up @@ -233,7 +233,7 @@ def create_client(
async_credential: object | None = None,
env_file_path: str | None = None,
env_file_encoding: str | None = None,
) -> "AzureAIAgentClient":
) -> "DurableAIAgentClient":
pass

@staticmethod
Expand Down Expand Up @@ -443,9 +443,12 @@ def create_client(
retry_config=retry_config,
)
elif client_type == ClientType.AzureOpenAIAgent:
from agent_framework.azure import AzureAIAgentClient
try:
from agent_framework.azure import DurableAIAgentClient
except ImportError:
from agent_framework.azure import AzureAIAgentClient as DurableAIAgentClient

return AzureAIAgentClient(
return DurableAIAgentClient(
project_client=project_client,
agent_id=agent_id,
agent_name=agent_name,
Expand Down
7 changes: 4 additions & 3 deletions src/processor/src/libs/agent_framework/agent_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"""Pydantic model describing an agent participant with Jinja2 template rendering."""

from typing import Any, Callable, MutableMapping, Sequence
from agent_framework import ToolProtocol

from agent_framework import FunctionTool
from jinja2 import Template
from openai import BaseModel
from pydantic import Field
Expand All @@ -20,10 +21,10 @@ class AgentInfo(BaseModel):
agent_instruction: str | None = Field(default=None)
agent_framework_helper: AgentFrameworkHelper | None = Field(default=None)
tools: (
ToolProtocol
FunctionTool
| Callable[..., Any]
| MutableMapping[str, Any]
| Sequence[ToolProtocol | Callable[..., Any] | MutableMapping[str, Any]]
| Sequence[FunctionTool | Callable[..., Any] | MutableMapping[str, Any]]
| None
) = Field(default=None)

Expand Down
Loading
Loading