Table of Contents

Class WorkflowGenerator

Namespace
JD.AI.Workflows
Assembly
JD.AI.Workflows.dll

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

name string
workflows IReadOnlyList<AgentWorkflowDefinition>

Returns

AgentWorkflowDefinition

DeriveToolStepName(string)

public static string DeriveToolStepName(string tool)

Parameters

tool string

Returns

string

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

workflow AgentWorkflowDefinition
availableTools IReadOnlySet<string>

Returns

WorkflowDryRunResult

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

messages IReadOnlyList<ChatMessageContent>
turnCount int
name string

Returns

AgentWorkflowDefinition

FormatDryRun(WorkflowDryRunResult)

Formats a dry-run result for display.

public static string FormatDryRun(WorkflowDryRunResult result)

Parameters

result WorkflowDryRunResult

Returns

string

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

description string
name string

Returns

AgentWorkflowDefinition

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

description string
kernel Kernel
name string
availableTools IReadOnlySet<string>
ct CancellationToken

Returns

Task<WorkflowRefinementResult>

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

workflow AgentWorkflowDefinition
feedback string
kernel Kernel
ct CancellationToken

Returns

Task<WorkflowRefinementResult>