Commit Graph

38 Commits

  • .NET: fix: Add session support for Handoff-hosted Agents (#5280)
    * fix: Add session support for Handoff-hosted Agents
    
    In order to better support using `Workflows` hosted as `AIAgents` inside of Handoff workflows, we need to make proper use of AgentSession. This causes potential issues around checkpointing and making sure that we properly compute only the new incoming messages for each agent invocation.
    
    * fix: AgentSession checkpointing using AIAgent's Serialize/Deserialize methods
    
    We cannot rely on implicit serialization through `HandoffHostState` because we are missing type information.
    
    * fix: Thread safety issue in `MultiPartyConversation.AllMessages`
    
    * fix: Enable unwrapping of FunctionResultContent when ExternalRequest was wrapped into FunctionCallContent
  • .NET: feat: Implement return-to-previous routing in handoff workflow (#4356)
    * feat: Implement return-to-previous routing in handoff workflow
    
    - Also obsoletes HandoffsWorkflowBuilder => HandoffWorkflowBuilder (no "s")
    
    * refactor: Remove instance-shared current agent tracking in handoffs
    
    Because the tracker was instance-shared between the start and end executors, it would be shared between all sessions, resulting in incorrect behaviour.
    
    The corect way to do this is to keep the data in a shared executor scope, which is per-session.
    
    * fix: Fix test logic for Handoff to correctly use checkpointing for multiturn
  • .NET: [BREAKING] Workflows API Review Naming Changes (Part 1?) (#4090)
    * refactor: Normalize Run/RunStreaming with AIAgent
    
    * refactor: Clarify Session vs. Run -level concepts
    
    * Rename RunId to SessionId to better match Run/Session terminology in AIAgent
    * [BREAKING]: Will break existing checkpointed sessions in CosmosDb due to field rename
    
    * refactor: Rename and simplify interface around getting typed data out of ExternalRequest/Response
    
    * Also adds hints around using value types in PortableValue
    
    * refactor: Rename AddFanInEdge to AddFanInBarrierEdge
    
    This will prevent a breaking change later when we introduce a programmable FanIn edge, analogous to the FanOut edge's EdgeSelector.
    
    The goal, in the long run is to support a number of different FanIn scenarios, with naive FanIn (no barrier) by default, similar to FanOut.
    
    * refactor: AsAgent(this Workflow, ...) => AsAIAgent(...)
    
    * misc - part1: SwitchBuilder internal
    
    ---------
    
    Co-authored-by: Dmytro Struk <13853051+dmytrostruk@users.noreply.github.com>
  • [BREAKING] .NET: Decouple Checkpointing from Run/StreamAsync APIs (#4037)
    * [BREAKING] refactor: Decouple Checkpointing and Execution APIs
    
    With this change, Checkpointing becomes an property of an IWorkflowExecutionEnvironment. This lets environments that are tightly-coupled to their CheckpointManager avoid needing to present APIs that would not work (e.g. taking in an InMemory CheckpointManager for Durable Tasks, for example)
    
    * refactor: Normalize IsCheckpointingEnabled naming
  • .NET: [BREAKING] Implement Polymorphic Routing (#3792)
    * feat: Implement Polymorphic Routing
    
    * feat: Add support for Send/Yield annotations with basic Executor
    
    * Adds annotations to Declarative workflow executors
    
    * fix: Address PR Comments
    
    * Implicit filter in collection loops
    * Remove debug / usused / superfluous code
    * Fix ProtocolBuilder implicit output registrations
    * Fix logic error in ExecuteRouteGeneratorTests.ClassWithManualConfigureProtocol_DoesNotGenerate
    
    * fix: Solidify type checks and send/yield type registrations
    
    * fix: Suppress generation of TurnTokens out of AggregateTurnMessagesExecutor
    
    * Fixes an issue where ConcurrentEndExecutor is not expecting TurnTokens.
    
    * fix: Add ProtocolBuilder support for chained-delegation
    
    * Updates Declarative pacakge to rely on chained-delegation Send/Yield registration
    * Renames DeclarativeActionExectuor's new ExecuteAsync to ExecuteActionAsync to avoid colliding with Executor.ExecutoeAsync
    
    * fix: Address PR Comments
    
    * Fixes type mapping in FanInEdgeRunner
    * Fixes and expalins send/yield type registration in FunctionExecutor
    
    * fixup: build-break
    
    * fix: Add missing SendsMesage declaration to InvokeAzureAgentExecutor
  • .NET: BREAKING: Unify AgentResponse[Update] events as WorkflowOutputEvents (#3441)
    * Rename WorkflowOutputEvent.SourceId to ExecutorId for Python consistency
    
    - Rename SourceId property to ExecutorId in WorkflowOutputEvent
    - Add [Obsolete] SourceId property for backward compatibility
    - Update all test usages to use ExecutorId
    
    Resolves part of #2938
    
    * Unify AgentResponse events with WorkflowOutputEvent (#2938)
    
    - Change AgentResponseEvent and AgentResponseUpdateEvent to inherit from
      WorkflowOutputEvent instead of ExecutorEvent
    - Update AIAgentHostExecutor and HandoffAgentExecutor to use YieldOutputAsync()
      instead of AddEventAsync() for agent outputs
    - Add special-casing in InProcessRunnerContext.YieldOutputAsync() to create
      specific event types for AgentResponse and AgentResponseUpdate, bypassing
      OutputFilter for backwards compatibility
    - Update TestRunContext and TestWorkflowContext with same special-casing
    - Add regression tests in AgentEventsTests
    
    * refactor: Seal AgentResponse events
  • .NET: [BREAKING] Add session StateBag for state storage and support multiple providers on the Agent (#3806)
    * .NET: [BREAKING] Add session statebag to use for state storage instead of inside providers (#3737)
    
    * Add a StateBag to AgentSession and pass Agent and AgentSession to AIContextProvider and ChatHistoryProviders
    
    * Convert all AIContextProviders to use the statebag
    
    * Update InMemoryChatHistoryProvider to use StateBag
    
    * Update Comsos and Workflow ChatHistoryProviders
    
    * Update 3rd party chat history storage sample.
    
    * Remove serialize method from providers
    
    * Replacing provider factories with properties
    
    * Remove Providers from Session and flatten state bag serialization
    
    * Update samples to use getservice on agent
    
    * Updated additional session types to serialize statebag
    
    * Fix regression
    
    * Address PR comments
    
    * Address PR comments.
    
    * Fix formatting
    
    * Fix unit tests
    
    * Remove InMemoryAgentSession since it is not required anymore.
    
    * Address PR comments
    
    * Convert sessions for A2AAgent, ChatClientAgent, CopilotStudioAgent and GithubCopilotAgent to use regular json serialization.
    
    * Fix durable agent session jso usgae
    
    * Add jso to InMemory and Workflow ChatHistoryProviders
    
    * Update InMemoryChatHistoryProvider to use an options class for it's many optional settings.
    
    * Apply suggestions from code review
    
    Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
    
    * Address PR feedback
    
    * Fix verification bug.
    
    * Improve state bag thread safety
    
    * Address PR comments and fix unit tests
    
    * Address PR comments
    
    * Fix unit test
    
    ---------
    
    Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
    
    * Add a public StateKey property to providers (#3810)
    
    * .NET: [BREAKING] Update providers in such a way that they can participate in a pipeline (#3846)
    
    * Make providers pipeline capable
    
    * Fix unit tests
    
    * Move source stamping to providers from base class
    
    * Also update samples.
    
    * Address PR comments
    
    * Rename AsAgentRequestMessageSourcedMessage to WithAgentRequestMessageSource
    
    * .NET: [BREAKING] Add consistent message filtering to all providers. (#3851)
    
    * Add consistent message filtering to all providers.
    
    * Remove old chat history filtering classes
    
    * Fix merge issues
    
    * Fix unit test
    
    * Enforce non-nullable property
    
    * Fix merging bug and make troubleshooting source info easier by adding tostring implementation
    
    * .NET: [BREAKING] Add support for multiple AIContextProviders on a ChatClientAgent (#3863)
    
    * Add support for multiple AIContextProviders on a ChatClientAgent
    
    * Address PR comments and fix tests
    
    * Address PR comments.
    
    * .NET: [BREAKING]Delay AIContext Materialization until the end of the pipeline is reached. (#3883)
    
    * Delay AIContext Materialization until the end of the pipeline is reached.
    
    * Address PR comments.
    
    * Address PR comments
    
    * Modify InvokedContext to be immutable (#3888)
    
    * .NET: Address Feedback on StateBag feature branch PR (#3910)
    
    * Address Feedback on statebag feature branch PR
    
    * Update dotnet/src/Microsoft.Agents.AI.DurableTask/CHANGELOG.md
    
    Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
    
    * Address PR comments
    
    ---------
    
    Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
    
    ---------
    
    Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
  • .NET: [BREAKING] Change SerializeSession to be Async (#3879)
    * Change SerializeSession to be Async
    
    * Update Changelog
  • .NET: Introduce Core implementation methods for session methods on AIAgent (#3699)
    * Introduce Core implementation methods for session methods on AIAgent
    
    * Update changelog
  • [BREAKING] Obsoleting ReflectingExecutor in favor of source gen (#3380)
    * Initial working version with tests.
    
    * Updates to validate class data once instead of for each handler method. Also updated Diagnostics Ids to format of MAFGENWF{NUM}
    
    * Formatting and trying to fix generation project pack.
    
    * Another atempt at getting the genrators project to build.
    
    * More attempts to fix generator build and pack.
    
    * Fixing file encodings.
    
    * Initail round of cleanup.
    
    * Trying to fix packing.
    
    * Still trying to fix pipeline pack.
    
    * Remove obsolescence markers, sample updates, and docs from generator branch.
    
    This commit separates the generator core functionality from the
    deprecation of ReflectingExecutor. The removed changes will be
    re-added in a dependent branch (wf-obsolete-reflector).
    
    🤖 Generated with [Claude Code](https://claude.com/claude-code)
    
    Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
    
    * Mark ReflectingExecutor and IMessageHandler as obsolete.
    
    This commit deprecates the reflection-based handler discovery approach
    in favor of the new [MessageHandler] attribute with source generation.
    
    Changes:
    - Add [Obsolete] to ReflectingExecutor<T>, IMessageHandler<T>, IMessageHandler<T,R>
    - Add #pragma to suppress warnings in internal reflection code
    - Update Concurrent sample to use new [MessageHandler] pattern
    - Add Directory.Build.props for samples to include generator
    - Add documentation files explaining the migration
    
    🤖 Generated with [Claude Code](https://claude.com/claude-code)
    
    Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
    
    * Obsoleteing Reflector-based workflow code generation in favor of Source Generators and updating some samples to use new pattern.
    
    This commit deprecates the reflection-based handler discovery approach
    in favor of the new [MessageHandler] attribute with source generation.
    
    Changes:
    - Add [Obsolete] to ReflectingExecutor<T>, IMessageHandler<T>, IMessageHandler<T,R>
    - Add #pragma to suppress warnings in internal reflection code
    - Update Concurrent sample to use new [MessageHandler] pattern
    - Add Directory.Build.props for samples to include generator
    - Add documentation files explaining the migration
    
    🤖 Generated with [Claude Code](https://claude.com/claude-code)
    
    Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
    
    * Cleaning up temporary design and progress files.
    
    ---------
    
    Co-authored-by: alliscode <bentho@microsoft.com>
    Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
    Co-authored-by: Chris <66376200+crickman@users.noreply.github.com>
  • .NET: [BREAKING] Rename session state json param (#3681)
    * Rename session state json param to ensure consistency
    
    * Fix merge failures and PR comments.
  • .NET: [BREAKING] Move AgentSession.Serialize to AIAgent (#3650)
    * Move AgentSession.Serialize to AIAgent
    
    * Address PR comments.
    
    * Improve code and fix unit test
    
    * Update test agents to return a default json element instead of throwing where the the result of the serialization is never used.
    
    * Update further tests to actually serialize the session
  • .NET: [BREAKING] Rename GetNewSession to CreateSession (#3501)
    * Rename GetNewSession to CreateSession
    
    * Address copilot feedback
    
    * Suppress warning
    
    * Suppress warning
    
    * Fix further warnings.
  • .NET: Add tests for subworkflow shared state behavior (#3444)
    Adds tests documenting current shared state behavior in subworkflows:
    
    - State works correctly within a subworkflow
    
    - State is isolated across parent/subworkflow boundaries
    
    Related to #2419
  • .NET: [BREAKING] Rename AgentThread to AgentSession (#3430)
    * Rename AgentThread to AgentSession
    
    * Add more renames
    
    * Update readme files
    
    * Revert nullable variable change and further fixes.
    
    * Revert change in header name
    
    * Fix some comments and tests
    
    * Update changelog.
    
    * Address PR feedback.
    
    * Fixing code review comments.
    
    * Fix new errors after merging latest code.
  • fix: Subworkflows do not work well with HostAsAgent (#3240)
    Subworkflows run into issues with Checkpointing and the Chat Protocol:
    
    * The concurrency rework made subtle changes in behaviour that introduced a hang when using subworkflows with ChatProtocol and streaming execution.
    * The ResetAsync() implementation in WorkflowHostExecutor was improperly resetting the joinContext - this was happening on restore checkpoint _after_ the join context was attached when
    * Subworkflows cannot be used as the start node when hosted AsAgent due to inability to treat Catch-All as a Chat Protocol
    * Subworkflow ownership issue when used in non-concurrent mode after finishing a run
    
    Also fixes:
    * When ChatMessages are output by executors that are not agents, there is no corresponding AgentResponseUpdate/AgentResponse event
    
    Breaking Changes
    * [BREAKING CHANGE] It is possible to provide the wrong RunId when resuming from CheckpointInfo (even though the data already exists on CheckpointInfo)
  • .NET: [Breaking] Rename AgentRunResponseEvent and AgentRunUpdateEvent classes (#3214)
    * rename AgentRunResponseEvent and AgentRunUpdateEvent classes
    
    * rollback unnecessary changes
  • .NET: [Breaking] RenameAgentRunResponse and AgentRunResponseUpdate classes (#3197)
    * rename AgentRunResponse and AgentRunResponseUpdate classes - part1
    
    * rename varialbles, parameters, methods and tests
    
    * rollback unnecessary changes
  • .NET: [BREAKING] Change GetNewThread and DeserializeThread to async (#3152)
    * Change GetNewThread and DeserializeThread plus ChatMessageStore and AIContextProvider Factories to async
    
    * Merge fixes
  • .NET: [Breaking] Introduce RunCoreAsync/RunCoreStreamingAsync delegation pattern in AIAgent (#2749)
    * Initial plan
    
    * Refactor AIAgent: Make RunAsync and RunStreamingAsync non-abstract, add RunCoreAsync and RunCoreStreamingAsync
    
    Co-authored-by: SergeyMenshykh <68852919+SergeyMenshykh@users.noreply.github.com>
    
    * Fix infinite recursion in test implementations
    
    Co-authored-by: SergeyMenshykh <68852919+SergeyMenshykh@users.noreply.github.com>
    
    * Make RunAsync and RunStreamingAsync non-virtual as requested
    
    Co-authored-by: SergeyMenshykh <68852919+SergeyMenshykh@users.noreply.github.com>
    
    * Fix DelegatingAIAgent subclasses to use RunCoreAsync/RunCoreStreamingAsync
    
    Co-authored-by: SergeyMenshykh <68852919+SergeyMenshykh@users.noreply.github.com>
    
    * Fix XML documentation references in AnonymousDelegatingAIAgent
    
    Co-authored-by: SergeyMenshykh <68852919+SergeyMenshykh@users.noreply.github.com>
    
    * Restore <see cref> tags with proper qualified signatures in AnonymousDelegatingAIAgent
    
    Co-authored-by: SergeyMenshykh <68852919+SergeyMenshykh@users.noreply.github.com>
    
    * Rollback unnecessary XML documentation changes in AnonymousDelegatingAIAgent
    
    Co-authored-by: SergeyMenshykh <68852919+SergeyMenshykh@users.noreply.github.com>
    
    * Remove pragma and update crefs to RunCoreAsync/RunCoreStreamingAsync
    
    Co-authored-by: SergeyMenshykh <68852919+SergeyMenshykh@users.noreply.github.com>
    
    * Fix EntityAgentWrapper to call base.RunCoreAsync/RunCoreStreamingAsync
    
    Co-authored-by: SergeyMenshykh <68852919+SergeyMenshykh@users.noreply.github.com>
    
    * fix compilation issues
    
    * fix compilatio issue
    
    * fix tests
    
    * fix unit tests
    
    * fix unit test
    
    ---------
    
    Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
    Co-authored-by: SergeyMenshykh <68852919+SergeyMenshykh@users.noreply.github.com>
    Co-authored-by: SergeyMenshykh <sergemenshikh@gmail.com>
    Co-authored-by: Chris <66376200+crickman@users.noreply.github.com>
  • .NET: [Breaking] Delete display name property (#2758)
    * delete the AIAgent.DisplayName property
    
    * use agent name as a first value for activity display name
    
    * Update dotnet/src/Microsoft.Agents.AI.Workflows/Specialized/HandoffAgentExecutor.cs
    
    Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
    
    ---------
    
    Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
  • .NET: [BREAKING] Prevent nulls in AIAgent property (#2719)
    * prevent nulls in AIAgent property
    
    * address feedback
  • .NET: Change type of props representing continuation token (#2430)
    * change type of props representing continuation token
    
    * use explict cast instead of the as operator
  • .NET: Upgrade to .NET 10 (#2128)
    * Upgrade to .NET 10
    
    - Require .NET 10 SDK
    - Include net10.0 assets in all assemblies
    - Move net9.0-only targets to net10.0
    - Update LangVersion to latest
    - Remove complicated distinctions between debug target TFMs and release target TFMs
    - Remove unnecessary package dependencies when built into netcoreapp
    - Clean up some ifdefs
    - Clean up some analyzer warnings
    
    * Fix CI
  • .NET: [BREAKING] refactor: Normalize WorkflowBuilder APIs (#1935)
    * [BREAKING] refactor: Normalize WorkflowBuilder APIs
    
    * "partitioner" => "assigner"
    * normalize ordering so sources always to the left of targets for edges
    * normalize parameter ordering so sources and targets are always first arguments
    * remove `params` (users should use collection expressions instead)
    
    * refactor: Align name with Python
  • .NET: Improve fidelity of OpenAI Responses server and add Conversations (#1907)
    * Improve fidelity of OpenAI Responses server and add Conversations
    
    * Merge
    
    * nit
    
    * Undo prior change
    
    * Undo prior change
    
    * Review feedback
    
    * Review feedback
    
    * Fix test
    
    * Use simpler JsonDocument approach for polymorphic deserialization
    
    * More review feedback
    
    * dotnet format
  • .NET: [BREAKING] Unify ExecutorIsh and ExecutorRegistration, unify/simplify APIs (#1637)
    * refactor: Unify ExecutorIsh and ExecutorRegistration => ExecutorBinding
    
    * Switch to more modern Record type-tree for Sum Types
    * Unify APIs for getting ExecutorBinding
    * Fix an issue where workflows consisting entirely of cross-run shareable executors which are not instance-resettable do not properly clear state when running non-concurrently.
    
    * feat: Simplify function-to-executor pattern
    
    * refactor: Normalize API naming
  • fix: .NET: Concurrency Support for Orchestrations (#1689)
    Concurrent run support was recently added to workflows, but Orchestrations did not fully update to support it. A few executors were missing Cross-Run Shareable annotations, and the ConcurrentEnd executor needed to be factory-instantiated.
    
    This also ports the fix for #1613 from #1637, to avoid waiting on that PR.
  • refactor: [BREAKING] Remove generic Workflow<T> (#1551)
    Remove input type checking in favour of explicit `.DescribeProtocolAsync()` flow. Also removes `.AsAgentAsync()` as the validation happens at workflow run time. This makes it easier to use Workflows with DI without resorting to async-over-sync.
  • .NET: [BREAKING] Enable sharing of workflow instances across concurrently executing runs (#1464)
    * refactor: remove unused internals
    
    * feat: Execution Mode for sharing a workflow among concurrent runs
    
    * feat: Update WorkflowHostAgent to support concurrent execution
    
    * Also update AsAgent APIs to support injecting a CheckpointManager and an IWorkflowExecutionEnvironment
    
    * fix: Make Read logic consistent in DeclarativeWorkflowContext
  • .NET: [BREAKING] Propagate CancellationToken into Workflow Executors and message handlers (#1280)
    * feat: Propagate CancellationToken to Executors
    
    * Also adds cancellation propagation to `Executor`-accessible APIs
    * Adds registrators for cancellable handlers to `RouteBuilder`
    * [BREAKING]: Adds `CancellationToken` to `IMessageHandler.HandleAsync`
    
    * test: Re-enable Concurrent Orchestration test
    
    * refactor: Delete unused IInputCoordinator
    
    * refactor: Remove superfluous argument qualifications
  • [BREAKING] .NET: Workflow Off-Thread Execution Mode (#1233)
    * 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>
  • .NET: Add support for Subworkflows and many threading fixes (#1066)
    * 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
  • .NET: Fix some more static analysis diagnostics (#1025)
    * S1006
    
    * S2219
    
    * S3236
    
    * S3260
    
    * S1125
    
    * IDE0063
    
    * IDE0062
    
    * IDE0028
  • .NET: Clean up some CancellationToken usage (#996)
    * Clean up some CancellationToken usage
    
    * Unused usings
  • .NET: Clean up stale mentions of M.E.AI.Agents (#997)
    * Clean up stale mentions of M.E.AI.Agents
    
    * Unused usings
  • .NET: Rename workflows projects (#975)
    * Renaming Microsoft.Agent.Workflows to Microsoft.Agents.AI.Workflows
    
    * Removing local settings.
    
    * Removing remining old files from merge.