Class WorkflowGenerator
Generates structured workflow definitions from natural language descriptions. Uses a prompt-based approach: the description is analyzed and decomposed into steps with tool mappings, parameters, and control flow.
public sealed class WorkflowGenerator
- Inheritance
-
WorkflowGenerator
- Inherited Members
Methods
Compose(string, IReadOnlyList<AgentWorkflowDefinition>)
Composes multiple workflows into a single composite workflow. Steps from each child workflow become nested steps in the composite.
public AgentWorkflowDefinition Compose(string name, IReadOnlyList<AgentWorkflowDefinition> workflows)
Parameters
namestringworkflowsIReadOnlyList<AgentWorkflowDefinition>
Returns
DeriveToolStepName(string)
public static string DeriveToolStepName(string tool)
Parameters
toolstring
Returns
DryRun(AgentWorkflowDefinition, IReadOnlySet<string>?)
Generates a dry-run preview of a workflow without executing. Shows what each step would do, required tools, and validation.
public WorkflowDryRunResult DryRun(AgentWorkflowDefinition workflow, IReadOnlySet<string>? availableTools = null)
Parameters
workflowAgentWorkflowDefinitionavailableToolsIReadOnlySet<string>
Returns
ExtractFromHistory(IReadOnlyList<ChatMessageContent>, int, string?)
Extracts a workflow definition from conversation history by analyzing the tool calls and user/assistant interactions from the last N turns.
public AgentWorkflowDefinition ExtractFromHistory(IReadOnlyList<ChatMessageContent> messages, int turnCount = 10, string? name = null)
Parameters
messagesIReadOnlyList<ChatMessageContent>turnCountintnamestring
Returns
FormatDryRun(WorkflowDryRunResult)
Formats a dry-run result for display.
public static string FormatDryRun(WorkflowDryRunResult result)
Parameters
resultWorkflowDryRunResult
Returns
Generate(string, string?)
Generates a workflow definition from a natural language description. This is a deterministic fallback that parses common patterns; for AI-powered generation, the agent loop itself generates the workflow and calls SaveAsync on the catalog.
public AgentWorkflowDefinition Generate(string description, string? name = null)
Parameters
Returns
GenerateAsync(string, Kernel, string?, IReadOnlySet<string>?, CancellationToken)
Generates a workflow from a natural language description using LLM. Falls back to heuristic generation if LLM fails.
public Task<WorkflowRefinementResult> GenerateAsync(string description, Kernel kernel, string? name = null, IReadOnlySet<string>? availableTools = null, CancellationToken ct = default)
Parameters
descriptionstringkernelKernelnamestringavailableToolsIReadOnlySet<string>ctCancellationToken
Returns
RefineAsync(AgentWorkflowDefinition, string, Kernel, CancellationToken)
Refines an existing workflow using AI-powered analysis. Applies the user's natural language feedback to add, remove, reorder, or modify steps. Returns a new version of the workflow with the refinements applied.
public Task<WorkflowRefinementResult> RefineAsync(AgentWorkflowDefinition workflow, string feedback, Kernel kernel, CancellationToken ct = default)
Parameters
workflowAgentWorkflowDefinitionfeedbackstringkernelKernelctCancellationToken