Workflow Basic Template
The Workflow Basic template demonstrates the simplest linear workflow you can build with BindAI. It introduces the core concepts of the workflow engine by defining a workflow containing nodes that execute sequentially. This template is the recommended starting point for understanding how BindAI workflows are created, executed, and extended. Once the basic execution model is understood, additional workflow features such as conditions, loops, parallel execution, retries, timeout protection, human tasks, and scheduling can be introduced.Purpose
This template demonstrates how to:- Create a workflow
- Add workflow nodes
- Establish the starting node
- Execute nodes sequentially
- Share variables through the workflow context
- Produce a
WorkflowResult - Observe workflow execution through workflow events
Workflow Structure
A basic workflow consists of workflow nodes connected through theirnext_nodes.
Conceptually:
StartNode or EndNode objects for a basic workflow.
Instead, the first node added to a Workflow automatically becomes its starting node.
For example:
start_node if no start node has been configured yet.
The nodes themselves determine the next execution path through their next_nodes relationships.
Creating a Workflow
A workflow can be created with an optional name:idversionnamenodesstart_nodeagentsexecutor
Adding Nodes
Nodes are added to the workflow with:next_nodes configuration.
Execution Flow
A basic workflow execution follows this general sequence:Running a Workflow
A workflow can be executed with:Workflow.run() creates a new ExecutionContext.
A context can also be supplied explicitly:
Workflow Context
Each workflow instance has an execution context. The context contains execution state used by the workflow runtime. Variables are particularly important for sharing data between nodes. Conceptually:Workflow Result
A successful workflow execution returns aWorkflowResult.
The current executor returns the workflow context variables as the result output:
Node Execution
The executor processes one node at a time from the workflow execution queue. The general flow is:Workflow Events
The workflow executor emits workflow events during execution. Important events include:Execution State
The workflow runtime maintains execution state in the workflow instance context. Important execution information includes:- Current execution queue
- Variables
- Completion state
- Waiting state
- Errors
- Retry attempt
- Timeout policy
- Retry policy
- Execution timestamps
- Events
In-Memory Storage
The currentWorkflow implementation creates a WorkflowExecutor using a MemoryWorkflowStore.
The executor also uses a MemoryHistoryStore by default.
Conceptually:
Execution History
The executor records workflow execution history after completion or failure. A history entry contains information such as:- Workflow ID
- Workflow version
- Instance ID
- Start time
- Finish time
- Success state
- Error information when execution fails
Failure Handling
If a node raises an exception and no retry policy is configured, the workflow fails. Conceptually:workflow.failed event is emitted.
The resulting WorkflowResult contains:
Retry
A workflow can use a retry policy for node failures. The executor checks the configured retry policy when a node raises an exception. For example:max_attempts to control the number of attempts.
The configured delay_seconds and exponential_backoff values are not currently applied.
Therefore, retries currently occur immediately.
Retry behavior is covered in more detail by:
08.6 workflow-retry.md
Timeout
The workflow executor can check a configured timeout policy during execution. The timeout is evaluated before each node is executed. Conceptually:08.7 workflow-timeout.md
Waiting and Resuming
Some workflow nodes can place the workflow into a waiting state. When the executor encounters a waiting state, it can return the current workflow result instead of continuing normal execution. A paused workflow can later be resumed through:08.5 workflow-human.md
Cloning a Workflow
A workflow can be cloned with:Basic Example
A minimal workflow follows this general structure:- What work is performed
- What variables are written
- Which nodes execute next
- Whether execution waits
- Whether execution succeeds or fails
WorkflowExecutor.
When to Use
Use the Workflow Basic pattern when you want to:- Learn how BindAI workflows execute
- Build a simple linear workflow
- Test workflow nodes
- Prototype workflow logic
- Understand workflow context and variables
- Build a foundation for more advanced workflows
Extending the Workflow
Once the basic execution model is understood, additional workflow features can be introduced. For example:- Human tasks
- Retry policies
- Timeout policies
- Scheduling
- Subworkflows
- Workflow events
Best Practices
When building a basic workflow:- Start with a small number of nodes.
- Give nodes clear identifiers.
- Explicitly define node relationships.
- Keep shared state in the workflow context when appropriate.
- Handle node failures deliberately.
- Test both successful and failing execution paths.
- Use retry policies only for recoverable failures.
- Use timeout policies for workflows that require execution limits.
- Treat the default in-memory stores as development-oriented storage.
- Add observability when workflows become more complex.
Current Implementation Boundaries
The basic workflow runtime currently has several important boundaries.No special Start Node
The workflow does not require a built-inStartNode.
The first node added to the workflow becomes the starting node.
No special End Node
The workflow does not require a built-inEndNode.
Execution completes when the execution queue is exhausted or another terminal execution condition occurs.
In-memory persistence
The default workflow and history stores are in memory. They do not provide durable distributed workflow persistence.Retry delay
Retry configuration exposes delay and exponential-backoff fields, but the current executor does not apply them.Timeout interruption
Timeout checking happens between node executions. It does not forcibly terminate a currently running node.Related Templates
The Workflow Basic template introduces the core execution model used throughout the workflow templates. The remaining templates build on these concepts:08.2 workflow-condition.md08.3 workflow-loop.md08.4 workflow-parallel.md08.5 workflow-human.md08.6 workflow-retry.md08.7 workflow-timeout.md08.8 workflow-schedule.md
Summary
The Workflow Basic template demonstrates the fundamental BindAI workflow execution model. A workflow:WorkflowResult.
This basic model provides the foundation for conditions, loops, parallel execution, human tasks, retries, timeout protection, and other workflow capabilities.