* Use actual message role when creating ChatMessage
Replace hard-coded ChatRole.User with a ChatRole constructed from the message's Role. The change ensures ToChatMessage and FunctionMessage use the original role (new ChatRole(this.Role)) for both text and contents branches, fixing incorrect role assignment when constructing ChatMessage instances.
* Update changes
* Fix formatting in ToChatMessage tests
---------
Co-authored-by: Roger Barreto <19890735+rogerbarreto@users.noreply.github.com>
* Add AsIChatClientWithStoredOutputDisabled for ProjectResponsesClient
Add extension method on ProjectResponsesClient in Microsoft.Agents.AI.AzureAI
package (Azure.AI.Extensions.OpenAI namespace) mirroring the existing extension
on ResponsesClient in the OpenAI package. This enables Azure AI consumers to
disable server-side response storage without depending on the OpenAI package.
- New ProjectResponsesClientExtensions class with AsIChatClientWithStoredOutputDisabled
- Optional deploymentName parameter (model is no longer required)
- Updated OpenAI counterpart doc to remove 'Required' wording for model param
- Added unit tests covering null guard, inner client accessibility,
StoredOutputEnabled=false, and reasoning encrypted content inclusion/exclusion
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Preserve existing RawRepresentationFactory when disabling stored output
Address PR review feedback: wrap/chain the existing factory instead of
replacing it, so upstream configuration (e.g., deploymentName/model defaults
from AsIChatClient) is preserved.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: HandoffAgentExecutor does not output any reponse when non-streaming
* fix: Ensure Workflow outputs persisted in chat history when hosted AsAgent
* fix: Remove duplicate history entry creation and ad test
* test: Add streaming tests for AsAgent to smoke tests
* feat: Add output configurability to Handoffs
* refactor: [BREAKING] Config => ExecutorConfig
Make the Config name less likely to collide with other classes by renaming to ExecutorConfig. Makes Configured and related classes internal as they do not need to be part of the public surface.
* fix: Make RouteBuilder explicit in SourceGen to avoid conflicts
* Handle external input request and response conversion for workflow as agent scenario
* Remove unnecessary test comment
* Fix PR comments
* Updated to fix edge cases, and add more tests.
* Update pending requests to use typed properties instead of relying on StateBag. replying to PR feedback.
* Fixed external response de-dup and updated possible brittle test.
* Address PR comments on sending turn token for normal messages and handle contentId collision by source agent
* Remove unnecessary serialization element and address pr comment on intercepted outgoing requests
* Updated MEAI changes for UserInput request and response abstractions.
* Expose workflow as MCP Tool
* Expose workflow as MCP Tool
* Cleanup
* PR feedback fixes
* update changelog to include PR numner
* Improvements to error handling.
* Adding a sample project demonstrating how to setup Agents and Workflows together.
* Ensure duplicate agent registrations are properly handled.
The `sessionId`, an optional parameter when starting a new session when
running a workflow is an arbitrary string. This allows consumers to
support whatever ids are needed by other systems, but can result in
errors when an OS special or forbidden character is included.
The fix is to escape the paths, in a 1:1 manner. We rely on
EncodeDataString to do this.
* Also modifies the index file to make it easier to determine what the
name of the file on disk is for a given `sessionId`.
* Persist messages during the Function Call Loop
* Revert version reset
* Fix bugs and improve sample
* Fix formatting issues
* Also updating conversation id during run
* Update based on ADR feedback
Azure.AI.Agents.Persistent 1.2.0-beta.10 now targets ME.AI 10.4.0+,
resolving the compatibility issue that required disabling this package.
- Remove IsPackable=false from the csproj
- Re-enable all 6 integration test classes (IntegrationDisabled → Integration)
- Remove outdated compatibility warning from README.md
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix source generator bug that silently drops base class handler registrations for protocol-only partial executors
* Fixed xml comments and variable naming.
* Fix FileAgentSkillsProvider accepting SkillsInstructionPrompt without {0} placeholder (#4638)
BuildSkillsInstructionPrompt validated only format-string syntax via
string.Format(template, ""), which silently accepted templates without a
{0} placeholder. The generated skills list was then dropped from the final
instructions.
Tighten validation to format with a sentinel string and verify it appears
in the output, rejecting templates that do not reference argument 0 with
an ArgumentException.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix netstandard2.0 compat and simplify prompt template validation (#4638)
- Replace string.Contains(string, StringComparison) with IndexOf for
netstandard2.0/net472 compatibility
- Remove sentinel round-trip check; validate {0} directly on the raw
template string using IndexOf
- Add positive test verifying custom SkillsInstructionPrompt with {0}
is accepted and applied to output
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix race condition issue in FanInEdge while processing messages.
* refactored to limit the code segment under lock.
* Remove extra materialization of the result.
* Added comment to clarify future changes if process message is made async.
* .NET: [Feature Branch] Add basic durable workflow support (#3648)
* Add basic durable workflow support.
* PR feedback fixes
* Add conditional edge sample.
* PR feedback fixes.
* Minor cleanup.
* Minor cleanup
* Minor formatting improvements.
* Improve comments/documentation on the execution flow.
* .NET: [Feature Branch] Add Azure Functions hosting support for durable workflows (#3935)
* Adding azure functions workflow support.
* - PR feedback fixes.
- Add example to demonstrate complex Object as payload.
* rename instanceId to runId.
* Use custom ITaskOrchestrator to run orchestrator function.
* .NET: [Feature Branch] Adding support for events & shared state in durable workflows (#4020)
* Adding support for events & shared state in durable workflows.
* PR feedback fixes
* PR feedback fixes.
* Add YieldOutputAsync calls to 05_WorkflowEvents sample executors
The integration test asserts that WorkflowOutputEvent is found in the
stream, but the sample executors only used AddEventAsync for custom
events and never called YieldOutputAsync. Since WorkflowOutputEvent is
only emitted via explicit YieldOutputAsync calls, the assertion would
fail. Added YieldOutputAsync to each executor to match the test
expectation and demonstrate the API in the sample.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix deserialization to use shared serializer options.
* PR feedback updates.
* Sample cleanup
* PR feedback fixes
* Addressing PR review feedback for DurableStreamingWorkflowRun
- Use -1 instead of 0 for taskId in TaskFailedException when task ID is not relevant.
- Add [NotNullWhen(true)] to TryParseWorkflowResult out parameter following .NET TryXXX conventions.
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* .NET: [Feature Branch] Add nested sub-workflow support for durable workflows (#4190)
* .NET: [Feature Branch] Add nested sub-workflow support for durable workflows
* fix readme path
* Switch Orchestration output from string to DurableWorkflowResult.
* PR feedback fixes
* Minor cleanup based on PR feedback.
* .NET: [Feature Branch] Add Human In the Loop support for durable workflows (#4358)
* Add Azure Functions HITL workflow sample
Add 06_WorkflowHITL Azure Functions sample demonstrating Human-in-the-Loop
workflow support with HTTP endpoints for status checking and approval responses.
The sample includes:
- ExpenseReimbursement workflow with RequestPort for manager approval
- Custom HTTP endpoint to check workflow status and pending approvals
- Custom HTTP endpoint to send approval responses via RaiseEventAsync
- demo.http file with step-by-step interaction examples
* PR feedback fixes
* Minor comment cleanup
* Minor comment clReverted the `!context.IsReplaying` guards on `PendingEvents.Add`/`RemoveAll` and `SetCustomStatus` in `ExecuteRequestPortAsync`. The guards broke fan-out scenarios where parallel RequestPorts need to be discoverable after replay. `SetCustomStatus` is idempotent metadata that doesn't affect replay determinism.eanup
* fix for PR feedback
* PR feedback updates
* Improvements to samples
* Improvements to README
* Update samples to use parallel request ports.
* Unit tests
* Introduce local variables to improve readability of Workflows.Workflows access patter
* Use GitHub-style callouts and add PowerShell command variants in HITL sample README
* Add changelog entries for durable workflow support (#4436)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Bump Microsoft.DurableTask.Worker to 1.19.1 to fix version downgrade
Microsoft.Azure.Functions.Worker.Extensions.DurableTask 1.13.1 requires
Microsoft.DurableTask.Worker >= 1.19.1 via its transitive dependency on
Microsoft.DurableTask.Worker.Grpc 1.19.1.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix broken markdown links in durable workflow sample READMEs
- Create Workflow/README.md with environment setup docs
- Fix ../README.md -> ../../README.md in ConsoleApps 01, 02, 03, 08
- Fix SubWorkflows relative path (3 levels -> 4 levels up)
- Fix dead Durable Task Scheduler URL
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix build errors from main merge: Throw conflict, ExecuteAsync rename, GetNewSessionAsync rename
- Remove InjectSharedThrow from DurableTask csproj (uses Workflows' internal Throw via InternalsVisibleTo)
- Update ExecuteAsync -> ExecuteCoreAsync with WorkflowTelemetryContext.Disabled
- Update GetNewSessionAsync -> CreateSessionAsync
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Move durable workflow samples to 04-hosting/DurableWorkflows
Aligns with main branch sample reorganization where durable samples
live under 04-hosting/ (alongside DurableAgents/).
- Move samples/Durable/Workflow/ -> samples/04-hosting/DurableWorkflows/
- Add Directory.Build.props matching DurableAgents pattern
- Update slnx project paths
- Update integration test sample paths
- Update README cd paths and cross-references
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix build errors: remove duplicate base class members, update renamed APIs
- Remove duplicate OutputLog, WriteInputAsync, CreateTestTimeoutCts, etc. from
ConsoleAppSamplesValidation (already in SamplesValidationBase)
- Update AddFanInEdge -> AddFanInBarrierEdge in workflow samples
- Update GetNewSessionAsync -> CreateSessionAsync in workflow samples
- Update SourceId -> ExecutorId (obsolete) in workflow samples
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix dotnet format issues: add UTF-8 BOM and remove unused using
- Add UTF-8 BOM to 20 .cs files across DurableTask, AzureFunctions,
unit tests, and workflow samples
- Remove unnecessary using directive in 07_SubWorkflows/Executors.cs
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix typo PaymentProcesser -> PaymentProcessor and garbled arrows in README
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix GetExecutorName to handle agent names with underscores
Split on last underscore instead of first, and validate that the
suffix is a 32-char hex string (sanitized GUID) before stripping it.
This prevents truncation of agent names like 'my_agent' when the
executor ID is 'my_agent_<guid>'.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Align DurableTask.Client.AzureManaged to 1.19.1
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Bump DurableTask and Azure Functions extension package versions
- DurableTask.* packages: 1.19.1 -> 1.22.0
- Functions.Worker.Extensions.DurableTask: 1.13.1 -> 1.16.0
- Functions.Worker.Extensions.DurableTask.AzureManaged: 1.0.1 -> 1.5.0 (telemetry bug fix)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Bump DurableTask SDK packages to 1.22.0
- DurableTask.Client: 1.19.1 -> 1.22.0
- DurableTask.Client.AzureManaged: 1.19.1 -> 1.22.0
- DurableTask.Worker: 1.19.1 -> 1.22.0
- DurableTask.Worker.AzureManaged: 1.19.1 -> 1.22.0
- Azure Functions extensions kept at original versions (1.13.1/1.0.1) due to
host-side DurableTask.Core 3.7.0 incompatibility with newer extensions
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Update Microsoft.Azure.Functions.Worker.Extensions.DurableTask to "1.16.0"
* Add the local.settings.json files to the sample which were previously ignored. This aligns with our other samples.
* Increase timeout for tests as CI has them failing transiently.
* increaset timeout value for azure functions integration tests.
* Add YieldsOutput(string) to workflow shared state sample executors
ValidateOrder and EnrichOrder call YieldOutputAsync with string messages,
but only their TOutput (OrderDetails) was in the allowed yield types.
This caused TargetInvocationException in the WorkflowSharedState sample
validation integration test.
* Downgrade the durable packages to 1.18.0
* Downgrading Worker.Extensions.DurableTask to 1.12.1
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Filter empty AIContent from durable agent state responses
Prevent opaque AIContent objects (e.g., with only RawRepresentation set)
from being stored in durable entity state, where they serialize to empty
JSON payloads. Base AIContent instances are kept only if they have
Annotations or AdditionalProperties.
Fixes https://github.com/microsoft/agent-framework/issues/4481
* Update CHANGELOG.md and fix linter violation
* Fix filter combine logic for ChatHistoryMemoryProvider
* Replace var with explicit types in filter building code and test
Address PR review nit: use explicit types instead of var for better
readability in the filter-building logic and the new combined filter
compilation test.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix style issues
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* bug fix for duplicate output on GitHubCopilotAgent
* Add Test code for bug fix of duplicate output on GitHubCopilotAgenttT
* update Test code for bug fix of duplicate output on GitHubCopilotAgenttT
* update Test for duplicate output of GitHubCopilotAgent
---------
Co-authored-by: Mark Wallace <127216156+markwallace-microsoft@users.noreply.github.com>
Co-authored-by: Dmytro Struk <13853051+dmytrostruk@users.noreply.github.com>
* Update Microsoft.Agents.AI.AzureAI for Azure.AI.Projects SDK 2.0.0
- Bump Azure.AI.Projects to 2.0.0-alpha.20260213.1
- Bump Azure.AI.Projects.OpenAI to 2.0.0-alpha.20260213.1
- Bump System.ClientModel to 1.9.0 (transitive dependency)
- Switch both GetAgent and CreateAgentVersion to protocol methods
with MEAI user-agent policy injection via RequestOptions
- Migrate 29 CREATE-path tests from FakeAgentClient to HttpHandlerAssert
pattern for real HTTP pipeline testing
- Fix StructuredOutputDefinition constructor (BinaryData -> IDictionary)
- Fix responses endpoint path (openai/responses -> /responses)
- Add local-packages NuGet source for pre-release nupkgs
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Update Azure.AI.Projects to 2.0.0-beta.1 from NuGet.org
- Update Azure.AI.Projects and Azure.AI.Projects.OpenAI to 2.0.0-beta.1
- Remove local-packages NuGet source (packages now on nuget.org)
- Fix MemorySearchTool -> MemorySearchPreviewTool rename
- Fix RedTeams.CreateAsync ambiguous call
- Fix CreateAgentVersion/Async signature change (BinaryData -> string)
- Suppress AAIP001 experimental warning for WorkflowAgentDefinition
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Move s_modelWriterOptionsWire field before methods that use it
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix flaky test: prevent spurious workflow_invoke Activity on timeout wake-up
The StreamingRunEventStream run loop uses a 1-second timeout on
WaitForInputAsync. When the timeout fires before the consumer calls
StopAsync, the loop would create a spurious workflow_invoke Activity
even though no actual input was provided. This caused the
WorkflowRunActivity_IsStopped_Streaming_OffThread_MultiTurnAsync test
to intermittently fail (expecting 2 activities but finding 3).
Fix: guard the loop body with a HasUnprocessedMessages check. On
timeout wake-ups with no work, the loop waits again without creating
an activity or changing the run status.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix epoch race condition causing unit tests to hang on net10.0 and net472
The HasUnprocessedMessages guard (previous commit) correctly prevents
spurious workflow_invoke Activity creation on timeout wake-ups, but
exposed a latent race in the epoch-based signal filtering.
The race: when the run loop processes messages quickly and calls
Interlocked.Increment(ref _completionEpoch) before the consumer calls
TakeEventStreamAsync, the consumer reads the already-incremented epoch
and sets myEpoch = epoch + 1. This causes the consumer to skip the
valid InternalHaltSignal (its epoch < myEpoch) and block forever
waiting for a signal that will never arrive (since the guard prevents
spurious signal generation).
Fix: read _completionEpoch without +1. The +1 was originally needed to
filter stale signals from timeout-driven spurious loop iterations, but
those no longer exist thanks to the HasUnprocessedMessages guard.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Revert "Fix epoch race condition causing unit tests to hang on net10.0 and net472"
This reverts commit 6ce7f01be8.
* Revert "Fix flaky test: prevent spurious workflow_invoke Activity on timeout wake-up"
This reverts commit 98963e17f2.
* Skip hanging multi-turn declarative integration tests
The ValidateMultiTurnAsync tests (ConfirmInput.yaml, RequestExternalInput.yaml)
hang indefinitely in CI, blocking the merge queue. The hang is SDK-independent
(reproduces with both Azure.AI.Projects 1.2.0-beta.5 and 2.0.0-beta.1) and
is a pre-existing issue in the declarative workflow multi-turn test logic.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Remove unused using directive in IntegrationTest.cs
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Restore Azure.AI.Projects 2.0.0-beta.1 version bump
The merge from main accidentally reverted the package versions back to
1.2.0-beta.5. This is the primary change of this PR.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Address merge conflict
* Skip flaky WorkflowRunActivity_IsStopped_Streaming_OffThread_MultiTurnAsync test
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Skip CheckSystem test cases temporarily
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Skip tool validation when UseProvidedChatClientAsIs is true (#3855)
When GetAIAgentAsync is called with ChatClientAgentOptions.UseProvidedChatClientAsIs = true,
skip requireInvocableTools validation so users can handle function calls manually
via custom ChatClient middleware without needing to provide matching AIFunction tools.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Simplify requireInvocableTools expression per review feedback
UseProvidedChatClientAsIs is a non-nullable bool, so use ! operator
instead of != true for clarity.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Decouple tool matching from validation and add tool preservation test (#3855)
Always match provided AIFunctions to server-side function definitions
regardless of requireInvocableTools flag. Only throw when validation
is required and no match is found. This ensures UseProvidedChatClientAsIs
still preserves user-provided AIFunction tools instead of falling back
to the broken ResponseToolAITool wrapper.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix Mermaid rendering errors in WorkflowVisualizer.ToMermaidString
Fix two bugs in the Mermaid diagram output:
1. Use safe node aliases (node_0, node_1, ...) instead of raw executor IDs
as Mermaid node identifiers. Raw IDs containing spaces, dots, or
non-ASCII characters (e.g. Japanese) caused Mermaid parse errors.
2. Fix conditional edge arrow syntax from '.--> ' (invalid) to '.-> '
(valid Mermaid dotted arrow syntax).
Fixes#1406
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Use recognizable sanitized IDs for Mermaid node identifiers\n\nReplace generic node_0/node_1 aliases with IDs derived from the original\nexecutor names. ASCII letters, digits, and underscores are preserved;\nother characters become underscores (collapsed, trimmed). Leading digits\nget an n_ prefix. Collisions are resolved with a numeric suffix.\n\nThis keeps node IDs readable in the Mermaid source while the display\nlabels continue to show the full original names."
* Remove issue number references from test names and comments"
* Address PR review feedback from Copilot\n\n- Add Throw.IfNull(id) guard to SanitizeMermaidNodeId\n- Add safety limit (10,000) to collision resolution loop\n- Restore missing edge assertions (middle1/middle2 --> end)\n- Fix comment to show actual sanitized ID (n_1_User_input)\n- Use stricter regex in Unicode test (must start with letter/underscore)"
* Address second round of PR review feedback\n\n- Escape node display labels via EscapeMermaidLabel to handle quotes,\n brackets, and newlines in executor IDs\n- Fix XML doc on SanitizeMermaidNodeId to accurately describe that\n existing consecutive underscores in input are preserved\n- Restore specific edge assertion (mid --> end) in conditional edge test\n- Restore fan-in routing assertions (s1/s2 through intermediate node,\n no direct edges to t) in fan-in test"
---------
Co-authored-by: alliscode <bentho@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix .NET conversation memory in DevUI (#3484)
* formatting fixes
* fix memory regression in python devui , fix for #4123
* Fix for #3983: Added _get_event_type() helper that safely accesses event type on both objects (.type) and dicts (.get("type")). Replaced all 4 bare event.type accesses in _executor.py (lines 267, 477, 499, 523).
Root cause: PR #3690 changed event.__class__.__name__ == "RequestInfoEvent" (safe) to event.type == "request_info" (crashes on dicts), but _execute_workflow still yields raw dicts on error paths.
Test: test_workflow_error_yields_dict_event_without_crash — mocks a workflow that raises, verifies execute_entity consumes the dict error events without crashing.
* format fixes
* lint fixes
* support script execution by code interpretor
* improve the instruction prompt
* Add DefaultAzureCredential production warning to AgentSkills samples
Add the standard three-line WARNING comment about DefaultAzureCredential
production considerations to both AgentSkills sample Program.cs files,
matching the convention used in all other GettingStarted/Agents samples.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* address pr review comments
* address feedback
* rename Skill* types to FileAgentSkill* prefix for consistency
- Rename SkillFrontmatter -> FileAgentSkillFrontmatter
- Rename SkillScriptExecutor -> FileAgentSkillScriptExecutor
- Add FileAgentSkillScriptExecutionContext and FileAgentSkillScriptExecutionDetails
- Update sample, provider, loader, and tests accordingly
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* reorder usings
* use set for props initialization instead of init
* rename HostedCodeInterpreterSkillScriptExecutor
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>