> For the complete documentation index, see [llms.txt](https://whitepaper.aitech.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://whitepaper.aitech.io/agentforge/connections/basics.md).

# basics

When you run a workflow in Agent Forge, the execution engine follows a systematic process to ensure blocks are executed in the correct order with proper data flow.

### Execution Flow

The execution engine runs workflows in layers, processing blocks based on their dependencies:

{% stepper %}
{% step %}

### Validation

Ensures the workflow has a starter block with no incoming connections and all blocks are properly connected.
{% endstep %}

{% step %}

### Layer-based Execution

Identifies which blocks can execute next based on completed dependencies and executes them in parallel.
{% endstep %}

{% step %}

### Path Updates

Router and Condition blocks update the active execution path, determining which blocks execute next.
{% endstep %}

{% step %}

### Iteration Processing

Loop and Parallel blocks manage iterations and create virtual instances for concurrent execution.
{% endstep %}

{% step %}

### Result Collection

Outputs from the final blocks are collected and returned as the workflow result.
{% endstep %}
{% endstepper %}

### Block Types and Execution

Different block types have different execution behaviors:

{% tabs %}
{% tab title="Orchestration Blocks" %}
Orchestration blocks control the flow of execution through your workflow.

* **Starter Block**: Initiates workflow execution and provides initial input values. Every workflow must have exactly one starter block.
* **Router Block**: Directs execution along specific paths based on dynamic decisions. Uses an AI model to select one of multiple possible paths.
* **Condition Block**: Executes different paths based on conditional logic. Evaluates JavaScript expressions to determine which path to follow.
* **Loop Block**: Executes blocks repeatedly for a fixed number of iterations or over a collection. Manages iteration state and provides access to current item.
* **Parallel Block**: Executes blocks concurrently across multiple instances. Distributes work based on count or collection for faster processing.
  {% endtab %}

{% tab title="Processing Blocks" %}
Processing blocks transform data and generate new outputs.

* **Agent Block**: Interacts with AI models to generate content. Executes prompts against various LLM providers.
* **Function Block**: Executes custom JavaScript/TypeScript code. Runs in a secure sandbox environment with access to connected block outputs.
* **Evaluator Block**: Assesses outputs against defined criteria. Uses AI to evaluate content based on custom metrics.
* **Workflow Block**: Execute nested workflows as a single block. Allows modular workflow design by embedding one workflow inside another.
  {% endtab %}

{% tab title="Integration Blocks" %}
Integration blocks connect with external systems.

* **API Block**: Makes HTTP requests to external services. Configurable with headers, body, and authentication.
* **Knowledge Base Block**: Search and interact with knowledge bases. Performs semantic search, retrieves documents, and manages knowledge data.
* **Response Block**: Format and return responses from workflows. Configure response data, status codes, and headers.
* **Tool Blocks**: Specialized blocks for specific services (Gmail, Slack, GitHub, etc.). Each has its own execution logic for the specific service.
  {% endtab %}
  {% endtabs %}

### Execution Methods

Agent Forge offers multiple ways to trigger workflow execution:

#### Manual Execution

Run workflows on-demand through the Agent Forge 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

**Viewing Deployed APIs**

Monitor your deployed workflow APIs and their current state:

This shows how to view the deployed state and compare with the original deployed API configuration.

#### 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.)

{% hint style="info" %}
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.
{% endhint %}

### Execution Context

Each workflow execution maintains a context that tracks:

* **Block States**: Outputs and execution status of each block
* **Execution Path**: Active blocks based on routing decisions
* **Loop/Parallel State**: Current iterations and distribution items
* **Environment Variables**: Configuration values available during execution
* **Execution Logs**: Detailed records of each block's execution

### Real-Time Monitoring

Monitor your workflow execution in real-time:

* **Active Block Highlighting**: Currently executing blocks pulse with animation
* **Live Logs**: Execution logs appear instantly in the logs panel
* **Block States**: Visual indicators show success, error, or pending states
* **Performance Metrics**: Execution time for each block

These monitoring features help you understand workflow behavior and quickly identify any issues.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://whitepaper.aitech.io/agentforge/connections/basics.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
