Table of Contents

Class WorkflowDefinition

Namespace
LMKit.Agents.Workflows
Assembly
LM-Kit.NET.dll

A workflow as data: steps that run agents and tools, branch on conditions, run in parallel, loop, wait for a person's approval or hand the work to a person. It is plain JSON, so it is stored, versioned, exported and edited like an agent definition, and WorkflowOrchestrator runs and resumes it.

public sealed class WorkflowDefinition
Inheritance
WorkflowDefinition
Inherited Members

Examples

{
  "schema_version": 1,
  "name": "support-triage",
  "steps": [
    { "id": "classify", "type": "agent", "agent": "classifier", "input": "{{input}}" },
    { "id": "route", "type": "condition",
      "branches": [ { "when": "contains(steps.classify.output, 'refund')",
                      "steps": [ { "id": "refund", "type": "agent", "agent": "refunds" } ] } ],
      "else": [ { "id": "answer", "type": "agent", "agent": "support" } ] }
  ]
}

Fields

CurrentSchemaVersion

The schema version this library writes and the newest it reads.

Properties

Description

Gets or sets what the workflow does, for people.

InputSchema

Gets or sets the JSON Schema the run's input meets, or null for free text. With a schema the input is a JSON document, checked before any step runs (CheckInput(string)); its fields read as input.<field>.

Manifest

Gets or sets what the published revision runs against (WorkflowManifest): the revisions of the agents and child workflows its steps name, recorded by the host when it publishes; null for a draft, whose steps resolve the current ones.

Name

Gets or sets the workflow's name.

Output

Gets or sets the workflow's answer (a template); empty for the last step's output.

OutputSchema

Gets or sets the JSON Schema the workflow's answer meets, or null; a run whose answer does not fails.

Revision

Gets or sets the revision the host published this workflow as; 0 when the host keeps no revisions. Informational: the workflow runs the same whatever it says.

SchemaVersion

Gets or sets the schema version the workflow is written in.

Steps

Gets or sets the steps, run in order.

Methods

Advise()

Advice on the workflow that blocks nothing: agent steps that run their agent's live revision (UnpinnedRevision), which a later publication of the agent changes under runs already started.

AllSteps()

Every step of the workflow, nested ones included, in document order.

CheckInput(string)

Every way input breaks InputSchema, located; empty when it meets it or there is no schema. A host refuses such a run before it starts; a run started on it anyway fails before its first step.

Diagnose(Func<string, bool>, Func<string, bool>)

The same faults as Validate(Func<string, bool>, Func<string, bool>), each located: the step and the field it is about, and whether the workflow is written wrong (Invalid), not finished (Incomplete) or names an agent or a tool the host lacks, or reads a step that cannot have run before the read (Unreachable). An editor shows each fault on its step; a host can keep an unfinished workflow as a draft while refusing to run it.

Diagnose(Func<string, bool>, Func<string, bool>, Func<string, bool>)

The faults of Diagnose(Func<string, bool>, Func<string, bool>), plus every tool step inside a parallel branch whose tool the host holds for a person's approval (ApprovalInParallel): a parallel branch cannot stop, so such a workflow is refused before it runs rather than failing at the call.

Diagnose(Func<string, bool>, Func<string, bool>, Func<string, bool>, Func<string, string>)

The faults of Diagnose(Func<string, bool>, Func<string, bool>, Func<string, bool>), plus every tool step whose arguments do not meet the tool's own input schema (ArgumentMismatch): a required argument missing, an argument the tool does not take, a fixed value of the wrong type. Templated values are checked when they run.

Diagnose(Func<string, bool>, Func<string, bool>, Func<string, bool>, Func<string, string>, Func<string, int?, WorkflowDefinition>)

The faults of Diagnose(Func<string, bool>, Func<string, bool>, Func<string, bool>, Func<string, string>), plus every workflow step whose workflow the host does not provide (MissingWorkflow), that makes workflows run each other in a circle or nest too deep (WorkflowCycle), or whose workflow can stop for a person where nothing can stop (inside a parallel branch or items running at once).

FromJson(string)

Reads a workflow from its JSON form.

ToJson()

Writes the workflow as JSON.

Validate(Func<string, bool>, Func<string, bool>)

Why the workflow cannot run, every reason at once; empty when it can. Unknown step types, missing fields, unreadable conditions and templates, timeouts, retries and error handlers out of bounds or on steps that take none, references to steps that do not exist, duplicate ids, reads of a step that cannot have run yet, and (when the host says what it has) agents and tools it does not provide are each named.

Share