Skip to content

fix: Upgrade azure-ai-projects and agent-framework#599

Draft
Prachig-Microsoft wants to merge 19 commits into
devfrom
feature/upgrade-azure-ai-libs
Draft

fix: Upgrade azure-ai-projects and agent-framework#599
Prachig-Microsoft wants to merge 19 commits into
devfrom
feature/upgrade-azure-ai-libs

Conversation

@Prachig-Microsoft
Copy link
Copy Markdown
Contributor

This pull request updates both the ContentProcessor and ContentProcessorWorkflow projects to support the latest agent-framework (1.3.0) and azure-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?

  • Yes
  • No

Golden Path Validation

  • I have tested the primary workflows (the "golden path") to ensure they function correctly without errors.

Deployment Validation

  • I have validated the deployment process successfully and all services are running as expected with this change.

What to Check

Verify that the following are valid

  • ...

Other Information

Prachig-Microsoft and others added 2 commits May 20, 2026 14:18
- 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>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 20, 2026

Coverage

Coverage Report •
FileStmtsMissCoverMissing
TOTAL121716186% 
report-only-changed-files is enabled. No files were changed during this commit :)

Tests Skipped Failures Errors Time
244 0 💤 0 ❌ 0 🔥 4.318s ⏱️

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>
@Prachig-Microsoft Prachig-Microsoft changed the title fix: Upgrade azure-ai-projects and agent-framework with breaking changes fix: Upgrade azure-ai-projects and agent-framework May 20, 2026
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>
Prachig-Microsoft and others added 2 commits May 22, 2026 10:14
- 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>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-framework and azure-ai-projects dependency pins and updates the uv.lock resolution.
  • Migrates workflow steps, middleware, orchestrator, and helpers from legacy ChatAgent/ChatMessage/Azure client classes to Agent/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_text to populate TextContent, but the implementation now builds contents via Content.from_text(...) in azure_openai_response_retry.py. The TextContent import and isinstance(..., 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 a ChatAgent, but the method signature/implementation now returns Agent. Please update the docstring (and any other ChatAgent references 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 AzureOpenAIChatClientWithRetry docstring says it overrides both _inner_get_response and _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.

Comment thread src/ContentProcessorWorkflow/pyproject.toml
Comment thread src/ContentProcessor/src/libs/agent_framework/agent_builder.py
@Prachig-Microsoft Prachig-Microsoft marked this pull request as draft May 22, 2026 05:26
Prachig-Microsoft and others added 2 commits May 22, 2026 11:06
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants