.NET: Propagate AgentRunOptions to underlying workflow agents - #7925
Open
Saibernard wants to merge 2 commits into
Open
.NET: Propagate AgentRunOptions to underlying workflow agents#7925Saibernard wants to merge 2 commits into
Saibernard wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes #3679 by propagating per-invocation AgentRunOptions through hosted workflows, nested workflows, and checkpoint recovery.
Changes:
- Carries run options through workflow contexts and
TurnToken. - Merges handoff-specific tools and instructions with caller options.
- Adds orchestration and recovery coverage across workflow types.
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
dotnet/src/Microsoft.Agents.AI.Workflows/ChatProtocolExecutor.cs |
Exposes full turn tokens to derived executors. |
dotnet/src/Microsoft.Agents.AI.Workflows/IWorkflowContext.cs |
Adds an internal run-options context contract. |
dotnet/src/Microsoft.Agents.AI.Workflows/IWorkflowContextExtensions.cs |
Resolves invocation options with fallback behavior. |
dotnet/src/Microsoft.Agents.AI.Workflows/InProc/InProcessExecutionEnvironment.cs |
Starts and resumes runs with invocation options. |
dotnet/src/Microsoft.Agents.AI.Workflows/InProc/InProcessRunner.cs |
Applies current options to restored turn tokens. |
dotnet/src/Microsoft.Agents.AI.Workflows/InProc/InProcessRunnerContext.cs |
Stores per-run options in execution context. |
dotnet/src/Microsoft.Agents.AI.Workflows/Specialized/AIAgentHostExecutor.cs |
Passes options to hosted agents and continuations. |
dotnet/src/Microsoft.Agents.AI.Workflows/Specialized/GroupChatHost.cs |
Forwards options to group-chat participants. |
dotnet/src/Microsoft.Agents.AI.Workflows/Specialized/HandoffAgentExecutor.cs |
Merges caller and handoff options. |
dotnet/src/Microsoft.Agents.AI.Workflows/Specialized/HandoffStartExecutor.cs |
Preserves the full token in handoff state. |
dotnet/src/Microsoft.Agents.AI.Workflows/Specialized/Magentic/MagenticManager.cs |
Passes options to manager-agent calls. |
dotnet/src/Microsoft.Agents.AI.Workflows/Specialized/Magentic/MagenticOrchestrator.cs |
Propagates options through Magentic turns. |
dotnet/src/Microsoft.Agents.AI.Workflows/Specialized/WorkflowHostExecutor.cs |
Propagates options into nested workflows. |
dotnet/src/Microsoft.Agents.AI.Workflows/TurnToken.cs |
Adds nonserialized run options to turn tokens. |
dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowHostAgent.cs |
Supplies caller options to workflow sessions. |
dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowSession.cs |
Carries options through run creation and recovery. |
dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/ChatProtocolExecutorTests.cs |
Tests token forwarding and recovery. |
dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/GroupChatOrchestrationTests.cs |
Tests group-chat propagation. |
dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/HandoffOrchestrationTests.cs |
Tests handoff option merging. |
dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/MagenticOrchestrationTests.cs |
Tests Magentic propagation and recovery. |
dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/OrchestrationTestHelpers.cs |
Adds checkpoint test support. |
dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/RecordingEchoAgent.cs |
Records received options for assertions. |
dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/RecordingReplayAgent.cs |
Records replay-agent options. |
dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/Sample/12_HandOff_HostAsAgent.cs |
Records handoff-agent options. |
dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/WorkflowHostSmokeTests.cs |
Covers sequential, concurrent, nested, and continuation flows. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Saibernard
marked this pull request as ready for review
August 28, 2026 01:03
Saibernard
requested review from
SergeyMenshykh,
chetantoshniwal,
Peter Ibekwe (peibekwe),
Roger Barreto (rogerbarreto) and
westey (westey-m)
as code owners
August 28, 2026 01:04
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.
Motivation & Context
Workflows exposed through
AsAgent()currently discard the caller'sAgentRunOptions. As a result, per-run settings such as chat options and additional properties do not reach agents executed by the workflow.Description & Review Guide
AgentRunOptionsthrough workflow sessions and turn tokens for sequential, concurrent, group chat, handoff, Magentic, customChatProtocolExecutorimplementations, and nested workflows. The current invocation options are restored after checkpoint recovery without serializing them.ChatProtocolExecutorimplementations remain compatible, and handoff instructions and tools are preserved when options are combined.Related Issue
Fixes #3679
Contribution Checklist