.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>
This commit is contained in:
Jacob Alber
2026-02-20 02:05:18 +00:00
committed by GitHub
co-authored by Dmytro Struk
parent 5fd260e11d
commit 0086d38f58
93 changed files with 397 additions and 458 deletions
@@ -22,7 +22,7 @@ namespace Microsoft.Agents.AI.Workflows.InProc;
internal sealed class InProcessRunnerContext : IRunnerContext
{
private int _runEnded;
private readonly string _runId;
private readonly string _sessionId;
private readonly Workflow _workflow;
private readonly object? _previousOwnership;
private bool _ownsWorkflow;
@@ -40,7 +40,7 @@ internal sealed class InProcessRunnerContext : IRunnerContext
public InProcessRunnerContext(
Workflow workflow,
string runId,
string sessionId,
bool checkpointingEnabled,
IEventSink outgoingEvents,
IStepTracer? stepTracer,
@@ -61,7 +61,7 @@ internal sealed class InProcessRunnerContext : IRunnerContext
}
this._workflow = workflow;
this._runId = runId;
this._sessionId = sessionId;
this._edgeMap = new(this, this._workflow, stepTracer);
this._outputFilter = new(workflow);
@@ -94,7 +94,7 @@ internal sealed class InProcessRunnerContext : IRunnerContext
throw new InvalidOperationException($"Executor with ID '{executorId}' is not registered.");
}
Executor executor = await registration.CreateInstanceAsync(this._runId).ConfigureAwait(false);
Executor executor = await registration.CreateInstanceAsync(this._sessionId).ConfigureAwait(false);
executor.AttachRequestContext(this.BindExternalRequestContext(executorId));
await executor.InitializeAsync(this.BindWorkflowContext(executorId), cancellationToken: cancellationToken)
@@ -438,7 +438,7 @@ internal sealed class InProcessRunnerContext : IRunnerContext
{
if (Volatile.Read(ref this._runEnded) == 1)
{
throw new InvalidOperationException($"Workflow run '{this._runId}' has been ended. Please start a new Run or StreamingRun.");
throw new InvalidOperationException($"Workflow run for session '{this._sessionId}' has been ended. Please start a new Run or StreamingRun.");
}
}