fix: Upgrade azure-ai-projects and agent-framework#599
fix: Upgrade azure-ai-projects and agent-framework#599Prachig-Microsoft wants to merge 19 commits into
Conversation
- Update azure-ai-projects from 2.0.0b3/1.0.0b12 to 2.1.0 in pyproject.toml and requirements.txt - Update agent-framework from 1.0.0b260127/1.0.0b260107 to 1.3.0 in pyproject.toml - Migrate ChatMessage(text=...) to ChatMessage(contents=[...]) (breaking change in 1.0.0) - Update codeSample.py to use new sub-client agents API (.agents.threads.create() etc.) - Fix test files to use public ChatMessage import and new constructor Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…or 1.3.0 In agent-framework 1.3.0, Azure OpenAI clients were extracted into the agent-framework-openai sub-package. The old import path agent_framework.azure no longer exports OpenAI client classes. Changes: - AzureOpenAIChatClient -> OpenAIChatCompletionClient (agent_framework.openai) - AzureOpenAIResponsesClient -> OpenAIChatClient (agent_framework.openai) - Updated constructor params: deployment_name->model, endpoint->azure_endpoint, ad_token_provider->credential - Removed unsupported params: ad_token, token_endpoint - AzureOpenAIAssistantsClient and AzureAIAgentClient raise NotImplementedError (never used at runtime, no direct equivalents in 1.3.0) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
In agent-framework 1.3.0, individual event classes (ExecutorCompletedEvent, ExecutorFailedEvent, ExecutorInvokedEvent, WorkflowFailedEvent, WorkflowOutputEvent, WorkflowStartedEvent) were replaced by a unified WorkflowEvent class with a type discriminator field. Migrated isinstance checks to event.type == '...' pattern. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Reverted all agent-framework 1.3.0 breaking change fixes (ChatMessage, event classes, import paths) back to dev baseline. Set agent-framework to 1.1.1 instead of 1.3.0. Kept azure-ai-projects upgrade to 2.1.0. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
agent-framework stable releases (1.1.1+) have the same API changes as 1.3.0: - Individual event classes replaced by unified WorkflowEvent with type field - Azure OpenAI clients moved to agent_framework.openai sub-package - Constructor params renamed (deployment_name->model, endpoint->azure_endpoint) - ChatMessage(text=...) replaced with ChatMessage(contents=[...]) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The Dockerfile uses 'uv sync --frozen' which reads from uv.lock, not pyproject.toml. The lock files were still pinned to the old beta versions (1.0.0b260107/1.0.0b260127), causing the Docker build to install the old beta despite pyproject.toml specifying 1.1.1. Regenerated both lock files to resolve agent-framework 1.1.1 with agent-framework-openai 1.1.1 and agent-framework-core 1.1.1. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Updated mock patches in test_agent_framework_helper.py to reference: - agent_framework.openai.OpenAIChatCompletionClient (was azure.AzureOpenAIChatClient) - agent_framework.openai.OpenAIChatClient (was azure.AzureOpenAIResponsesClient) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- ctx.set_state() and ctx.get_state() are synchronous in agent-framework 1.1.1 (return None/value directly). Removing incorrect await that caused: TypeError: object NoneType can't be used in 'await' expression - Role is a NewType (str alias) in 1.1.1, not an enum. Replace Role.USER and Role.ASSISTANT with string literals, and .role.value with .role - Replace removed TextContent with Content.from_text() in retry utils Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove docstring, comment, and test rename changes that were not required by the agent-framework 1.1.1 / azure-ai-projects 2.1.0 upgrade. Keeps only functional API migration changes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Remove unused 'asyncio' import from both azure_openai_response_retry.py - Remove unused 'Role' import from groupchat_orchestrator.py and middlewares.py - Remove trailing blank line from ContentProcessor azure_openai_response_retry.py Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Resolve uv.lock conflict by regenerating after merge. Includes dev's python-multipart 0.0.27 bump and other updates. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Updates the ContentProcessor and ContentProcessorWorkflow Python code to align with newer agent-framework / azure-ai-projects APIs by migrating from deprecated agent/client/message types to the newer Agent / Message / OpenAI client classes, and refreshing retry/middleware/orchestration integrations.
Changes:
- Bumps
agent-frameworkandazure-ai-projectsdependency pins and updates theuv.lockresolution. - Migrates workflow steps, middleware, orchestrator, and helpers from legacy
ChatAgent/ChatMessage/Azure client classes toAgent/Message/OpenAI client classes and new workflow streaming event shapes. - Updates infra sample code and unit tests to match the new SDK/client interfaces.
Reviewed changes
Copilot reviewed 29 out of 31 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/tests/ContentProcessorWorkflow/libs/agent_framework/test_input_observer_middleware.py | Updates test to use Message (but still uses Role.USER in a way that no longer matches middleware role handling). |
| src/tests/ContentProcessorWorkflow/libs/agent_framework/test_azure_openai_response_retry_utils.py | Updates tests to Message, but still asserts TextContent content type. |
| src/tests/ContentProcessorWorkflow/libs/agent_framework/test_agent_framework_helper.py | Updates patch targets to new agent_framework.openai client classes. |
| src/tests/ContentProcessorWorkflow/libs/agent_framework/test_agent_builder.py | Updates patch target from ChatAgent to Agent and adapts option passing expectations. |
| src/ContentProcessorWorkflow/tests/unit/libs/agent_framework/test_input_observer_middleware.py | Migrates unit test to Message and string role usage. |
| src/ContentProcessorWorkflow/tests/unit/libs/agent_framework/test_azure_openai_response_retry_utils.py | Migrates unit test to new content typing (Content) and Message. |
| src/ContentProcessorWorkflow/tests/unit/libs/agent_framework/test_agent_framework_helper.py | Updates unit tests for new OpenAI client class construction paths. |
| src/ContentProcessorWorkflow/tests/unit/libs/agent_framework/test_agent_builder.py | Adjusts unit tests for Agent creation and option passing. |
| src/ContentProcessorWorkflow/src/steps/summarize/executor/summarize_executor.py | Migrates executor to Message, SupportsChatGetResponse, and ctx.set_state. |
| src/ContentProcessorWorkflow/src/steps/rai/executor/rai_executor.py | Migrates executor to Message, SupportsChatGetResponse, and ctx.set_state. |
| src/ContentProcessorWorkflow/src/steps/gap_analysis/executor/gap_executor.py | Migrates executor to Message, SupportsChatGetResponse, and ctx.set_state. |
| src/ContentProcessorWorkflow/src/steps/document_process/executor/document_process_executor.py | Switches workflow output persistence from set_shared_state to set_state. |
| src/ContentProcessorWorkflow/src/steps/claim_processor.py | Updates workflow builder/streaming API usage and event handling to new WorkflowEvent model. |
| src/ContentProcessorWorkflow/src/libs/agent_framework/middlewares.py | Migrates middleware types to AgentContext/Message and string role comparisons. |
| src/ContentProcessorWorkflow/src/libs/agent_framework/groupchat_orchestrator.py | Migrates orchestrator to new agent-framework types/events and builder API; adds local ManagerSelectionResponse. |
| src/ContentProcessorWorkflow/src/libs/agent_framework/azure_openai_response_retry.py | Migrates retry wrappers to agent_framework.openai clients and updates option passing (options). |
| src/ContentProcessorWorkflow/src/libs/agent_framework/agent_speaking_capture.py | Updates middleware context type to AgentContext. |
| src/ContentProcessorWorkflow/src/libs/agent_framework/agent_info.py | Removes deprecated ToolProtocol typing and broadens tools typing. |
| src/ContentProcessorWorkflow/src/libs/agent_framework/agent_framework_helper.py | Migrates client creation to agent_framework.openai classes and removes deprecated Azure agent client support. |
| src/ContentProcessorWorkflow/src/libs/agent_framework/agent_builder.py | Reworks builder to construct Agent with ChatOptions (default_options) and new middleware/history types. |
| src/ContentProcessorWorkflow/pyproject.toml | Pins agent-framework==1.1.1 and azure-ai-projects==2.1.0. |
| src/ContentProcessor/uv.lock | Updates locked dependency set for newer agent-framework ecosystem; enables prerelease mode. |
| src/ContentProcessor/src/libs/pipeline/handlers/map_handler.py | Migrates map handler call from ChatMessage to Message. |
| src/ContentProcessor/src/libs/agent_framework/azure_openai_response_retry.py | Migrates retry wrappers to agent_framework.openai clients and options parameter. |
| src/ContentProcessor/src/libs/agent_framework/agent_info.py | Removes deprecated ToolProtocol typing and broadens tools typing. |
| src/ContentProcessor/src/libs/agent_framework/agent_framework_helper.py | Migrates client creation to new OpenAI client classes; removes deprecated Azure agent client support. |
| src/ContentProcessor/src/libs/agent_framework/agent_builder.py | Reworks builder to construct Agent with ChatOptions (default_options) and new middleware/history types. |
| src/ContentProcessor/pyproject.toml | Pins agent-framework==1.1.1. |
| infra/vscode_web/requirements.txt | Updates azure-ai-projects requirement to 2.1.0. |
| infra/vscode_web/codeSample.py | Updates AIProjectClient agent/thread/message/run calls to the newer agents.* namespaces and adds run failure handling. |
Comments suppressed due to low confidence (3)
src/tests/ContentProcessorWorkflow/libs/agent_framework/test_azure_openai_response_retry_utils.py:151
- This test still expects
_set_message_textto populateTextContent, but the implementation now builds contents viaContent.from_text(...)inazure_openai_response_retry.py. TheTextContentimport andisinstance(..., TextContent)assertion will fail; update the test to assert against the new content type (or to assert on the resulting text value rather than a concrete content class).
m = Message(role="user", contents=["A" * 100_000])
result = _set_message_text(m, "truncated")
assert result.text == "truncated"
assert len(result.contents) == 1
assert isinstance(result.contents[0], TextContent)
src/ContentProcessor/src/libs/agent_framework/agent_builder.py:436
- The
build()docstring still describes returning aChatAgent, but the method signature/implementation now returnsAgent. Please update the docstring (and any otherChatAgentreferences in this module) to match the upgraded agent-framework API.
def build(self) -> Agent:
"""Build and return the configured ChatAgent.
Returns:
ChatAgent: Configured agent instance ready for use
src/ContentProcessorWorkflow/src/libs/agent_framework/azure_openai_response_retry.py:604
- The
AzureOpenAIChatClientWithRetrydocstring says it overrides both_inner_get_responseand_inner_get_streaming_response, but the streaming override has been removed in this version of the wrapper. Please update the docstring to reflect the actual overridden methods so retry/streaming behavior is clear.
class AzureOpenAIChatClientWithRetry(OpenAIChatCompletionClient):
"""Azure OpenAI Chat client with 429 retry at the request boundary.
This wraps the underlying chat-completions call used by Agent Framework by overriding
the internal `_inner_get_response` / `_inner_get_streaming_response` methods.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…param The openai SDK does not accept a 'reasoning' dict parameter in AsyncCompletions.create(). The correct parameter is 'reasoning_effort' (a string like 'high'). This fixes the runtime error in the map stage: AsyncCompletions.create() got an unexpected keyword argument 'reasoning' Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…leware Role is a NewType(str) in agent-framework 1.1.1, not an enum. Role.USER raises AttributeError at runtime. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This pull request updates both the ContentProcessor and ContentProcessorWorkflow projects to support the latest
agent-framework(1.3.0) andazure-ai-projects(2.1.0) releases, and removes support for deprecated Azure agent client types. It also updates the code to use the new OpenAI client classes and adapts helper logic and retry wrappers accordingly.Does this introduce a breaking change?
Golden Path Validation
Deployment Validation
What to Check
Verify that the following are valid
Other Information