Skip to content

fix: enhance message handling and context management in orchestrators#277

Merged
Roopan-Microsoft merged 5 commits into
devfrom
psl-agentframework
Jun 10, 2026
Merged

fix: enhance message handling and context management in orchestrators#277
Roopan-Microsoft merged 5 commits into
devfrom
psl-agentframework

Conversation

@Dhanushree-Microsoft

Copy link
Copy Markdown
Contributor

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?

  • Yes
  • No

@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown

Coverage

Processor Coverage Report •
FileStmtsMissCoverMissing
src/processor/src/libs/agent_framework
   agent_builder.py1992985%448, 450, 454, 456, 458, 460, 462, 464, 466, 472, 474, 476, 483, 488, 791, 793, 795, 797, 799, 801, 803, 805, 807, 809, 815, 817, 819, 826, 831
   agent_info.py250100% 
   azure_openai_response_retry.py45520854%91, 201, 209, 231, 257, 267–269, 334, 336, 353–357, 359–366, 375, 382–387, 389–396, 398–403, 405, 407, 409–410, 413, 415–429, 432, 434, 436, 504, 511–514, 516–518, 524–526, 548, 569–570, 575–578, 581–584, 586–589, 591, 601–603, 605–608, 610–613, 615–619, 621, 629–631, 633, 656–661, 664–666, 668, 672–677, 679–680, 686–687, 691–694, 698, 701, 709–710, 716–717, 722, 724, 745, 751–753, 757–758, 774–775, 777–780, 784, 787, 795–796, 802–804, 806–809, 811–822, 825, 832–833, 858–859, 866–867, 869, 873, 876–877, 881–882, 884–886, 894, 896–898, 900–902, 904–905, 915
   groupchat_orchestrator.py5449083%129–130, 137–138, 143–144, 471, 474–478, 480, 482–483, 486, 489, 492, 494, 496–499, 506–507, 514–515, 522–523, 526–528, 530–531, 536–538, 541–542, 547, 550–552, 555–556, 561, 564, 570, 573, 577, 579–583, 587–588, 594, 597, 601, 606, 609, 620–621, 623, 625–626, 628, 638–639, 641, 734, 908, 927, 929, 931, 960, 1089, 1091, 1207, 1216, 1218, 1263–1264, 1267, 1288–1291, 1309
   shared_memory_context_provider.py1222182%26, 115, 143, 218, 229, 233, 238, 270, 281, 286, 309–311, 318–319, 321–326
src/processor/src/libs/base
   orchestrator_base.py1695269%65, 71, 74–77, 83–84, 86–87, 130, 141, 146, 151–152, 156, 164, 166, 168, 176–177, 184, 190, 192, 199, 203, 212–215, 222, 224–225, 227, 326–328, 331, 337, 344–346, 373–375, 378, 385, 392–394, 445–446
src/processor/src/steps
   migration_processor.py2684483%88–89, 145–146, 160–163, 167, 175, 210–211, 217–218, 222, 226, 297–300, 303–306, 310–311, 324–325, 383–384, 484–485, 535–536, 543–544, 582–583, 601–602, 666–667, 691, 720
TOTAL592084985% 

Tests Skipped Failures Errors Time
812 0 💤 0 ❌ 0 🔥 19.841s ⏱️

@github-actions

github-actions Bot commented Jun 10, 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 🔥 30.228s ⏱️

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@Roopan-Microsoft Roopan-Microsoft merged commit 99e941b into dev Jun 10, 2026
12 of 13 checks passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 2.1.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants