Skip to content

fix: Feature/upgrade agent framework azure ai projects#281

Draft
Prachig-Microsoft wants to merge 9 commits into
devfrom
feature/upgrade-agent-framework-azure-ai-projects
Draft

fix: Feature/upgrade agent framework azure ai projects#281
Prachig-Microsoft wants to merge 9 commits into
devfrom
feature/upgrade-agent-framework-azure-ai-projects

Conversation

@Prachig-Microsoft

Copy link
Copy Markdown
Contributor

This pull request introduces several improvements and refactors to the agent builder and related developer experience. The most significant changes are a major refactor of the AgentBuilder class to support the new Agent interface (instead of ChatAgent), improved handling of model-specific options, and updates to documentation and dependencies to align with the latest APIs.

Agent Builder and Agent Framework Refactor:

  • Refactored AgentBuilder in agent_builder.py to build the new Agent class instead of ChatAgent, updated type hints throughout, improved middleware and context provider handling, and added logic to strip unsupported parameters for reasoning models. Also updated static creation methods and tool typing for compatibility with the latest agent framework. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14]

Dependency and Compatibility Updates:

  • Upgraded agent-framework to version 1.3.0 in pyproject.toml and azure-ai-projects to 2.1.0 in requirements.txt to ensure compatibility with new APIs and features. [1] [2]

Code Sample and SDK Usage Updates:

  • Updated infra/vscode_web/codeSample.py to use the latest SDK method names and patterns, including new thread, message, and run creation APIs, and improved message handling with the new ListSortOrder. [1] [2]

Documentation Improvements:

  • Clarified and updated instructions in LocalDevelopmentSetup.md regarding the use of prerelease dependencies, and improved the process framework guide to reflect new workflow builder usage and simplified test commands. [1] [2] [3]

These changes modernize the agent framework integration, improve developer ergonomics, and ensure the codebase is aligned with the latest SDK and library best practices.## Purpose

  • ...

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

  • [x
    This pull request introduces several important updates to both the documentation and the agent framework codebase, with a focus on upgrading dependencies, improving API clarity, and aligning the code with the latest versions of key libraries. The most significant changes include refactoring the AgentBuilder to support the new Agent class (instead of ChatAgent), updating type annotations for middleware and tools, and revising documentation to reflect these updates and new best practices.

Agent Framework Refactoring and Type Modernization

  • Refactored AgentBuilder in agent_builder.py to construct the new Agent class (not ChatAgent), updated type annotations for middleware, tools, and message stores, and added logic to handle model-specific options and reasoning models. This includes new helper functions, improved option handling, and a more robust build process. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14]

Dependency Upgrades

  • Upgraded agent-framework to version 1.3.0 in pyproject.toml and azure-ai-projects to 2.1.0 in requirements.txt, ensuring compatibility with the latest features and APIs. [1] [2]

Sample Code and Usage Updates

  • Updated infra/vscode_web/codeSample.py to use the new agents.threads, agents.messages, and agents.runs APIs, and improved error handling and message printing to match the upgraded SDK. [1] [2]

Documentation Improvements

  • Revised documentation in LocalDevelopmentSetup.md to clarify the need for the --prerelease=allow flag and explain its purpose more clearly.
  • Updated ProcessFrameworkGuide.md to reflect the new workflow builder API, showing how to instantiate and chain executors, and simplified the unit test command to remove unnecessary flags. [1] [2]

These changes collectively modernize the codebase, improve developer experience, and ensure alignment with the latest agent framework and Azure SDK conventions.] 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 3 commits June 11, 2026 21:19
- Update agent-framework from 1.0.0b260107 to 1.3.0 in pyproject.toml
- Update azure-ai-projects from 1.0.0b12 to 2.1.0 in requirements.txt
- Migrate ChatAgent to Agent (client=, default_options=ChatOptions)
- Migrate agent_framework.azure to agent_framework.openai module paths
- Migrate ChatMessage to Message with Content.from_text()
- Migrate Role enum to string literals
- Migrate AgentRunContext to AgentContext
- Migrate WorkflowBuilder to new API (start_executor=, add_chain)
- Migrate event handling from isinstance checks to WorkflowEvent.type
- Migrate GroupChatBuilder to agent_framework.orchestrations module
- Migrate ContextProvider to before_run/after_run interface
- Remove ToolProtocol (use Any), AgentProtocol (use SupportsAgentRun)
- Define ManagerSelectionResponse locally (removed from framework)
- Update MCP tool files for Agent import
- Update all unit tests for new APIs (812 tests passing)
- Update docs/ProcessFrameworkGuide.md with new WorkflowBuilder example
- Update docs/LocalDevelopmentSetup.md prerelease note
- Regenerate uv.lock

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
AgentBuilder.with_context_providers() and with_middleware() accepted single
objects but passed them directly to Agent(), which expects Sequence types.
Now both methods auto-wrap single items into a list.

Also wrapped the call site in orchestrator_base.py for clarity.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown

Coverage

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

Tests Skipped Failures Errors Time
588 0 💤 0 ❌ 0 🔥 26.549s ⏱️

@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown

Coverage

Processor Coverage Report •
FileStmtsMissCoverMissing
src/processor/src/libs/agent_framework
   agent_builder.py2233882%33–34, 40, 44, 53–59, 497, 499, 503, 505, 507, 509, 511, 513, 515, 521, 523, 525, 527, 838, 840, 842, 844, 846, 848, 850, 852, 854, 856, 862, 864, 866, 868
   agent_framework_helper.py77692%82, 149, 173, 195, 218, 235
   agent_info.py230100% 
   agent_speaking_capture.py66493%205–206, 209, 211
   azure_openai_response_retry.py3259371%87, 197, 205, 227, 253, 263–265, 389, 397–400, 402–404, 410–412, 429, 450–451, 456–459, 462–465, 467–470, 472, 482–484, 486–489, 491–494, 496–500, 502, 510–512, 514, 530–532, 544, 546–547, 550, 552, 556, 559, 563, 574–577, 581–583, 586–587, 594–595, 606, 610–611, 617–618, 623, 625, 646–647, 650–651, 656, 660, 663–664
   groupchat_orchestrator.py5479083%138–139, 146–147, 152–153, 481, 484–488, 490, 492–493, 496, 499, 502, 504, 506–509, 516–517, 524–525, 532–533, 536–538, 541–542, 547–549, 552–553, 558, 561–563, 566–567, 572, 575, 581, 584, 588, 590–594, 598–599, 605, 608, 612, 617, 620, 631–632, 634, 636–637, 639, 649–650, 652, 744, 918, 937, 939, 941, 970, 1099, 1101, 1217, 1226, 1228, 1273–1274, 1277, 1298–1301, 1319
   middlewares.py800100% 
   shared_memory_context_provider.py1241587%109, 136, 178, 182, 222, 233, 237, 242, 274, 285, 290, 313–315, 323
src/processor/src/libs/base
   orchestrator_base.py1654970%63, 69, 72–75, 81–82, 84–85, 128, 139, 144, 149–150, 154, 162, 164, 166, 173–174, 181, 183, 190, 194, 203, 207, 212, 214–215, 217, 316–318, 321, 327, 334–336, 363–365, 368, 375, 382–384, 435–436
src/processor/src/libs/mcp_server
   MCPBlobIOTool.py50100% 
   MCPDatetimeTool.py60100% 
   MCPMicrosoftDocs.py30100% 
src/processor/src/steps
   migration_processor.py2684483%92–93, 149–150, 164–167, 171, 177, 212–213, 219–220, 224, 228, 299–302, 305–308, 312–313, 326–327, 387–388, 490–491, 541–542, 549–550, 588–589, 607–608, 672–673, 697, 726
src/processor/src/steps/analysis/orchestration
   analysis_orchestrator.py85890%46–47, 61, 65, 112, 115, 121, 123
src/processor/src/steps/convert/orchestration
   yaml_convert_orchestrator.py97594%67, 115, 118, 124, 126
src/processor/src/steps/design/orchestration
   design_orchestrator.py82989%45–46, 53, 57, 107, 110, 117–118, 120
src/processor/src/steps/documentation/orchestration
   documentation_orchestrator.py95693%72, 120, 123, 129–130, 132
TOTAL580272987% 

Tests Skipped Failures Errors Time
814 0 💤 0 ❌ 0 🔥 18.257s ⏱️

The Responses API requires the new v1 API endpoint. The old preview
version (2025-03-01-preview) does not support the /responses endpoint,
causing BadRequest 'API version not supported' errors at runtime.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The parent OpenAIChatClient._inner_get_response is a regular def that
returns ResponseStream (async iterable) when stream=True, or Awaitable
when stream=False. The override was async def, which always returned a
coroutine, breaking 'async for event in workflow.run(stream=True)'.

Refactored to:
- Regular def _inner_get_response dispatching stream vs non-stream
- _non_streaming_with_retry: async coroutine with retry + context-trim
- _streaming_with_retry: async generator with pre-first-chunk retry
- _maybe_trim_messages: shared context-trim helper

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…erator

The framework's BaseChatClient.get_response checks
isinstance(result, ResponseStream) for streaming responses. Our async
generator from _streaming_with_retry failed that check, causing the
framework to 'await' it — which fails with 'object async_generator
can't be used in await expression'.

Fix: for streaming, pass through to the parent's _inner_get_response
which returns a proper ResponseStream. Retry is preserved for
non-streaming calls. Removed unused _streaming_with_retry method.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- _trim_messages: keep at least 1 message (never pop to empty)
- _maybe_trim_messages: fall back to originals if trim produces empty
- _non_streaming_with_retry: re-raise if aggressive trim empties list
- _inner_get_response: log warning and use originals if messages empty

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Lychee v0.23.0 removed --exclude-mail (mail exclusion is now default).

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.

1 participant