Skip to content

Workflow Concepts

A Workflow in LenserFight is a directed acyclic graph (DAG) of Lens invocations connected by typed edges. Each node in the graph is one Lens call. Edges carry the output of one Lens into the input of another.

Workflows let you compose simple Lenses into powerful, multi-step pipelines without writing application code.

Core building blocks

ConceptWhat it is
LensA versioned prompt template with typed input and output contracts
NodeA single Lens invocation inside a Workflow, with its own config overrides
EdgeA connection from a source node's output key to a target node's parameter
RunOne execution of a Workflow with a specific set of root inputs
Node ResultThe output, status, and timing of a single node within a run
Artifact (Ray)A durable output produced by a Lens run, stored in the media layer

The DAG model

Workflows are DAGs — directed and acyclic. This means:

  • Directed: data flows in one direction (no feedback loops)
  • Acyclic: no node can appear on a path that leads back to itself

The engine enforces acyclicity at save time. Any edit that would introduce a cycle is rejected.

In this example, nodes B and C both depend on A and can run in parallel. Node D depends on both B and C and runs after both complete.

Nodes

A node wraps a specific Lens version and adds:

  • Config overrides — temperature, timeout, retry policy, moderation settings
  • Failure policy — how to handle an upstream failure (skip, propagate, substitute_default)
  • Merge strategy — how to combine multiple incoming edges for the same parameter
bash
# Add a node to an existing workflow
lf workflow node add <workflow-slug> \
  --lens my-research-lens \
  --version latest

# Update a node's config
lf workflow node update <workflow-slug> <node-id> \
  --timeout 60000 \
  --retry-attempts 3

Edges

An edge maps a source output key to a target parameter label. The engine uses this mapping to thread data through the DAG.

Edge fieldMeaning
source_node_idWhich node produces the value
source_output_keyWhich key in that node's output envelope to read
target_node_idWhich node receives the value
target_param_labelWhich parameter slot on the target lens to fill
merge_strategyWhat to do if multiple edges target the same parameter
bash
# Connect two nodes
lf workflow edge add <workflow-slug> \
  --from <source-node-id>:output \
  --to <target-node-id>:input_text

Root inputs and parameters

When you run a Workflow, you provide root inputs — values for parameters that have no incoming edges. These act as the starting data for the pipeline.

Each Lens node can declare parameters that must be satisfied either by:

  1. An incoming edge from an upstream node
  2. A root input provided at run time
  3. A default value defined in the Lens version

Runs and results

A run is one execution of a Workflow. It has:

  • A status: pending, running, completed, failed, cancelled
  • An idempotency_key derived from (workflow_id, rootInputsHash) — duplicate runs with identical inputs are deduplicated
  • A budget envelope that caps token and compute spend

Runs produce node results — one per node, storing the output envelope, status, token usage, and timing. Node results are also the source for Artifacts (Rays) — durable media objects stored in the platform.

Execution order: topological waves

The engine executes nodes in topological waves:

  1. Find all nodes with zero unmet dependencies → Wave 1
  2. Execute Wave 1 nodes in parallel (Promise.all)
  3. Mark their dependents' in-degrees as satisfied
  4. Repeat until all nodes are done or a failure stops the run

This means independent branches always run in parallel. Dependent nodes wait for all their inputs.

Failure policies

Each node declares how it behaves when an upstream node fails:

PolicyWhat happens
skip (default)Node is skipped; downstream nodes inherit the skip
propagateNode is marked failed with error_message: "upstream_failure"
substitute_defaultMissing values are replaced with empty string (legacy)