Multi-Step Pipelines (sequence)
This example demonstrates how to create a sequential pipeline that orchestrates multiple workflows to accomplish a complete automation goal. Weβll build a blog creation pipeline that researches a topic, writes content, and publishes it.
Note: This example uses
create_mock
tools for demonstration purposes to keep the example simple and focused on core workflow concepts. In real-world use cases, you would replace these mock tools with actual tools that perform the specific processing operations your automation requires (such as API calls, data transformations, file operations, or LLM interactions).
Pipeline Configuration
The root pipeline defines the sequence of workflows that execute one after another:
pipelines:
- name: sequence_example
title: "Example 1: Pipeline Sequence"
type: root
workspace: examples
sequence:
- workflow: research_topic # Step 1: Research
- workflow: write_content # Step 2: Write content
- workflow: publish_content # Step 3: Publish
Key Concepts:
- Sequential Execution: Each workflow completes before the next begins
- Root Pipeline: Marked as
type: root
so it can be executed from Loopstack Studio - Workspace Assignment: All workflows inherit the
examples
workspace
Workflow 1: Research Topic
The first workflow uses mock data to simulate topic research:
workflows:
- name: research_topic
title: 'Research'
type: stateMachine
transitions:
- name: research_topic
from: start
to: research_finished
call:
- tool: create_mock # Mock tool for demonstration
arguments:
input: 'AI trends 2025'
output: 'Key AI trends include: agentic AI systems, reasoning models, and AI-powered robotics.'
exportContext: RESEARCH_RESULT # Available to subsequent workflows
- name: show_results
from: research_finished
to: end
call:
- tool: create_chat_message
arguments:
role: 'assistant'
content: ${ context.variables.RESEARCH_RESULT } # Access from context
Key Concepts:
- Mock Tools:
create_mock
simulates tool behavior for testing and examples - exportContext: Makes data available to subsequent workflows in the pipeline sequence
- Context Access: Use
${ context.variables.VARIABLE_NAME }
to access data from context object - Chat Messages:
create_chat_message
displays results in the Studio interface
Workflow 2: Write Content
The second workflow accesses data from the previous workflow and creates content:
workflows:
- name: write_content
title: "Write Content"
type: stateMachine
transitions:
- name: write_content
from: start
to: content_created
call:
- tool: create_mock
arguments:
input: ${ context.variables.RESEARCH_RESULT } # Access from pipeline context
output: |
# Top AI Trends in 2025
Here are the key trends defining this year...
exportContext: CREATED_CONTENT
- name: show_results
from: content_created
to: end
call:
- tool: create_chat_message
arguments:
role: 'assistant'
content: ${ context.variables.CREATED_CONTENT } # Access from context
Key Concepts:
- Context Access: Use
${ context.variables.RESEARCH_RESULT }
to access data from other workflows - Data Flow: Research results flow from the first workflow to inform content creation
- Multi-line Output: Use
|
for multi-line YAML strings in mock tool outputs
Workflow 3: Publish Content
The final workflow publishes the created content:
workflows:
- name: publish_content
title: "Publish"
type: stateMachine
transitions:
- name: publish_content
from: start
to: published
call:
- tool: create_mock
arguments:
input: ${ context.variables.CREATED_CONTENT } # Access content from previous workflow
output: 'Blog post "Top AI Trends in 2025" published successfully to blog.example.com'
as: SUCCESS_MESSAGE # Only available within this workflow
- name: show_results
from: published
to: end
call:
- tool: create_chat_message
arguments:
role: 'assistant'
content: ${ SUCCESS_MESSAGE } # Access local variable
Key Concepts:
- as: Use
${ SUCCESS_MESSAGE }
to transfer data within the same workflow - Local Variables: Variables exported with
as
are only accessible within the current workflow
Data Flow Summary
This example demonstrates the complete data flow pattern in sequential pipelines:
Data Export Patterns:
- exportContext:
RESEARCH_RESULT
β Access as${ context.variables.RESEARCH_RESULT }
- as:
SUCCESS_MESSAGE
β Access as${ SUCCESS_MESSAGE }
(within same workflow only)
Running This Example
This example is already available in Loopstack Studio:
- Navigate to the Studio interface
- Switch to the examples workspace
- Select βExample 1: Pipeline Sequenceβ from the available automations
- Click βStartβ to execute the complete sequence
- Watch each workflow execute in order, displaying results in the chat
Configuration Location: You can also view the complete configuration file at src/config/examples/basic/sequence-example.yaml
Complete Example:
include:
- core/tools/create-mock.yaml
- core/tools/create-chat-message.yaml
pipelines:
- name: sequence_example
title: "Example 1: Pipeline Sequence"
type: root
workspace: examples
sequence:
- workflow: research_topic # Step 1: Research
- workflow: write_content # Step 2: Write content
- workflow: publish_content # Step 3: Publish
workflows:
- name: research_topic
title: 'Research'
type: stateMachine
transitions:
- name: research_topic
from: start
to: research_finished
call:
- tool: create_mock # A mock tool call returning the research result
arguments:
input: 'AI trends 2025'
output: 'Key AI trends include: agentic AI systems, reasoning models, and AI-powered robotics.'
exportContext: RESEARCH_RESULT
- name: show_results
from: research_finished
to: end
call:
- tool: create_chat_message # Display the results in the chat
arguments:
role: 'assistant'
content: ${ context.variables.RESEARCH_RESULT }
- name: write_content
title: "Write Content"
type: stateMachine
transitions:
- name: write_content
from: start
to: content_created
call:
- tool: create_mock # A mock tool call returning the created content
arguments:
input: ${ context.variables.RESEARCH_RESULT }
output: |
# Top AI Trends in 2025
Here are the key trends defining this year...
exportContext: CREATED_CONTENT
- name: show_results
from: content_created
to: end
call:
- tool: create_chat_message # Display the content in the chat
arguments:
role: 'assistant'
content: ${ context.variables.CREATED_CONTENT }
- name: publish_content
title: "Publish"
type: stateMachine
transitions:
- name: publish_content
from: start
to: published
call:
- tool: create_mock # A mock tool call returning a success message
arguments:
input: ${ context.variables.CREATED_CONTENT }
output: 'Blog post "Top AI Trends in 2025" published successfully to blog.example.com'
as: SUCCESS_MESSAGE
- name: show_results
from: published
to: end
call:
- tool: create_chat_message # Display the success message in the chat
arguments:
role: 'assistant'
content: ${ SUCCESS_MESSAGE }