Skip to content

Terminator step

A step that connects previous steps to the END node.

Author

Dimitrij Ray (dimitrij.ray@gdplabs.id)

References

NONE

TerminatorStep(name)

Bases: BasePipelineStep

A step that connects previous steps to the END node.

This step is useful when you want to explicitly terminate a branch or the entire pipeline. It has no processing logic and simply acts as a connection point to the END node.

Example:

pipeline = (
    step_a
    | ConditionalStep(
        name="branch",
        branches={
            "terminate": TerminatorStep("early_end"),
            "continue": step_b
        },
        condition=lambda x: "terminate" if x["should_stop"] else "continue"
    )
    | step_c
)

Attributes:

Name Type Description
name str

A unique identifier for this pipeline step.

Initializes a new pipeline step.

Parameters:

Name Type Description Default
name str

A unique identifier for the pipeline step.

required

add_to_graph(graph, previous_endpoints)

Adds this step to the graph and connects it to the END node.

This method is used by Pipeline to manage the pipeline's execution flow. It should not be called directly by users.

Parameters:

Name Type Description Default
graph StateGraph

The graph to add this step to.

required
previous_endpoints list[str]

The endpoints from previous steps to connect to.

required

Returns:

Type Description
list[str]

list[str]: Empty list as this step has no endpoints (it terminates the flow).

execute(state, config) async

Executes this step, which does nothing but pass through the state.

Parameters:

Name Type Description Default
state dict[str, Any]

The current pipeline state.

required
config RunnableConfig

The runtime configuration.

required