* improve structured output for chat client agent
* add comment to the result property
* remove code duplication and add tests
* refactor the CreateAIAgent extension methods to return specific types, so consumers can avoid unnecessary downcasting.
* fix type and remove unused using.
* add ChatClientAgentRunResponse and move AgentRunResponse to the abstractions package to reuse later.
* seal ChatClientAgentRunResponse
* update xml comment
* remove funcitons from sample
* rename agent for streaming
* Fix bug where ChatClientAgent throws when providing a ChatMessageStore with a service that requries service storage
* Update dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgentTests.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Updates to async run loop.
* fix: Workflow Onwership can be release by nonowner
* fix: Incorrect handling of blockOnPending in StreamingRun
Depending on whether we are running in streaming on non-streaming mode, we may be using the StreamingRun in different ways. Unfortunately, the only place we can really know what is the actual state of execution is in the RunEventStream implementations.
This resulted in blocking where blocking was unneeded and occasionally not-blocking when blocking was needed.
The fix is to move the logic of handling this blocking into RunEventStream implementations.
* fix: Fix cleanup on error and end run
This ensures we clean up the background resources correctly.
* fix: Ensure we let the run loop proceed when shutting down
* fix: Add timeout for Input Waiting
* fix: Make the samples properly clean up `Run`s and `StreamingRun`s
* fix: Simplify Declarative Workflow Run disposal pattern
* Also fixes missing .Disposal() in Integration tests
---------
Co-authored-by: Ben Thomas <ben.thomas@microsoft.com>
Capitalize instruction and relax assertion to accept any non-empty response instead of requiring exact text match. Fixes flaky test failures with reasoning models.
Add optional name and description fields to workflows in both Python and .NET implementations, matching the existing agent API pattern.
Python changes:
- Add name/description parameters to WorkflowBuilder.__init__
- Add name/description attributes to Workflow class
- Include name/description in to_dict() serialization
- Add WORKFLOW_NAME and WORKFLOW_DESCRIPTION OTEL attributes
- Add tests in test_serialization.py and test_workflow_observability.py
.NET changes:
- Add Name and Description properties to Workflow and Workflow<T>
- Add WithName() and WithDescription() fluent methods to WorkflowBuilder
- Add WorkflowName and WorkflowDescription OTEL tags
- Add test in WorkflowBuilderSmokeTests.cs
This enables applications like DevUI to display human-readable workflow names (e.g., 'Data Processing Pipeline') instead of auto-generated UUIDs (e.g., 'Workflow 50fdd917').
Fixes: #1181
* feat: Add support for Workflow-as-Executor
* Fixes routing of 'object' compile-typed variables to properly take in type information
* Fixes a concurrency issue in StepTracer
* fix: Make Subworkflow ExternalRequests work properly
* fix: Threading and Concurrency fixes; prep for OffThread Mode
* refactor: Remove dead code around OffStreamRunEventStream
Currently not used, and will be replaced with a rewrite when brought back, so having it in the change is not valuable.
* ci: Work around issues with dotnet-format not properly analyzing the source
* fix: Fix the logic of AsyncCoordinator and AsyncBarrier
* Prevent individual wait cancellations from canceling the entire barrier
* Propagate information about whether the wait was completed or cancelled, and whether any waiters were present when released
* fix: Remove superfluous acces to .Keys in InProcStepTracer
* refactor: Clean up AsyncCoordinator's use of AsyncBarrier
* Move the AsAIAgent extension methods to the correct class
* Fix format issue
* Disable unit test, see issue #1109
---------
Co-authored-by: Mark Wallace <markwallace@microsoft.com>
* Re-enable ImplicitUsings in samples and clean up NoWarns
* Fix dotnet format
* More dotnet format
* More dotnet format
---------
Co-authored-by: Chris <66376200+crickman@users.noreply.github.com>
We shouldn't be shipping any more dependencies on this package, as it's becoming legacy, replaced by System.Linq.AsyncEnumerable.
We'll eventually want to replace it with System.Linq.AsyncEnumerable in all tests/samples, too, but that's hard to do until SK updates to use S.L.AsyncEnumerable once its 10.0.0 version is released. I did remove the package reference from tests/samples where it's not needed.
* Use copilot to improve XML docs for M.Agents.AI{.Abstractions}
Asked copilot to help improve some of the docs, then I reviewed them.
I also cleaned up a few things along the way, like a couple of extension method types that should be combined.
* Update dotnet/src/Microsoft.Agents.AI.Abstractions/InMemoryChatMessageStore.cs
---------
Co-authored-by: Mark Wallace <127216156+markwallace-microsoft@users.noreply.github.com>
* Adding more test for workflow vizualization.
* Improving README for sample.
* More cleanup.
* Removing rendering of workflow visualization and adding basic support for mermaid format.
* Adding basic mermaid tests.
* Improving sample. Switching to another branch.
* About to merge from main.
* Formatting.
* More fromatting.
* Removng uneeded call to ToUpper.
* Adding README.
* Moving samples under workflow to workflows.
* Removing uneeded README for map-reduce sample.
* Update OpenTelemetryAgent to latest spec
It was stale. Rather than try to keep it up-to-date manually, I've changed it to piggy back on OpenTelemetryChatClient, so that it inherits everything OpenTelemetryChatClient does and then augments it just with agent-specific tags.
* Address feedback / merge
* Make serialize methods sync and rename one to match others.
* Remove unnecessary async postfixes.
* Remove nullability of ChatMessageStore.Serialize return type, since the default JsonElement already represents an undefined json element.
* Fix unit test
* Disallow execution of multiple workflows at once
* Define notion of executor Reset() to allow reuse of workflows with shared executor instances
* Switch to delivering all messages to a single executor sequentially, with executors running in parallel
* Rename AI Agent packages to use Microsoft.Agents.AI
* Fix for build
* Fix formatting
* Fix formatting
* Ignore in VSTHRD200 in migration samples
* Ignore in VSTHRD200 in migration samples
* Add some missing projects and run format
* Fix build errors
* Address code review feedback
* Fix merge issues
---------
Co-authored-by: Mark Wallace <markwallace@microsoft.com>
* feat: Make Executor id field mandatory
When checkpointing is involved, it is critical to keep executor ids consistent between runs, even when recreating a new object tree for the workflow.
The default id-setting mechanism generated a guid for part of the id, making it not work when restoring from a checkpoint.
This change prevents this situation from arising.
* feat: Enable running untyped Workflows
With the change to enable delay-instantiation of executors and support for async Executor factory methods, we must instantiate the starting executor to know what are the valid input types for the workflow.
To avoid forcing instantiation every time, and to better support workflows with multiple input types, we enable support for build and interacting with the base Workflow type without type annotations, and remove the requirement to know a valid input type when initiating a run.
* feat: Support Output from any executor and multiple outputs.
* Add AgentWorkflowBuilder group chat
And fix a variety of issues along the way:
- Use DateTime{Offset}.UtcNow rather than Now
- AIAgentHostExecutor shouldn't be publishing empty messages
- Sequential workflows should be flowing all history and not just the output from the previous agent as the input into the next agent
- Renamed some of the new agent workflow methods... still not super happy with the shape, though
- Simplified handoffs builder, e.g. using a hashset with a custom comparer instead of a dictionary
- Improved multi-service use by trying to change assistant->user role for messages created by other agents
- Changed MessageMerger to rely on M.E.AI's coalescing more and to avoid empty contents / text
- Ensured that messages from ChatClientAgent include MessageId and CreatedAt timestamps
- Avoided including instructions for agents in a handoff workflow that don't have any handoffs
- Removed the unnecessary end function in handoffs
- Improved naming of executors to include agent name for debuggability
- Use "N" formatting with Guid.ToString everywhere, to avoid the unnecessary extra dash character which is also not valid in various places (like function tool names)
- Replace `params T[]` with `params IEnumerable<T>` to make public APIs more flexible in what they consume
* Address feedback
- Fix unintentional provider change in sample