The compiled, executable graph. Produced by StateGraph$compile(). Do not
call GraphRunner$new() directly; use StateGraph$compile().
Value
The final WorkflowState object. If the run was paused at an
interrupt point, the returned state reflects the graph at that moment;
call $invoke() again with the same thread_id to resume.
A coro generator yielding
list(node, state_snapshot, iteration).
State snapshot (named list) or NULL.
A data frame with columns agent, provider, model,
input_tokens, output_tokens, cost.
Character string.
Character string.
Invisibly, path.
Methods
Method new()
Initialise the runner. Called internally by StateGraph$compile().
Usage
GraphRunner$new(
nodes,
edges,
conditional_edges,
state_schema,
agents,
checkpointer,
termination,
output_channel = NULL,
interrupt_before = character(),
interrupt_after = character()
)Arguments
nodesNamed list of
list(fn = <function>).edgesList of
list(from, to).conditional_edgesList of
list(from, routing_fn, route_map).state_schemaA WorkflowState object (used as schema template).
agentsNamed list of
Agentobjects.checkpointerA Checkpointer or
NULL.terminationA
termination_conditionorNULL.output_channelCharacter or
NULL. Name of the channel returned byWorkflowState$output()after$invoke().interrupt_beforeCharacter vector of node names to pause before.
interrupt_afterCharacter vector of node names to pause after.
Method invoke()
Execute the graph and return the final state.
Arguments
initial_stateNamed list of initial channel overrides.
configNamed list of run-time configuration:
thread_id: character, identifies this run for checkpointing. Required when the graph hasinterrupt_beforeorinterrupt_afterpoints.max_iterations: integer, cycle guard (default 25).on_step:function(node_name, state)callback after each node (kept for backwards compatibility; preferon_event).on_event:function(event)callback fired around each node.eventis a list with fieldstype("node_start"or"node_end"),node(character),iteration(integer), anddata(a list with fieldupdateson"node_end",NULLon"node_start").verbose: logical, print step info viacli(defaultFALSE).
Method visualize()
Render a visualization of the compiled graph.
Usage
GraphRunner$visualize(engine = c("dot", "visnetwork", "mermaid"))