Skip to contents

Connects two nodes. With when = NULL the edge is unconditional; with a predicate when = function(state) -> logical it is taken only when the predicate returns TRUE (a FALSE, an NA, or any other value leaves the edge untaken). After a node, the runtime takes the first outgoing edge, in the order the edges were added, whose predicate holds or that is unconditional. A back-edge forms a loop, bounded by max_steps in run_workflow().

Usage

add_edge(wf, from, to, when = NULL)

Arguments

wf

An agent_workflow.

from, to

Node names.

when

Optional function(state) -> logical.

Value

The workflow, with the edge added.

Details

A predicate that raises an error ends the run with status "failed"; the error, naming the edge, is returned in the run's error field and recorded in its event log, and no later edge is tried. resume_workflow() retries the edge selection after the predicate has been repaired.