Terminator step
A step that connects previous steps to the END node.
References
NONE
TerminatorStep(name, retry_config=None, error_handler=None, cache_store=None, cache_config=None)
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. |
retry_policy |
RetryPolicy | None
|
Configuration for retry behavior using LangGraph's RetryPolicy. |
add_to_graph(graph, previous_endpoints, retry_policy=None)
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 |
retry_policy
|
RetryPolicy | None
|
Configuration for retry behavior using LangGraph's RetryPolicy. If None, the retry policy of the step is used. If the step is not a retryable step, this parameter is ignored. |
None
|
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: Empty list as this step has no endpoints (it terminates the flow). |
execute(state, runtime, config=None)
async
Executes this step, which does nothing but pass through the state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
PipelineState
|
The current pipeline state. |
required |
runtime
|
Runtime[dict[str, Any] | BaseModel]
|
The runtime information. |
required |
config
|
RunnableConfig | None
|
The runnable configuration. Defaults to None. |
None
|