-
-
Drag and Drop
-
- Click on a connection tag and drag it into input fields of destination blocks. A dropdown will appear showing available values.
-
-
-
-
-
Angle Bracket Syntax
-
- Type <> in input fields to see a dropdown of available connection values from previous blocks.
-
-
+
+
-## Connection Data Structure
-
-When you connect blocks, the output data structure from the source block determines what values are available in the destination block:
-
-
-
- ```json
- {
- "content": "The generated text response",
- "model": "gpt-4",
- "tokens": {
- "prompt": 120,
- "completion": 85,
- "total": 205
- },
- "toolCalls": [...]
- }
- ```
-
-
- ```json
- {
- "status": 200,
- "body": { ... },
- "headers": { ... },
- "error": null
- }
- ```
-
-
- ```json
- {
- "result": "Function return value",
- "stdout": "Console output",
- "executionTime": 45
- }
- ```
-
-
-
-## Accessing Nested Data
-
-You can access nested properties from connected blocks using dot notation:
-
-
-
-
-
-
-
-
-## Dynamic References
-
-Connection references are evaluated at runtime, allowing for dynamic data flow through your workflow:
-
-```javascript
-// In a Function block, you can access connected data
-const userName = input.userBlock.name;
-const orderTotal = input.apiBlock.body.order.total;
-
-// Process the data
-const discount = orderTotal > 100 ? 0.1 : 0;
-const finalPrice = orderTotal * (1 - discount);
-
-// Return the result
-return {
- userName,
- originalTotal: orderTotal,
- discount: discount * 100 + '%',
- finalPrice
-};
-```
-
## Connection Types
-Sim Studio supports different types of connections based on the blocks being connected:
+Sim Studio supports different types of connections that enable various workflow patterns:
-
-
-
Data Connections
-
- Pass data between blocks for processing or transformation
-
-
-
-
-
Control Connections
-
- Determine execution flow based on conditions or routing decisions
-
-
-
-
-
Feedback Connections
-
- Create loops by connecting later blocks back to earlier ones
-
-
-
-
-## Best Practices
-
-### Organize Your Connections
-
-Keep your workflow clean and understandable by organizing connections logically:
-
-- Minimize crossing connections when possible
-- Group related blocks together
-- Use consistent flow direction (typically left-to-right or top-to-bottom)
-
-### Validate Data Flow
-
-Ensure that the data being passed between blocks is compatible:
-
-- Check that required fields are available in the source block
-- Verify data types match expectations
-- Use Function blocks to transform data when necessary
-
-### Document Connection Purpose
-
-Add comments or descriptions to clarify the purpose of connections, especially in complex workflows:
-
-- What data is being passed
-- Why this connection exists
-- Any transformations or conditions applied to the data
-
-### Test Connection References
-
-Verify that connection references work as expected:
-
-- Test with different input values
-- Check edge cases (empty values, large datasets)
-- Ensure error handling for missing or invalid data
+
+
+ Learn how connections work and how to create them in your workflows
+
+
+ Understand how to use connection tags to reference data between blocks
+
+
+ Explore the output data structures of different block types
+
+
+ Learn techniques for accessing and manipulating connected data
+
+
+ Follow recommended patterns for effective connection management
+
+
diff --git a/docs/content/docs/connections/meta.json b/docs/content/docs/connections/meta.json
new file mode 100644
index 000000000..eb4351176
--- /dev/null
+++ b/docs/content/docs/connections/meta.json
@@ -0,0 +1,4 @@
+{
+ "title": "Connections",
+ "pages": ["basics", "tags", "data-structure", "accessing-data", "best-practices"]
+}
\ No newline at end of file
diff --git a/docs/content/docs/connections/tags.mdx b/docs/content/docs/connections/tags.mdx
new file mode 100644
index 000000000..2ab7daf09
--- /dev/null
+++ b/docs/content/docs/connections/tags.mdx
@@ -0,0 +1,111 @@
+---
+title: Connection Tags
+description: Using connection tags to reference data between blocks
+---
+
+import { Callout } from 'fumadocs-ui/components/callout'
+
+## Connection Tags
+
+Connection tags are visual representations of the data available from connected blocks. They provide an easy way to reference outputs from previous blocks in your workflow.
+
+
+
+
+
+### What Are Connection Tags?
+
+Connection tags are interactive elements that appear when blocks are connected. They represent the data that can flow from one block to another and allow you to:
+
+- Visualize available data from source blocks
+- Reference specific data fields in destination blocks
+- Create dynamic data flows between blocks
+
+
+ Connection tags make it easy to see what data is available from previous blocks and use it in your current block without having to remember complex data structures.
+
+
+## Using Connection Tags
+
+There are two primary ways to use connection tags in your workflows:
+
+
+
+
Drag and Drop
+
+ Click on a connection tag and drag it into input fields of destination blocks. A dropdown will appear showing available values.
+
+
+ - Hover over a connection tag to see available data
+ - Click and drag the tag to an input field
+ - Select the specific data field from the dropdown
+ - The reference is inserted automatically
+
+
+
+
+
Angle Bracket Syntax
+
+ Type <> in input fields to see a dropdown of available connection values from previous blocks.
+
+
+ - Click in any input field where you want to use connected data
+ - Type
<> to trigger the connection dropdown
+ - Browse and select the data you want to reference
+ - Continue typing or select from the dropdown to complete the reference
+
+
+
+
+## Tag Syntax
+
+Connection tags use a simple syntax to reference data:
+
+```
+
+```
+
+Where:
+- `blockId` is the identifier of the source block
+- `path.to.data` is the path to the specific data field
+
+For example:
+- `` - References the content field from a block with ID "agent1"
+- `` - References the name of the first user in the users array from the data field of a block with ID "api2"
+
+## Dynamic Tag References
+
+Connection tags are evaluated at runtime, which means:
+
+1. They always reference the most current data
+2. They can be used in expressions and combined with static text
+3. They can be nested within other data structures
+
+### Examples
+
+```javascript
+// Reference in text
+"The user's name is "
+
+// Reference in JSON
+{
+ "userName": "",
+ "orderTotal":
+}
+
+// Reference in code
+const greeting = "Hello, !";
+const total = * 1.1; // Add 10% tax
+```
+
+
+ When using connection tags in numeric contexts, make sure the referenced data is actually a number to avoid type conversion issues.
+
\ No newline at end of file
diff --git a/docs/content/docs/execution/advanced.mdx b/docs/content/docs/execution/advanced.mdx
new file mode 100644
index 000000000..4095124d8
--- /dev/null
+++ b/docs/content/docs/execution/advanced.mdx
@@ -0,0 +1,289 @@
+---
+title: Advanced Execution Features
+description: Master advanced execution capabilities in Sim Studio
+---
+
+import { Callout } from 'fumadocs-ui/components/callout'
+import { Tabs, Tab } from 'fumadocs-ui/components/tabs'
+import { Accordion, Accordions } from 'fumadocs-ui/components/accordion'
+
+# Advanced Execution Features
+
+Sim Studio provides several advanced features that give you more control over workflow execution, error handling, and performance optimization.
+
+## Error Handling
+
+The execution engine includes built-in error handling mechanisms to make your workflows more robust:
+
+### Block-Level Error Handling
+
+Errors in one block don't necessarily stop the entire workflow execution:
+
+```javascript
+// Example of error handling in a Function block
+try {
+ // Potentially risky operation
+ const result = JSON.parse(input.apiBlock.data);
+ return { success: true, data: result };
+} catch (error) {
+ // Handle the error gracefully
+ console.error("Failed to parse JSON:", error.message);
+ return {
+ success: false,
+ error: error.message,
+ fallbackData: { status: "error", message: "Could not process data" }
+ };
+}
+```
+
+### Error Logging
+
+Comprehensive error information is captured in the execution logs:
+
+- **Error Messages**: Clear descriptions of what went wrong
+- **Stack Traces**: Detailed information about where errors occurred
+- **Context Data**: The inputs that led to the error
+- **Timestamps**: When the error occurred
+
+
+ Error logs are invaluable for debugging workflows. Always check the logs first when troubleshooting execution issues.
+
+
+### Fallback Mechanisms
+
+For certain operations, the system provides automatic fallbacks:
+
+- **Function Execution**: WebContainer execution first, then VM execution if needed
+- **API Requests**: Automatic retries for transient network errors
+- **Model Calls**: Fallback to alternative models if primary model is unavailable
+
+### Recovery Options
+
+Configure blocks to handle failures gracefully:
+
+- **Retry Logic**: Automatically retry failed operations
+- **Default Values**: Provide fallback values when operations fail
+- **Alternative Paths**: Use conditional blocks to create error handling paths
+- **Graceful Degradation**: Continue execution with partial results
+
+## Environment Variables
+
+Environment variables provide a secure way to store and access configuration values:
+
+### Types of Environment Variables
+
+
+
+ Store API credentials securely:
+
+ ```
+ OPENAI_API_KEY=sk-...
+ ANTHROPIC_API_KEY=sk-...
+ GOOGLE_API_KEY=AIza...
+ ```
+
+ These are automatically available to blocks that need them, without hardcoding sensitive values in your workflow.
+
+
+
+ Manage environment-specific configuration:
+
+ ```
+ MAX_RETRIES=3
+ DEFAULT_MODEL=gpt-4o
+ LOG_LEVEL=info
+ BASE_URL=https://api.example.com
+ ```
+
+ These values can be referenced in blocks to control behavior without modifying the workflow itself.
+
+
+
+ Store sensitive information securely:
+
+ ```
+ DATABASE_PASSWORD=...
+ JWT_SECRET=...
+ ENCRYPTION_KEY=...
+ ```
+
+ These values are encrypted at rest and only decrypted during execution, providing an extra layer of security.
+
+
+
+### Using Environment Variables
+
+Environment variables can be accessed in different ways depending on the block type:
+
+```javascript
+// In Function blocks
+const apiKey = process.env.MY_API_KEY;
+const maxRetries = parseInt(process.env.MAX_RETRIES || "3");
+
+// In API blocks (via connection tags)
+// URL: https://api.example.com?key=
+
+// In Agent blocks (via connection tags)
+// System prompt: Use the model for this task.
+```
+
+
+ Never hardcode sensitive information like API keys directly in your workflows. Always use environment variables instead.
+
+
+## Real-Time Monitoring
+
+Sim Studio provides powerful real-time monitoring capabilities:
+
+
+
+ The currently executing block is highlighted in the workflow editor, making it easy to follow the execution flow in real-time. This visual indicator helps you understand exactly where in your workflow the execution is currently happening.
+
+
+
+ Execution logs appear in real-time in the logs panel on the right side. These logs include detailed information about each block's execution, including inputs, outputs, execution time, and any errors that occur. You can use these logs to debug your workflow and understand how data flows between blocks.
+
+
+
+ Each block's state (pending, executing, completed, or error) is visually indicated in the workflow editor. This helps you quickly identify which blocks have executed successfully and which may have encountered issues.
+
+
+
+ Detailed timing information shows how long each block takes to execute, helping you identify performance bottlenecks in your workflow. The execution engine tracks start time, end time, and total duration for both individual blocks and the entire workflow.
+
+
+
+## Performance Optimization
+
+Optimize your workflows for better performance:
+
+### Block Optimization
+
+- **Break Down Complex Blocks**: Split complex operations into multiple simpler blocks
+- **Minimize External Calls**: Batch API requests where possible
+- **Cache Results**: Use Memory blocks to store and reuse results
+- **Optimize Function Code**: Write efficient JavaScript/TypeScript code
+
+### Data Flow Optimization
+
+- **Filter Data Early**: Process only the data you need as early as possible
+- **Minimize Data Transfer**: Pass only necessary fields between blocks
+- **Use Appropriate Data Structures**: Choose efficient data structures for your use case
+- **Avoid Redundant Computations**: Don't recalculate values that haven't changed
+
+### Execution Configuration
+
+- **Set Appropriate Timeouts**: Configure timeouts based on expected execution time
+- **Limit Parallel Executions**: Control how many workflows can run simultaneously
+- **Schedule During Off-Peak Hours**: Run resource-intensive workflows when system load is lower
+- **Monitor Resource Usage**: Keep an eye on memory and CPU usage
+
+
+ Performance optimization is especially important for workflows that run frequently or process large amounts of data.
+
+
+## Advanced Execution Context
+
+The execution context maintains detailed information about the workflow execution:
+
+```javascript
+// Example of execution context structure (simplified)
+{
+ // Block states indexed by block ID
+ blockStates: {
+ "block-1": { output: { content: "..." }, status: "completed" },
+ "block-2": { output: { data: { ... } }, status: "completed" },
+ "block-3": { status: "pending" }
+ },
+
+ // Active execution path
+ activeExecutionPath: Set(["block-1", "block-2", "block-5"]),
+
+ // Routing decisions
+ decisions: {
+ router: Map(["router-1" => "block-5"]),
+ condition: Map(["condition-1" => "condition-true"])
+ },
+
+ // Loop iterations
+ loopIterations: Map(["loop-1" => 2]),
+
+ // Environment variables
+ env: { "API_KEY": "...", "MAX_RETRIES": "3" },
+
+ // Execution logs
+ logs: [
+ { blockId: "block-1", timestamp: "...", status: "completed", duration: 120 },
+ { blockId: "block-2", timestamp: "...", status: "completed", duration: 85 }
+ ]
+}
+```
+
+This context is used internally by the execution engine but understanding its structure can help you debug complex workflows.
+
+## Debugging Techniques
+
+Advanced techniques for debugging workflow execution:
+
+### Console Logging
+
+Add strategic console.log statements in Function blocks:
+
+```javascript
+console.log("Input to processData:", JSON.stringify(input, null, 2));
+console.log("Processing step 1 complete:", intermediateResult);
+console.log("Final result:", finalResult);
+```
+
+### State Inspection
+
+Use Function blocks to inspect the current state:
+
+```javascript
+function debugState() {
+ // Log all inputs
+ console.log("All inputs:", input);
+
+ // Return a debug object with relevant information
+ return {
+ debug: true,
+ inputSummary: {
+ hasUserData: !!input.userBlock,
+ apiStatus: input.apiBlock?.status,
+ itemCount: input.dataBlock?.items?.length || 0
+ },
+ timestamp: new Date().toISOString()
+ };
+}
+```
+
+### Execution Tracing
+
+Enable detailed execution tracing for complex workflows:
+
+1. Add a Memory block to accumulate trace information
+2. Add trace logging in key Function blocks
+3. Review the trace after execution to understand the flow
+
+### Performance Profiling
+
+Identify performance bottlenecks:
+
+```javascript
+function profileOperation() {
+ const start = performance.now();
+
+ // Perform the operation
+ const result = performExpensiveOperation();
+
+ const end = performance.now();
+ console.log(`Operation took ${end - start}ms`);
+
+ return {
+ result,
+ executionTime: end - start
+ };
+}
+```
+
+By mastering these advanced execution features, you can create more robust, efficient, and sophisticated workflows in Sim Studio.
\ No newline at end of file
diff --git a/docs/content/docs/execution/basics.mdx b/docs/content/docs/execution/basics.mdx
new file mode 100644
index 000000000..edc8e17eb
--- /dev/null
+++ b/docs/content/docs/execution/basics.mdx
@@ -0,0 +1,173 @@
+---
+title: Execution Basics
+description: Understanding the fundamental execution flow in Sim Studio
+---
+
+import { Step, Steps } from 'fumadocs-ui/components/steps'
+import { Tabs, Tab } from 'fumadocs-ui/components/tabs'
+import { Files, Folder, File } from 'fumadocs-ui/components/files'
+import { Callout } from 'fumadocs-ui/components/callout'
+import { AgentIcon, ApiIcon, ConditionalIcon, CodeIcon, ChartBarIcon, ConnectIcon } from '@/components/icons'
+
+# Execution Basics
+
+When you run a workflow in Sim Studio, the execution engine follows a systematic process to ensure blocks are executed in the correct order and data flows properly between them.
+
+## Execution Flow
+
+The execution of a workflow follows these key steps:
+
+
+
+ ### Validation
+ Before execution begins, the workflow is validated to ensure it has:
+ - An enabled starter block with no incoming connections
+ - Properly connected blocks with valid configurations
+ - No circular dependencies (except in intentional loops)
+ - Valid input and output types between connected blocks
+
+
+
+ ### Initialization
+ The execution context is created, which includes:
+ - Environment variables for the workflow
+ - Input values from the starter block
+ - Initial state for all blocks
+ - Execution path tracking
+ - Loop iteration counters
+
+
+
+ ### Block Execution
+ Blocks are executed in topological order (based on dependencies):
+ - The system identifies which blocks can be executed next
+ - Inputs for each block are resolved from previous block outputs
+ - Each block is executed by its specialized handler
+ - Outputs are stored in the execution context
+
+
+
+ ### Path Determination
+ As execution progresses, the system determines which paths to follow:
+ - Router and conditional blocks make decisions about execution paths
+ - Only blocks on active paths are executed
+ - The path tracker maintains the current execution state
+
+
+
+ ### Result Collection
+ After all blocks have executed:
+ - Final outputs are collected
+ - Execution logs are compiled
+ - Performance metrics are calculated
+ - Results are presented in the UI
+
+
+
+## Block Types and Execution
+
+Different block types have different execution behaviors:
+
+
+
+
+ Orchestration blocks control the flow of execution through your workflow.
+
+
+ } annotation="Initiates workflow execution and provides initial input values. Every workflow must have exactly one starter block." />
+ } annotation="Directs execution along specific paths based on dynamic decisions. Uses an AI model to select one of multiple possible paths." />
+ } annotation="Executes different paths based on conditional logic. Evaluates JavaScript expressions to determine which path to follow." />
+
+
+
+
+
+
+ Processing blocks transform data and generate new outputs.
+
+
+ } annotation="Interacts with AI models to generate content. Executes prompts against various LLM providers." />
+ } annotation="Executes custom JavaScript/TypeScript code. Runs in a secure sandbox environment with access to connected block outputs." />
+ } annotation="Assesses outputs against defined criteria. Uses AI to evaluate content based on custom metrics." />
+
+
+
+
+
+
+ Integration blocks connect with external systems.
+
+
+ } annotation="Makes HTTP requests to external services. Configurable with headers, body, and authentication." />
+ } annotation="Specialized blocks for specific services (Gmail, Slack, GitHub, etc.). Each has its own execution logic for the specific service." />
+
+
+
+
+
+## Execution Methods
+
+Sim Studio offers multiple ways to trigger workflow execution:
+
+### Manual Execution
+
+Run workflows on-demand through the Sim Studio interface by clicking the "Run" button. This is perfect for:
+- Testing during development
+- One-off tasks
+- Workflows that need human supervision
+
+### Scheduled Execution
+
+Configure workflows to run automatically on a specified schedule:
+- Set up recurring executions using cron expressions
+- Define start times and frequency
+- Configure timezone settings
+- Set minimum and maximum execution intervals
+
+### API Endpoints
+
+Each workflow can be exposed as an API endpoint:
+- Get a unique URL for your workflow
+- Configure authentication requirements
+- Send custom inputs via POST requests
+- Receive execution results as JSON responses
+
+### Webhooks
+
+Configure workflows to execute in response to external events:
+- Set up webhook triggers from third-party services
+- Process incoming webhook data as workflow input
+- Configure webhook security settings
+- Support for specialized webhooks (GitHub, Stripe, etc.)
+
+
+ The execution method you choose depends on your workflow's purpose. Manual execution is great for development, while scheduled execution, API endpoints, and webhooks are better for production use cases.
+
+
+## Execution Context
+
+Each workflow execution maintains a detailed context that includes:
+
+- **Block States**: Outputs and execution status of each block
+- **Execution Path**: The active path through the workflow
+- **Routing Decisions**: Records of which paths were selected
+- **Environment Variables**: Configuration values for the workflow
+- **Execution Logs**: Detailed records of each step in the execution
+
+This context is maintained throughout the execution and is used to:
+- Resolve inputs for blocks
+- Determine which blocks to execute next
+- Track the progress of execution
+- Provide debugging information
+- Store intermediate results
+
+## Real-Time Execution Monitoring
+
+As your workflow executes, you can monitor its progress in real-time:
+
+- **Active Block Highlighting**: The currently executing block is highlighted
+- **Live Logs**: Execution logs appear in real-time in the logs panel
+- **Block States**: Visual indicators show each block's execution state
+- **Performance Metrics**: Timing information for each block's execution
+
+These monitoring features help you understand how your workflow is executing and identify any issues that arise.
\ No newline at end of file
diff --git a/docs/content/docs/execution/index.mdx b/docs/content/docs/execution/index.mdx
index 2a5e18f13..8b3700506 100644
--- a/docs/content/docs/execution/index.mdx
+++ b/docs/content/docs/execution/index.mdx
@@ -1,6 +1,6 @@
---
title: Execution
-description: Sim Studio provides a powerful execution engine that brings your workflows to life. Understanding how execution works will help you design more effective workflows and troubleshoot any issues that arise..
+description: Understand how workflows are executed in Sim Studio
---
import { Card, Cards } from 'fumadocs-ui/components/card'
@@ -9,6 +9,53 @@ import { Step, Steps } from 'fumadocs-ui/components/steps'
import { Accordion, Accordions } from 'fumadocs-ui/components/accordion'
import { Tab, Tabs } from 'fumadocs-ui/components/tabs'
import { AgentIcon, ApiIcon, ConditionalIcon, CodeIcon, ChartBarIcon, ConnectIcon, GmailIcon, PerplexityIcon, NotionIcon, ExaAIIcon, FirecrawlIcon, SlackIcon } from '@/components/icons'
+import { Callout } from 'fumadocs-ui/components/callout'
+
+# Workflow Execution
+
+Sim Studio provides a powerful execution engine that brings your workflows to life. Understanding how execution works will help you design more effective workflows and troubleshoot any issues that arise.
+
+
+
+
+
+
+ The execution engine handles everything from block execution order to data flow, error handling, and loop management. It ensures your workflows run efficiently and predictably.
+
+
+## Execution Documentation
+
+
+
+ Learn about the fundamental execution flow, block types, and how data flows through your workflow
+
+
+
+ Master the powerful loop functionality to create iterative processes and feedback mechanisms
+
+
+
+ Discover advanced capabilities like error handling, environment variables, and performance optimization
+
+
+
+## Key Execution Concepts
+
+- **Topological Execution** - Blocks are executed in dependency order, ensuring data flows correctly
+- **Path Tracking** - The system tracks active execution paths based on routing decisions
+- **Loop Management** - Sophisticated loop handling allows for iterative processing with safeguards
+- **Real-time Monitoring** - Watch your workflow execute with detailed logs and visual indicators
+- **Error Handling** - Robust error management keeps your workflows resilient
+
+Whether you're building simple automations or complex AI workflows, understanding execution is key to creating effective solutions in Sim Studio.
## Execution Flow
diff --git a/docs/content/docs/execution/loops.mdx b/docs/content/docs/execution/loops.mdx
new file mode 100644
index 000000000..638dfc332
--- /dev/null
+++ b/docs/content/docs/execution/loops.mdx
@@ -0,0 +1,219 @@
+---
+title: Loops
+description: Creating iterative processes with loops in Sim Studio
+---
+
+import { Callout } from 'fumadocs-ui/components/callout'
+import { Steps, Step } from 'fumadocs-ui/components/steps'
+import { Tabs, Tab } from 'fumadocs-ui/components/tabs'
+
+# Loops
+
+Loops are a powerful feature in Sim Studio that allow you to create iterative processes, implement feedback mechanisms, and build more sophisticated workflows.
+
+
+
+
+
+## What Are Loops?
+
+Loops in Sim Studio allow a group of blocks to execute repeatedly, with each iteration building on the results of the previous one. This enables:
+
+- **Iterative Refinement**: Progressively improve outputs through multiple passes
+- **Batch Processing**: Process collections of items one at a time
+- **Feedback Mechanisms**: Create systems that learn from their own outputs
+- **Conditional Processing**: Continue execution until specific criteria are met
+
+
+ Loops are particularly powerful for AI workflows, allowing you to implement techniques like chain-of-thought reasoning, recursive refinement, and multi-step problem solving.
+
+
+## Creating Loops
+
+To create a loop in your workflow:
+
+
+
+ Select Blocks: Choose the blocks you want to include in the loop
+
+
+ Create Loop: Use the "Create Loop" option in the editor
+
+
+ Configure Loop Settings: Set iteration limits and conditions
+
+
+ Create Feedback Connections: Connect outputs from later blocks back to earlier blocks
+
+
+
+## Loop Configuration
+
+When configuring a loop, you can set several important parameters:
+
+### Iteration Limits
+
+- **Maximum Iterations**: The maximum number of times the loop can execute (default: 5)
+- **Minimum Iterations**: The minimum number of times the loop must execute before checking conditions
+
+
+ Always set a reasonable maximum iteration limit to prevent infinite loops. The default limit of 5 iterations is a good starting point for most workflows.
+
+
+### Loop Conditions
+
+Loops can continue based on different types of conditions:
+
+
+
+ Use a Condition block to determine whether the loop should continue:
+
+ ```javascript
+ // Example condition in a Condition block
+ function shouldContinueLoop() {
+ // Get the current score from an evaluator block
+ const score = input.evaluatorBlock.score;
+
+ // Continue looping if score is below threshold
+ return score < 0.8;
+ }
+ ```
+
+ The loop will continue executing as long as the condition returns true and the maximum iteration limit hasn't been reached.
+
+
+
+ Use a Function block to implement complex loop conditions:
+
+ ```javascript
+ // Example condition in a Function block
+ function processAndCheckContinuation() {
+ // Process data from previous blocks
+ const currentResult = input.agentBlock.content;
+ const previousResults = input.memoryBlock.results || [];
+
+ // Store results for comparison
+ const allResults = [...previousResults, currentResult];
+
+ // Check if we've converged (results not changing significantly)
+ const shouldContinue = previousResults.length === 0 ||
+ currentResult !== previousResults[previousResults.length - 1];
+
+ return {
+ results: allResults,
+ shouldContinue: shouldContinue
+ };
+ }
+ ```
+
+ Connect this Function block's output to a Condition block to control the loop.
+
+
+
+ Execute the loop for a fixed number of iterations:
+
+ ```
+ // Set in loop configuration
+ Minimum Iterations: 3
+ Maximum Iterations: 3
+ ```
+
+ This will run the loop exactly 3 times, regardless of any conditions.
+
+
+
+## Loop Execution
+
+When a workflow with loops executes, the loop manager handles the iteration process:
+
+1. **First Pass**: All blocks in the loop execute normally
+2. **Iteration Check**: The system checks if another iteration should occur
+3. **State Reset**: If continuing, block states within the loop are reset
+4. **Next Iteration**: The loop blocks execute again with updated inputs
+5. **Termination**: The loop stops when either:
+ - The maximum iteration count is reached
+ - A loop condition evaluates to false (after minimum iterations)
+
+## Loop Use Cases
+
+Loops enable powerful workflow patterns:
+
+### Iterative Refinement
+
+
+
Example: Content Refinement
+
+ Create a loop where an Agent block generates content, an Evaluator block assesses it, and a Function block decides whether to continue refining.
+
+
+ - Agent generates initial content
+ - Evaluator scores the content
+ - Function analyzes score and provides feedback
+ - Loop back to Agent with feedback for improvement
+ - Continue until quality threshold is reached
+
+
+
+### Batch Processing
+
+
+
Example: Data Processing Pipeline
+
+ Process a collection of items one at a time through a series of blocks.
+
+
+ - Function block extracts the next item from a collection
+ - Processing blocks operate on the single item
+ - Results are accumulated in a Memory block
+ - Loop continues until all items are processed
+
+
+
+### Recursive Problem Solving
+
+
+
Example: Multi-step Reasoning
+
+ Implement a recursive approach to complex problem solving.
+
+
+ - Agent analyzes the current problem state
+ - Function block implements a step in the solution
+ - Condition block checks if the problem is solved
+ - Loop continues until solution is found or maximum steps reached
+
+
+
+## Best Practices for Loops
+
+To use loops effectively in your workflows:
+
+- **Set Appropriate Limits**: Always configure reasonable iteration limits
+- **Use Memory Blocks**: Store state between iterations with Memory blocks
+- **Include Exit Conditions**: Define clear conditions for when loops should terminate
+- **Monitor Performance**: Watch for performance impacts with many iterations
+- **Test Thoroughly**: Verify that loops terminate as expected in all scenarios
+
+
+ Loops with many blocks or complex operations can impact performance. Consider optimizing individual blocks if your loops need many iterations.
+
+
+## Loop Debugging
+
+When debugging loops in your workflows:
+
+- **Check Iteration Counts**: Verify the loop is executing the expected number of times
+- **Inspect Block Inputs/Outputs**: Look at how data changes between iterations
+- **Review Loop Conditions**: Ensure conditions are evaluating as expected
+- **Use Console Logging**: Add console.log statements in Function blocks to track loop progress
+- **Monitor Memory Usage**: Watch for growing data structures that might cause performance issues
+
+By mastering loops, you can create much more sophisticated and powerful workflows in Sim Studio.
\ No newline at end of file
diff --git a/docs/content/docs/execution/meta.json b/docs/content/docs/execution/meta.json
new file mode 100644
index 000000000..4d3a531c3
--- /dev/null
+++ b/docs/content/docs/execution/meta.json
@@ -0,0 +1,4 @@
+{
+ "title": "Execution",
+ "pages": ["basics", "loops", "advanced"]
+}
\ No newline at end of file
diff --git a/docs/public/connections.gif b/docs/public/connections.gif
deleted file mode 100644
index fb8acbaf7..000000000
Binary files a/docs/public/connections.gif and /dev/null differ
diff --git a/docs/public/connections.mp4 b/docs/public/connections.mp4
new file mode 100644
index 000000000..ffd51a95f
Binary files /dev/null and b/docs/public/connections.mp4 differ
diff --git a/docs/public/loops.mp4 b/docs/public/loops.mp4
new file mode 100644
index 000000000..e6341a98e
Binary files /dev/null and b/docs/public/loops.mp4 differ