Skip to content

WorkflowAgentBinding

Namespace AgentPrism · Assembly AgentPrism.Workflows.dll

Binds catalog agents to a workflow graph defined in code.

public static class WorkflowAgentBinding

objectWorkflowAgentBinding

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Do not put an agent taken from the catalog DIRECTLY into the graph. IAgentCatalog.ResolveAsync returns an agent carrying the run-recording wrapper, but Microsoft Agent Framework calls it with options = null; the wrapper cannot read tree info from the incoming settings and opens its own root row instead. Result: the workflow run looks empty, the agents are independent roots in the list, and the waterfall is drawn wrong. Measured: in the sample app, the tree came back as one row instead of three.

This helper wraps the agent with ChildAgentInvoker. The wrapper reads tree info from the ambient scope, applies the depth/budget/ tenant limits, and attaches the sub-run under the workflow row. For workflows defined from the UI, the compiler does the same wrapping.

agentPrism.AddWorkflow("summarize-and-translate", services =>
AgentWorkflowBuilder.BuildSequential("summarize-and-translate",
[
services.GetWorkflowAgent("summarize-and-translate", "summarizer"),
services.GetWorkflowAgent("summarize-and-translate", "translator"),
]));

GetWorkflowAgent(IServiceProvider, string, string, string?)

Section titled “ GetWorkflowAgent(IServiceProvider, string, string, string?)”

Wraps a catalog agent in a form that can be placed in a workflow graph.

public static AIAgent GetWorkflowAgent(this IServiceProvider services, string workflowName, string agentName, string? description = null)

services IServiceProvider

The service provider.

workflowName string

The name of the enclosing workflow. Appears in error messages.

agentName string

The name of the agent to bind.

description string?

A description of what the agent does. In the GroupChat and Magentic patterns it reaches the participant list sent to the model; leaving it empty makes it harder for the manager agent to know when to call whom.

AIAgent

An agent that can be placed in the graph.

The agent is resolved lazily: this call does not read the catalog, it only builds a wrapper. This way, when an agent definition changes, the compiled workflow does not go stale, and the factory being synchronous causes no problem.

The same instance is returned for the same (workflowName, agentName) pair. This is deliberate: Microsoft Agent Framework derives executor ids from the agent instance’s identity, and returning a new instance on every call would make checkpoints incompatible.

ArgumentNullException

services is null.

ArgumentException

One of the names is empty.