Skip to content

.NET: Provide explicit API to convert AIAgent to Executor for workflow composition #1494

Closed

Description

Summary

When building workflows with AI agents, there is no explicit, documented API to convert an AIAgent (e.g., ChatClientAgent) into an Executor for use in workflow graphs. While agents can be added directly to workflows using AddFanOutEdge, there's ambiguity about whether agents can be treated as executors in all contexts, and no way to customize the executor name or description when doing so.

This request is for an explicit conversion API (e.g., .AsExecutor()) that would:

  1. Make the agent-to-executor pattern more discoverable
  2. Allow customization of executor metadata (name, description)
  3. Clarify the mental model of how agents integrate into workflows

Related issue

#1495


Current Behavior

Agents can be used directly in workflows via fan-out edges, but there's no explicit conversion API:

// ✅ This works (implicit conversion)
ChatClientAgent physicist = new ChatClientAgent(
    chatClient,
    name: "Physicist",
    instructions: "You are an expert in physics."
);

var workflow = new WorkflowBuilder(startExecutor)
    .AddFanOutEdge(startExecutor, targets: [physicist, chemist])  // Agents used directly
    .AddFanInEdge(aggregationExecutor, sources: [physicist, chemist])
    .Build();

Issues with current approach:

  1. Discoverability: Not clear that agents can be used as executors
  2. Customization: Cannot override executor name/description independently from agent name
  3. Visualization: Agents show as GUIDs in workflow diagrams (see related issue .NET: Agents used as Executors are displayed as cryptic GUIDs instead of names in workflow visualizations #1495)
  4. Mental model: Unclear if agents ARE executors or are CONVERTED to executors

Expected Behavior

Provide an explicit extension method or API to convert agents to executors with customizable metadata:

// ✅ Explicit conversion with customization
ChatClientAgent physicist = new ChatClientAgent(
    chatClient,
    name: "Physicist",
    instructions: "You are an expert in physics."
);

// Convert agent to executor with custom metadata
ExecutorIsh physicistExecutor = physicist.AsExecutor(
    name: "PhysicistAgent_v1",           // Override display name for workflows
    description: "Physics domain expert"  // Add description for documentation
);

var workflow = new WorkflowBuilder(startExecutor)
    .AddFanOutEdge(startExecutor, targets: [physicistExecutor])
    .AddFanInEdge(aggregationExecutor, sources: [physicistExecutor])
    .Build();

Benefits:

  1. Self-documenting code: Makes intent explicit
  2. Customization: Allows workflow-specific naming without changing agent identity
  3. Better visualizations: Custom names appear in Mermaid/DOT diagrams
  4. Consistency: Similar to .AsAgent() pattern used for workflows

Metadata

Metadata

Labels

.NETUsage: [Issues, PRs], Target: .NetworkflowsUsage: [Issues, PRs], Target: Workflows

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions