WorkflowsRunning workflows
WORKFLOWS

Running workflows

Execute a registered Flow and inspect its complete RunResult.

Find a definition through FlowCatalog and execute it through IFlowRunner. The result includes overall status and the steps visited.

Add an endpoint

Extend Defining workflows with these imports:

C#
using Runiq.AI.Workflows.Infrastructure;
using Runiq.AI.Workflows.Interfaces;

Map the handler before app.Run():

Snippet
app.MapPost("/summarize", async (
    SummaryRequest request,
    FlowCatalog catalog,
    IFlowRunner runner,
    CancellationToken cancellationToken) =>
{
    if (string.IsNullOrWhiteSpace(request.Text))
        return Results.BadRequest("Text is required.");

    var flow = catalog.FindById("summary-review");
    if (flow is null)
        return Results.NotFound();

    var result = await runner.ExecuteAsync(flow, request.Text, cancellationToken);
    return Results.Ok(result);
});

Place the request type after the top-level statements:

C#
/// <summary>Supplies source text for the workflow.</summary>
public sealed record SummaryRequest(string Text);

This local inspection handler returns full step inputs and outputs. Choose response fields and access policy before exposing it to product users.

Understand the handoff

The first step receives request.Text. After success, its output replaces the input for the next step. Review receives the summary, not the original source plus all prior results.

After a failed step, a failure target receives the input that entered the failed step. Error details are recorded in the result, not automatically appended to the next input.

Read the result

FieldMeaning
StatusOverall completion or failure.
FinalOutputLast successful output on completion.
StepResultsVisited steps, inputs, outputs, status, and tool calls.
ErrorMessageFailure information when available.

A recovered run can be Completed and still contain failed steps. Inspect the step results.

The cancellation token reaches downstream execution. The runner can record execution exceptions as failed steps; do not assume cancellation always propagates as an exception.

Continue with Failure handling.

On this page