Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
746b796
Upgrade azure-ai-projects to 2.1.0 and agent-framework to 1.3.0
Prachig-Microsoft May 20, 2026
c234316
fix: update agent_framework.azure imports to agent_framework.openai f…
Prachig-Microsoft May 20, 2026
e73f9f4
fix: replace removed event classes with WorkflowEvent type checks
Prachig-Microsoft May 20, 2026
77f0171
revert: change agent-framework to 1.1.1, revert all 1.3.0 code changes
Prachig-Microsoft May 20, 2026
4e87965
fix: apply breaking-change fixes for agent-framework 1.1.1
Prachig-Microsoft May 20, 2026
ee4650a
fix: regenerate uv.lock files for agent-framework 1.1.1
Prachig-Microsoft May 21, 2026
1b14417
fix: update test patches to use new agent_framework.openai classes
Prachig-Microsoft May 21, 2026
b400522
fix: migrate all renamed agent-framework symbols for 1.1.1
Prachig-Microsoft May 21, 2026
1e66f9e
fix: update docstring example to use Agent() constructor pattern
Prachig-Microsoft May 21, 2026
803fc11
fix: pass start_executor to WorkflowBuilder constructor
Prachig-Microsoft May 21, 2026
1927aa0
fix: use executor instances in WorkflowBuilder (1.1.1 API)
Prachig-Microsoft May 21, 2026
793f1b3
fix: align all code with agent-framework 1.1.1 API
Prachig-Microsoft May 21, 2026
369e3f7
fix: Workflow.run_stream() -> run(stream=True) in 1.1.1
Prachig-Microsoft May 21, 2026
9c23281
fix: remove await from sync ctx.set_state() and fix Role enum usage
Prachig-Microsoft May 21, 2026
ce961ad
chore: revert irrelevant docstring/comment changes from upgrade
Prachig-Microsoft May 21, 2026
f7c4134
fix: remove unused imports and trailing blank line (lint fixes)
Prachig-Microsoft May 22, 2026
8255859
Merge branch 'dev' into feature/upgrade-azure-ai-libs
Prachig-Microsoft May 22, 2026
13fe76a
fix: replace invalid 'reasoning' dict with 'reasoning_effort' string …
Prachig-Microsoft May 22, 2026
96df974
fix: replace Role.USER with 'user' string in test_input_observer_midd…
Prachig-Microsoft May 22, 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
19 changes: 13 additions & 6 deletions infra/vscode_web/codeSample.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
from azure.ai.projects import AIProjectClient
from azure.identity import DefaultAzureCredential
from azure.ai.agents.models import ListSortOrder

project_client = AIProjectClient.from_connection_string(
credential=DefaultAzureCredential(),
conn_str="<%= connectionString %>")

agent = project_client.agents.get_agent("<%= agentId %>")

thread = project_client.agents.create_thread()
thread = project_client.agents.threads.create()
print(f"Created thread, ID: {thread.id}")

message = project_client.agents.create_message(
message = project_client.agents.messages.create(
thread_id=thread.id,
role="user",
content="<%= userMessage %>"
)

run = project_client.agents.create_and_process_run(
run = project_client.agents.runs.create_and_process(
thread_id=thread.id,
agent_id=agent.id)
messages = project_client.agents.list_messages(thread_id=thread.id)

for text_message in messages.text_messages:
print(text_message.as_dict())
if run.status == "failed":
print(f"Run failed: {run.last_error}")
else:
messages = project_client.agents.messages.list(
thread_id=thread.id, order=ListSortOrder.ASCENDING)

for message in messages:
if message.text_messages:
print(f"{message.role}: {message.text_messages[-1].text.value}")
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
2 changes: 1 addition & 1 deletion src/ContentProcessor/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = "Content Process Gold Standard Solution Accelerator - Content Proc
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"agent-framework==1.0.0b260127",
"agent-framework==1.1.1",
"azure-ai-inference==1.0.0b9",
"azure-appconfiguration==1.8.0",
"azure-identity==1.26.0b1",
Expand Down
191 changes: 120 additions & 71 deletions src/ContentProcessor/src/libs/agent_framework/agent_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
from typing import Any, Literal

from agent_framework import (
ChatAgent,
ChatClientProtocol,
ChatMessageStoreProtocol,
Agent,
AgentMiddleware,
ChatMiddleware,
ChatOptions,
ContextProvider,
Middleware,
HistoryProvider,
SupportsChatGetResponse,
ToolMode,
ToolProtocol,
)
from pydantic import BaseModel

Expand Down Expand Up @@ -64,7 +65,7 @@ class AgentBuilder:
)
"""

def __init__(self, chat_client: ChatClientProtocol):
def __init__(self, chat_client: SupportsChatGetResponse):
"""Initialize the builder with a chat client.

Args:
Expand All @@ -75,12 +76,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[[], HistoryProvider] | None = None
self._conversation_id: str | None = None
self._context_providers: ContextProvider | list[ContextProvider] | None = None
self._middleware: Middleware | list[Middleware] | None = None
self._middleware: (
AgentMiddleware
| ChatMiddleware
| list[AgentMiddleware | ChatMiddleware]
| 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 @@ -96,10 +100,10 @@ def __init__(self, chat_client: ChatClientProtocol):
ToolMode | Literal["auto", "required", "none"] | dict[str, Any] | None
) = "auto"
self._tools: (
ToolProtocol
Any
| Callable[..., Any]
| MutableMapping[str, Any]
| Sequence[ToolProtocol | Callable[..., Any] | MutableMapping[str, Any]]
| Sequence[Any | Callable[..., Any] | MutableMapping[str, Any]]
| None
) = None
self._top_p: float | None = None
Expand Down Expand Up @@ -181,10 +185,10 @@ def with_max_tokens(self, max_tokens: int) -> "AgentBuilder":

def with_tools(
self,
tools: ToolProtocol
tools: Any
| Callable[..., Any]
| MutableMapping[str, Any]
| Sequence[ToolProtocol | Callable[..., Any] | MutableMapping[str, Any]],
| Sequence[Any | Callable[..., Any] | MutableMapping[str, Any]],
) -> "AgentBuilder":
"""Set the tools available to the agent.

Expand Down Expand Up @@ -213,7 +217,10 @@ 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 Down Expand Up @@ -385,7 +392,7 @@ def with_store(self, store: bool) -> "AgentBuilder":
return self

def with_message_store_factory(
self, factory: Callable[[], ChatMessageStoreProtocol]
self, factory: Callable[[], HistoryProvider]
) -> "AgentBuilder":
"""Set the message store factory.

Comment thread
Prachig-Microsoft marked this conversation as resolved.
Expand Down Expand Up @@ -422,7 +429,7 @@ def with_kwargs(self, **kwargs: Any) -> "AgentBuilder":
self._kwargs.update(kwargs)
return self

def build(self) -> ChatAgent:
def build(self) -> Agent:
"""Build and return the configured ChatAgent.

Returns:
Expand All @@ -442,32 +449,52 @@ def build(self) -> ChatAgent:
async with agent:
response = await agent.run("Hello!")
"""
return ChatAgent(
chat_client=self._chat_client,
options: dict[str, Any] = {}
if self._frequency_penalty is not None:
options["frequency_penalty"] = self._frequency_penalty
if self._logit_bias is not None:
options["logit_bias"] = self._logit_bias
if self._max_tokens is not None:
options["max_tokens"] = self._max_tokens
if self._metadata is not None:
options["metadata"] = self._metadata
if self._model_id is not None:
options["model"] = self._model_id
if self._presence_penalty is not None:
options["presence_penalty"] = self._presence_penalty
if self._response_format is not None:
options["response_format"] = self._response_format
if self._seed is not None:
options["seed"] = self._seed
if self._stop is not None:
options["stop"] = self._stop
if self._store is not None:
options["store"] = self._store
if self._temperature is not None:
options["temperature"] = self._temperature
if self._tool_choice is not None:
options["tool_choice"] = self._tool_choice
if self._top_p is not None:
options["top_p"] = self._top_p
if self._user is not None:
options["user"] = self._user
if self._conversation_id is not None:
options["conversation_id"] = self._conversation_id
if self._additional_chat_options:
options.update(self._additional_chat_options)

default_options: ChatOptions | None = ChatOptions(**options) if options else None

return Agent(
client=self._chat_client,
instructions=self._instructions,
id=self._id,
name=self._name,
description=self._description,
chat_message_store_factory=self._chat_message_store_factory,
conversation_id=self._conversation_id,
tools=self._tools,
default_options=default_options,
context_providers=self._context_providers,
middleware=self._middleware,
frequency_penalty=self._frequency_penalty,
logit_bias=self._logit_bias,
max_tokens=self._max_tokens,
metadata=self._metadata,
model_id=self._model_id,
presence_penalty=self._presence_penalty,
response_format=self._response_format,
seed=self._seed,
stop=self._stop,
store=self._store,
temperature=self._temperature,
tool_choice=self._tool_choice,
tools=self._tools,
top_p=self._top_p,
user=self._user,
additional_chat_options=self._additional_chat_options,
**self._kwargs,
)

Expand All @@ -477,11 +504,12 @@ 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[[], HistoryProvider] | None = None,
conversation_id: str | None = None,
context_providers: ContextProvider | list[ContextProvider] | None = None,
middleware: Middleware | list[Middleware] | 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 @@ -497,16 +525,16 @@ def create_agent_by_agentinfo(
| Literal["auto", "required", "none"]
| dict[str, Any]
| None = "auto",
tools: ToolProtocol
tools: Any
| Callable[..., Any]
| MutableMapping[str, Any]
| Sequence[ToolProtocol | Callable[..., Any] | MutableMapping[str, Any]]
| Sequence[Any | 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
Expand Down Expand Up @@ -608,17 +636,18 @@ def create_agent_by_agentinfo(

@staticmethod
def create_agent(
chat_client: ChatClientProtocol,
chat_client: SupportsChatGetResponse,
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[[], HistoryProvider] | None = None,
conversation_id: str | None = None,
context_providers: ContextProvider | list[ContextProvider] | None = None,
middleware: Middleware | list[Middleware] | 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 @@ -634,16 +663,16 @@ def create_agent(
| Literal["auto", "required", "none"]
| dict[str, Any]
| None = "auto",
tools: ToolProtocol
tools: Any
| Callable[..., Any]
| MutableMapping[str, Any]
| Sequence[ToolProtocol | Callable[..., Any] | MutableMapping[str, Any]]
| Sequence[Any | 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.
Expand Down Expand Up @@ -745,7 +774,7 @@ def create_agent(
temperature=0.7,
max_tokens=500,
additional_chat_options={
"reasoning": {"effort": "high", "summary": "concise"}
"reasoning_effort": "high"
}, # OpenAI-specific reasoning options
)

Expand All @@ -758,31 +787,51 @@ def create_agent(
``async with`` to ensure proper initialization and cleanup via the ChatAgent's
async context manager protocol.
"""
return ChatAgent(
chat_client=chat_client,
options: dict[str, Any] = {}
if frequency_penalty is not None:
options["frequency_penalty"] = frequency_penalty
if logit_bias is not None:
options["logit_bias"] = logit_bias
if max_tokens is not None:
options["max_tokens"] = max_tokens
if metadata is not None:
options["metadata"] = metadata
if model_id is not None:
options["model"] = model_id
if presence_penalty is not None:
options["presence_penalty"] = presence_penalty
if response_format is not None:
options["response_format"] = response_format
if seed is not None:
options["seed"] = seed
if stop is not None:
options["stop"] = stop
if store is not None:
options["store"] = store
if temperature is not None:
options["temperature"] = temperature
if tool_choice is not None:
options["tool_choice"] = tool_choice
if top_p is not None:
options["top_p"] = top_p
if user is not None:
options["user"] = user
if conversation_id is not None:
options["conversation_id"] = conversation_id
if additional_chat_options:
options.update(additional_chat_options)

default_options: ChatOptions | None = ChatOptions(**options) if options else None

return Agent(
client=chat_client,
instructions=instructions,
id=id,
name=name,
description=description,
chat_message_store_factory=chat_message_store_factory,
conversation_id=conversation_id,
tools=tools,
default_options=default_options,
context_providers=context_providers,
middleware=middleware,
frequency_penalty=frequency_penalty,
logit_bias=logit_bias,
max_tokens=max_tokens,
metadata=metadata,
model_id=model_id,
presence_penalty=presence_penalty,
response_format=response_format,
seed=seed,
stop=stop,
store=store,
temperature=temperature,
tool_choice=tool_choice,
tools=tools,
top_p=top_p,
user=user,
additional_chat_options=additional_chat_options,
**kwargs,
)
Loading
Loading