fix: Refactor code structure for improved readability and maintainability#271
Open
Dhanushree-Microsoft wants to merge 17 commits into
Open
fix: Refactor code structure for improved readability and maintainability#271Dhanushree-Microsoft wants to merge 17 commits into
Dhanushree-Microsoft wants to merge 17 commits into
Conversation
…proved telemetry and error reporting
…and OrchestratorBase
…eter support and backward compatibility
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request updates the processor/backend dependency set and refactors the “agent framework” integration layer to be compatible with agent-framework==1.3.0, including migrating from legacy event/agent types to the newer Agent + WorkflowEvent APIs.
Changes:
- Bumped
agent-framework(and related Azure SDK deps) and refresheduv.lock/requirements across processor, backend-api, and infra. - Refactored orchestrators, agent builder/helper code, and MCP examples to use
Agent,WorkflowEvent, andFunctionTool-style tooling. - Updated unit tests to align with the new event/message shapes and renamed coordinator response model.
Reviewed changes
Copilot reviewed 29 out of 31 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/processor/uv.lock | Updates processor locked dependencies for agent-framework 1.3.0 and related packages. |
| src/processor/pyproject.toml | Pins processor runtime dependencies to agent-framework 1.3.0 and newer Azure SDK versions. |
| src/backend-api/uv.lock | Updates backend-api lockfile to newer azure-ai-agents. |
| src/backend-api/pyproject.toml | Pins backend-api dependency azure-ai-agents to 1.2.0b6. |
| infra/vscode_web/requirements.txt | Updates infra requirements to azure-ai-projects==2.1.0. |
| infra/vscode_web/endpoint-requirements.txt | Updates endpoint requirements to azure-ai-projects==2.1.0. |
| src/processor/src/steps/migration_processor.py | Migrates workflow stream handling from event classes to WorkflowEvent with event.type checks. |
| src/processor/src/steps/analysis/orchestration/analysis_orchestrator.py | Updates MCP tool typing/imports for agent-framework 1.3.0. |
| src/processor/src/steps/design/orchestration/design_orchestrator.py | Updates MCP tool typing/imports for agent-framework 1.3.0. |
| src/processor/src/steps/convert/orchestration/yaml_convert_orchestrator.py | Updates MCP tool typing/imports for agent-framework 1.3.0. |
| src/processor/src/steps/documentation/orchestration/documentation_orchestrator.py | Updates MCP tool typing/imports for agent-framework 1.3.0. |
| src/processor/src/libs/base/orchestrator_base.py | Switches to Agent, adds coordinator response model, and configures tool-result compaction. |
| src/processor/src/libs/agent_framework/agent_builder.py | Refactors fluent builder from ChatAgent to Agent and updates types/tools/middleware handling. |
| src/processor/src/libs/agent_framework/agent_framework_helper.py | Adjusts client creation paths for removed/renamed agent-framework Azure clients. |
| src/processor/src/libs/agent_framework/azure_openai_response_retry.py | Re-bases retry client on new OpenAI client surface and adapts request/stream method signatures. |
| src/processor/src/libs/agent_framework/groupchat_orchestrator.py | Migrates orchestrator types/events/messages to agent-framework 1.3.0 equivalents. |
| src/processor/src/libs/agent_framework/shared_memory_context_provider.py | Updates context provider to use Message and revised context injection surface. |
| src/processor/src/libs/agent_framework/middlewares.py | Updates middleware interfaces to AgentContext and Message. |
| src/processor/src/libs/agent_framework/agent_speaking_capture.py | Updates middleware context type (AgentRunContext → AgentContext). |
| src/processor/src/libs/agent_framework/agent_info.py | Updates tool typing from ToolProtocol to FunctionTool. |
| src/processor/src/libs/agent_framework/coordinator_selection_response.py | Adds new coordinator selection response model used for routing/termination. |
| src/processor/src/libs/mcp_server/MCPMicrosoftDocs.py | Updates MCP usage examples to use Agent instead of ChatAgent. |
| src/processor/src/libs/mcp_server/MCPDatetimeTool.py | Updates MCP usage examples to use Agent instead of ChatAgent. |
| src/processor/src/libs/mcp_server/MCPBlobIOTool.py | Updates MCP usage examples to use Agent instead of ChatAgent. |
| src/processor/src/tests/unit/steps/test_migration_processor_run.py | Updates tests to use WorkflowEvent.*() factories instead of legacy event classes. |
| src/processor/src/tests/unit/libs/agent_framework/test_shared_memory_context_provider.py | Adjusts assertions for updated context object shape. |
| src/processor/src/tests/unit/libs/agent_framework/test_middlewares_extras.py | Introduces message stubs/patching to test middlewares under new Message API. |
| src/processor/src/tests/unit/libs/agent_framework/test_input_observer_middleware.py | Introduces message stubs/patching to test input observer behavior under new Message API. |
| src/processor/src/tests/unit/libs/agent_framework/test_groupchat_orchestrator_internals.py | Updates internal orchestrator tests to use message stubs and string roles. |
| src/processor/src/tests/unit/libs/agent_framework/test_agent_framework_helper.py | Updates helper tests to reflect removed azure clients and renamed agent client. |
| src/processor/src/tests/unit/libs/agent_framework/test_agent_builder.py | Updates builder tests to patch Agent construction instead of ChatAgent. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
When callers pass credential=None explicitly, the key exists in kwargs but the ad_token_provider mapping was skipped. Use kwargs.get() is None to correctly handle this case. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When callers pass credential=None explicitly, the key exists in kwargs but the ad_token_provider mapping was skipped. Use kwargs.get() is None to correctly handle this case. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep agent-framework==1.3.0 upgrade from PR (per user story 43673). Accept newer general dependency versions from dev branch. Keep upgraded azure_openai_response_retry.py from PR. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The teardown_module from one test file was restoring the real Message before another test file's tests ran. Adding setup_module ensures the stub is re-applied before each module's tests execute. Also fix test assertion to check contents instead of text since the middleware now uses Message(contents=). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 28 out of 29 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
src/processor/src/libs/agent_framework/shared_memory_context_provider.py:312
SharedMemoryContextProvider._get_text()checksmessage.content, but the new agent-frameworkMessageusescontents(and callers in this repo treat tool calls / message payloads asMessage.contents). As written, this will returnstr(message)for most messages and degrade both memory search queries and stored memory quality.
def _get_text(message: Message) -> str:
"""Extract text content from a Message."""
if hasattr(message, "text") and message.text:
return message.text
if hasattr(message, "content"):
return str(message.content) if message.content else ""
return str(message) if message else ""
The middleware now uses Message(contents=) so the test must verify the contents field, not text. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Set both text= and contents= when constructing Message in InputObserverMiddleware for compatibility with downstream code - Restore missing copyright header in azure_openai_response_retry.py Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- shared_memory_context_provider: _get_text() now checks message.contents - middlewares: InputObserverMiddleware handles messages with only contents (no text) - azure_openai_response_retry: _get_message_role() handles enum roles via .value - azure_openai_response_retry: _set_message_text() also updates contents attribute - groupchat_orchestrator: updated comment to reference Coordinator (not manager) - uv.lock: regenerated to match pyproject.toml pinned versions Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
This pull request updates dependencies and refactors the agent builder and client helper code to align with the latest
agent-frameworklibrary changes. The main focus is on supporting the newAgentclass and handling the removal or renaming of several types and clients inagent-framework1.3.0. The changes improve compatibility and future-proof the codebase.Does this introduce a breaking change?