fix: enhance message handling and context management in orchestrators#277
Merged
Conversation
Roopan-Microsoft
previously approved these changes
Jun 10, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the processor’s agent/orchestration integration to align with newer agent_framework APIs, improving how workflows stream events, how agent options/context providers are wired, and adding more robust Azure OpenAI Responses context-trimming behavior.
Changes:
- Refactors workflow construction and streaming execution to use updated
WorkflowBuilder/Workflow.run(..., stream=True)patterns. - Standardizes agent construction by moving model/options into
ChatOptions(default_options) and attaching context providers consistently (including in-memory history). - Enhances Azure OpenAI Responses context trimming by adding a post-trim cleanup step intended to prevent orphaned tool call/result pairs.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/processor/src/steps/migration_processor.py | Updates workflow graph construction and switches to the newer streaming run API. |
| src/processor/src/libs/base/orchestrator_base.py | Adjusts agent creation: sets store=False and adds InMemoryHistoryProvider alongside shared memory when enabled. |
| src/processor/src/libs/agent_framework/shared_memory_context_provider.py | Migrates context provider lifecycle hooks to the newer before_run/after_run interface and injects via context. |
| src/processor/src/libs/agent_framework/groupchat_orchestrator.py | Switches to agent_framework_orchestrations.GroupChatBuilder and updates streaming + response_format passing. |
| src/processor/src/libs/agent_framework/azure_openai_response_retry.py | Adds orphaned tool-message cleanup after trimming; improves endpoint/kwargs handling and adjusts Foundry base URL behavior. |
| src/processor/src/libs/agent_framework/agent_info.py | Broadens accepted tool types (FunctionTool + MCP tool types) via a shared ToolType alias. |
| src/processor/src/libs/agent_framework/agent_builder.py | Builds ChatOptions for default_options and normalizes middleware/context providers into sequences for Agent construction. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…e context handling
Roopan-Microsoft
approved these changes
Jun 10, 2026
|
🎉 This PR is included in version 2.1.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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 introduces several improvements and refactorings to the agent framework, focusing on cleaner option handling, improved tool type definitions, robust context trimming for Azure OpenAI responses, and more consistent context provider interfaces. The changes also address minor bugs and streamline the construction and orchestration of group chat workflows.
Does this introduce a breaking change?