Skip to content
Closed
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions docs/docs/Components/agent-blocks-agent-loop.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
title: AgentLoop

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The titles of these pages don't match the spelling used in the screenshot and on the pages. For example AgentLoop vs Agent Loop.

The "no space" versions are also in other places, like AgentLoop parameters.

slug: /agent-blocks-agent-loop
---

import Icon from "@site/src/components/icon";
import PartialParams from '@site/docs/_partial-hidden-params.mdx';

The **Agent Loop** component is a pre-composed component that encapsulates the complete agent loop. It combines the [**While Loop** component](/agent-blocks-while-loop), [**Agent Step** component](/agent-blocks-agent-step), and [**Execute Tool** component](/agent-blocks-execute-tool) into a single, ready-to-use component.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add an explanation or list here about when to use:

  • Individual Agent Blocks components: You want to build a custom agent with extra steps or logic beyond regular tool calls.
  • Agent Loop component: ?
  • Agents component: ?

**Agent Loop** provides a simplified way to create agent workflows without manually assembling individual agent blocks, including built-in loop control, LLM reasoning with tool calling, automatic tool execution, and session memory management.

For more information, see the [Agent blocks quickstart](/agent-blocks-quickstart).

## AgentLoop parameters

<PartialParams />

| Name | Display Name | Type | Description |
|------|--------------|------|-------------|
| llm | Language Model | LanguageModel | Input parameter. The language model for reasoning. |
| tools | Tools | Tool[] | Input parameter. List of tools available to the agent. |
| system_prompt | System Prompt | String | Input parameter. System prompt to guide agent behavior. |
| input_value | Input | Message | Input parameter. Input message from the [**Chat Input** component](/chat-input-and-output). |
| max_iterations | Max Iterations | Integer | Input parameter. Maximum number of iterations. Default: `15`. |
| response | Response | Message | Output parameter. Final response from the agent. |

## See also

* [Agent Blocks](/agent-blocks-quickstart)
* [Agent Step](/agent-blocks-agent-step)
* [Execute Tool](/agent-blocks-execute-tool)
* [While Loop](/agent-blocks-while-loop)
* [Agent component](/components-agents)
41 changes: 41 additions & 0 deletions docs/docs/Components/agent-blocks-agent-step.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
title: AgentStep
slug: /agent-blocks-agent-step
---

import Icon from "@site/src/components/icon";
import PartialParams from '@site/docs/_partial-hidden-params.mdx';

The **Agent Step** component is the reasoning core of an agent workflow. It sends messages to an LLM and routes the response based on whether the LLM requests tool execution or provides a final answer.

**Agent Step** performs the core reasoning step in the agent loop:

1. The **Agent Step** component receives input messages from the [**Chat Input** component](/chat-input-and-output) or [**While Loop** component](/agent-blocks-while-loop).
2. The **Agent Step** component sends messages to the LLM with available tools.
3. Examines the LLM response for `tool_calls`, and then routes to either:
* `tool_calls` output: When the LLM requests tool execution, the message routes to the [**Execute Tool** component](/agent-blocks-execute-tool).
* `ai_message` output: When the LLM provides a final answer, the message routes to the [**Chat Output** component](/chat-input-and-output).

For more information, see the [Agent blocks quickstart](/agent-blocks-quickstart).

## AgentStep parameters

<PartialParams />

| Name | Display Name | Type | Description |
|------|--------------|------|-------------|
| llm | Language Model | LanguageModel | Input parameter. The language model that performs reasoning. |
| tools | Tools | Tool[] | Input parameter. List of tools available to the agent. |
| system_prompt | System Prompt | String | Input parameter. System prompt to guide the agent's behavior. |
| chat_history | Chat Memory | Data[] | Input parameter. Chat history for context-aware responses. |
| input_value | Input | Message | Input parameter. The input message to process. |
| tool_calls | Tool Calls | ToolCall[] | Output parameter. Tool calls requested by the LLM (routes to [**Execute Tool** component](/agent-blocks-execute-tool)). |
| ai_message | AI Message | Message | Output parameter. Final answer from the LLM (routes to [**Chat Output** component](/chat-input-and-output)). |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the quickstart, the outputs are Response and Tool Calls.


## See also

* [Agent Blocks](/agent-blocks-quickstart)
* [Execute Tool](/agent-blocks-execute-tool)
* [While Loop](/agent-blocks-while-loop)
* [Agent Loop](/agent-blocks-agent-loop)
* [Agent component](/components-agents)
30 changes: 30 additions & 0 deletions docs/docs/Components/agent-blocks-execute-tool.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
title: ExecuteTool
slug: /agent-blocks-execute-tool
---

import Icon from "@site/src/components/icon";
import PartialParams from '@site/docs/_partial-hidden-params.mdx';

The **Execute Tool** component executes tool calls from the [**Agent Step** component](/agent-blocks-agent-step) with support for parallel execution and proper error handling.

For more information, see the [Agent blocks quickstart](/agent-blocks-quickstart).

## ExecuteTool parameters

<PartialParams />

| Name | Display Name | Type | Description |
|------|--------------|------|-------------|
| tool_calls | Tool Calls | ToolCall[] | Input parameter. Tool calls to execute from the [**Agent Step** component](/agent-blocks-agent-step). |
| parallel_execution | Parallel Execution | Boolean | Input parameter. Enable parallel execution of multiple tools. Default: `true`. |
| error_handling | Error Handling | Dropdown | Input parameter. Error handling strategy: `raise`, `return_error`, or `skip`. Default: `return_error`. |
| results | Tool Results | Message[] | Output parameter. Results from tool execution, formatted for the agent loop. |

## See also

* [Agent Blocks](/agent-blocks-quickstart)
* [Agent Step](/agent-blocks-agent-step)
* [While Loop](/agent-blocks-while-loop)
* [Agent Loop](/agent-blocks-agent-loop)
* [Agent component](/components-agents)
107 changes: 107 additions & 0 deletions docs/docs/Components/agent-blocks-quickstart.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
---
title: Agent blocks quickstart
slug: /agent-blocks-quickstart
---

import Icon from "@site/src/components/icon";

An agent is fundamentally a while loop.
The while loop accepts input and iterates over the agent's reasoning.
The agent's reasoning sends messages to an LLM and examines the LLM's response to determine where to route the request.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The agent's reasoning sends messages to an LLM and examines the LLM's response to determine where to route the request.
The agent's reasoning sends messages to an LLM, and then it examines the LLM's response to determine where to route the request.

If the LLM's response includes `tool_calls`, the agent sends output to a tool-calling function, and the results are sent back to the while loop to be iterated over again.
If the LLM's response does not include `tool_calls` and the agent determines the task is complete, the agent sends a "finished" message to output.

```
ChatInput → WhileLoop → AgentStep → [Tool Calls] → ExecuteTool → WhileLoop
↓ [AI Message - done]
ChatOutput
```
Comment on lines +14 to +18

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest a mermaid diagram here instead.
You can use the free editor https://mermaid.live/edit

I can't remember if mermaid was already enabled in this repo https://docusaurus.io/docs/next/markdown-features/diagrams


Langflow's [**Agent** component](/components-agents) is composed of this same architecture, and is suitable for most tasks that require a reasoning loop that can choose from a list of registered functions.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Langflow's [**Agent** component](/components-agents) is composed of this same architecture, and is suitable for most tasks that require a reasoning loop that can choose from a list of registered functions.
Langflow's [**Agent** component](/components-agents) uses this architecture, and it is suitable for most tasks that require a reasoning loop that can choose from a list of registered functions.


But what if you want to modify the agent's behavior? For example, how do you include a validation step in your tool outputs before execution?

Use **Agent Blocks** to construct an agent in Langflow's visual builder.
Comment on lines +22 to +24

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
But what if you want to modify the agent's behavior? For example, how do you include a validation step in your tool outputs before execution?
Use **Agent Blocks** to construct an agent in Langflow's visual builder.
If you want to modify the agent's behavior, you can use **Agent Blocks** to construct an agent. For example, you could add a validation step to `tool_calls` outputs.

Agent Blocks are composable primitives that provide the building blocks for constructing each step of custom agent workflows.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Agent Blocks are composable primitives that provide the building blocks for constructing each step of custom agent workflows.
**Agent Blocks** are narrowly scoped components that you can use to create custom agent workflows, instead of using the standalone **Agent** component.

Assemble the blocks to create agents tailored to your exact requirements.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Assemble the blocks to create agents tailored to your exact requirements.
Use **Agent Blocks** with other components to create agents tailored to your exact requirements.

For example, to add a validation step to your agent, insert an [**If-Else** component](/if-else) between the [**Agent Step** component](/agent-blocks-agent-step)'s `tool_calls` output and the [**Execute Tool** component](/agent-blocks-execute-tool) to validate tool names against an allowed list.

This page includes a quickstart for building an agent with Agent Blocks.
For the individual Agent Blocks components, see the Components reference pages.

## Agent Blocks quickstart

This quickstart demonstrates building an agent using Agent Blocks components.
The core agent loop pattern iterates over reasoning and tool execution until completion.
Comment on lines +29 to +35

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This page includes a quickstart for building an agent with Agent Blocks.
For the individual Agent Blocks components, see the Components reference pages.
## Agent Blocks quickstart
This quickstart demonstrates building an agent using Agent Blocks components.
The core agent loop pattern iterates over reasoning and tool execution until completion.
## Use Agent Blocks in a flow
This quickstart demonstrates how to build a custom agent with **Agent Blocks**.
The core agent loop pattern iterates over reasoning and tool execution until completion.


### Prerequisites

- [Install and start Langflow](/get-started-installation)
- Create an [OpenAI API key](https://platform.openai.com/api-keys) or credentials for your preferred LLM provider

### Build the agent loop

The agent loop consists of four main components:
Comment on lines +37 to +44

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Prerequisites
- [Install and start Langflow](/get-started-installation)
- Create an [OpenAI API key](https://platform.openai.com/api-keys) or credentials for your preferred LLM provider
### Build the agent loop
The agent loop consists of four main components:
### Prerequisites
- [Install and start Langflow](/get-started-installation)
- Create an [OpenAI API key](https://platform.openai.com/api-keys) or credentials for your preferred LLM provider
### Build the agent loop
For this example, the agent loop has four components:


* [**While Loop** component](/agent-blocks-while-loop): Controls iteration until the agent completes its task.
* [**Agent Step** component](/agent-blocks-agent-step): The reasoning core that sends messages to the LLM.
* [**Execute Tool** component](/agent-blocks-execute-tool): Executes tool calls when the agent needs to use tools.
* [**Chat Output** component](/chat-input-and-output): Displays the final response.

![Agent Loop flow diagram showing WhileLoop, AgentStep, ExecuteTool, and ChatOutput components connected in a loop pattern](/img/component-agent-blocks.png)

To create an agent with agent blocks, do the following:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To create an agent with agent blocks, do the following:
To recreate this example, do the following:


1. In Langflow, click **New Flow** to create a blank flow.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. In Langflow, click **New Flow** to create a blank flow.
1. In Langflow, click **New Flow**.

2. Add a [**While Loop** component](/agent-blocks-while-loop) from the component library.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it called the component library now?

The **While Loop** component manages conversation state and continues iterating until the agent signals completion.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this description to the list up above.

3. In the **While Loop** component, configure the following fields:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
3. In the **While Loop** component, configure the following fields:
3. Configure the **While Loop** component as follows:

* **Initial State**: Leave this empty, or optionally provide initial conversation history as a DataFrame.
* **Input Value**: Connect this to the [**Chat Input** component](/chat-input-and-output) in a later step.
* **Max Iterations**: Set a limit to prevent infinite loops. For this example, enter `10`.
4. Add an **Agent Step** component to your flow.
5. In the **Agent Step** component, configure the following fields:
* **Language Model**: Select your model provider, such as OpenAI.
* **API Key**: Enter your model provider's API key or a [global variable](/configuration-global-variables).
* **System Message**: Optionally define the agent's behavior with a prompt.

The **Agent Step** component has two outputs:
* **Response** (`ai_message`): This output sends when the model is done, and no tool calls remain.
* **Tool Calls** (`tool_calls`): This output sends when the model wants to execute tools.
Comment on lines +68 to +70

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move the explanation for each output down to the steps where you are connecting those outputs to something.


6. Connect the **While Loop** component's **Loop** output to the **Agent Step** component's **Messages** input.
7. Add an [**Execute Tool** component](/agent-blocks-execute-tool) to your flow.
8. Configure the **Execute Tool** component:
Comment on lines +73 to +74

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all 3 "configure" steps use different wording. i think you could use the same wording for all (Configure the ___ component).

- **Parallel Execution**: Enable to execute multiple tool calls concurrently
- **Timeout**: Set a timeout for individual tool calls (optional)
Comment on lines +75 to +76

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- **Parallel Execution**: Enable to execute multiple tool calls concurrently
- **Timeout**: Set a timeout for individual tool calls (optional)
* **Parallel Execution**: Enable to execute multiple tool calls concurrently.
* **Timeout (Optional)**: Set the timeout for individual tool calls.

9. Connect the **Agent Step** component's **Tool Calls** output to the **Execute Tool** component's **Tool Calls** input.
10. Connect the same tools you connected to the **Agent Step** component to the **Execute Tool** component's **tools** input.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an error here in step 10, I think. There don't seem to be any tools attached previously.


The **Execute Tool** component executes the tool calls and returns the results as a [Message](/data-types#message).

The next steps complete the agent loop by connecting the tool execution results back to the loop, and then routing the final responses to the output.

11. Connect the **Execute Tool** component's **messages** output back to the **While Loop** component's **loop** input.
This creates the iterative loop which sends tool result back into the conversation.
Comment on lines +80 to +85

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The **Execute Tool** component executes the tool calls and returns the results as a [Message](/data-types#message).
The next steps complete the agent loop by connecting the tool execution results back to the loop, and then routing the final responses to the output.
11. Connect the **Execute Tool** component's **messages** output back to the **While Loop** component's **loop** input.
This creates the iterative loop which sends tool result back into the conversation.
11. Connect the **Execute Tool** component's **messages** output back to the **While Loop** component's **loop** input.
The **Execute Tool** component triggers tool functions when requested by the agent, and then it returns the tool results as a `[Message](/data-types#message)`.
Connecting the tool results back to the **While Loop** component creates an iterative loop that feeds the tool results back to the agent's context for further reasoning or chat output.


12. Connect the **Agent Step** component's **Response** output to a **Chat Output** component.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
12. Connect the **Agent Step** component's **Response** output to a **Chat Output** component.
12. Add a **Chat Output** component to the flow, and then connect the **Agent Step** component's **Response** output to the **Chat Output** component.

The Chat output will display the final response when the agent completes its task and no tool calls remain.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The Chat output will display the final response when the agent completes its task and no tool calls remain.
This connection allows the agent to send a response to the chat once the agent determines that no further tool calls are needed and it exits the loop.


### Test the flow

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Test the flow
### Add input and test the flow


To test the flow in the Playground, do the following:

1. Add a **Chat Input** component.
2. Connect the **Chat Input** component to the **While Loop** component's **Input** input.
Comment on lines +94 to +95

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. Add a **Chat Input** component.
2. Connect the **Chat Input** component to the **While Loop** component's **Input** input.
1. Add a **Chat Input** component, and then connect the **Chat Input** component to the **While Loop** component's **Input** input. This feeds user input to the agent to trigger the loop.

3. Click <Icon name="Play" aria-hidden="true" /> **Playground** to test your agent.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
3. Click <Icon name="Play" aria-hidden="true" /> **Playground** to test your agent.
3. Click <Icon name="Play" aria-hidden="true" /> **Playground**.

4. Enter a message that requires tool usage, such as `What is 15 * 7?`, if you've connected a **Calculator** tool.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
4. Enter a message that requires tool usage, such as `What is 15 * 7?`, if you've connected a **Calculator** tool.
4. Enter a message that prompts the agent to use one of the tools you connected.
For example, if you connected a **Calculator** tool, you could ask the agent to solve an equation.

5. The Playground outputs each step of the agent loop as it receives your message, executes tools if required, and then returns a final response.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
5. The Playground outputs each step of the agent loop as it receives your message, executes tools if required, and then returns a final response.
The Playground outputs each step of the agent loop as it processes your message, determines which tools to call, calls the tools, and then returns a final response.


## Agent Blocks components

- [**Agent Step** component](/agent-blocks-agent-step): The reasoning core that sends messages to the LLM and routes based on tool calls.
- [**Execute Tool** component](/agent-blocks-execute-tool): Executes tool calls from the **Agent Step** component, with parallel execution support.
- [**While Loop** component](/agent-blocks-while-loop): Loop control for iterative agent execution.
- [**Agent Loop** component](/agent-blocks-agent-loop): A pre-composed component that encapsulates the complete agent loop.
- [**Shared Context** component](/agent-blocks-shared-context): Share state management across agent iterations.
- [**Think Tool** component](/agent-blocks-think-tool): Think tool support for step-by-step reasoning.
35 changes: 35 additions & 0 deletions docs/docs/Components/agent-blocks-shared-context.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
title: SharedContext
slug: /agent-blocks-shared-context
---

import Icon from "@site/src/components/icon";
import PartialParams from '@site/docs/_partial-hidden-params.mdx';

The **Shared Context** component provides shared state management across agent iterations. It allows you to maintain and update state that persists throughout the agent loop, enabling complex workflows that require accumulating information or tracking progress.

**Shared Context** is used when you need to maintain state across agent iterations:

```
ChatInput → WhileLoop → SharedContext → AgentStep → ExecuteTool → SharedContext → WhileLoop
```

For more information, see the [Agent blocks quickstart](/agent-blocks-quickstart).

## SharedContext parameters

<PartialParams />

| Name | Display Name | Type | Description |
|------|--------------|------|-------------|
| initial_context | Initial Context | Dictionary | Input parameter. Initial state values. Default: `{}`. |
| context_updates | Context Updates | Dictionary | Input parameter. Updates to apply to the context. |
| context | Context | Dictionary | Output parameter. Current shared context state. |
| updated_context | Updated Context | Dictionary | Output parameter. Context after applying updates. |

## See also

* [Agent Blocks](/agent-blocks-quickstart)
* [Agent Step](/agent-blocks-agent-step)
* [While Loop](/agent-blocks-while-loop)
* [Agent Loop](/agent-blocks-agent-loop)
35 changes: 35 additions & 0 deletions docs/docs/Components/agent-blocks-think-tool.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
title: ThinkTool
slug: /agent-blocks-think-tool
---

import Icon from "@site/src/components/icon";
import PartialParams from '@site/docs/_partial-hidden-params.mdx';

The **Think Tool** component provides think tool support for step-by-step reasoning. It enables agents to perform explicit reasoning steps before taking action, improving the quality of tool selection and parameter generation.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first sentence is repetitive and doesn't help explain what it does.


**Think Tool** is typically used as a tool that the [**Agent Step** component](/agent-blocks-agent-step) can call during reasoning:

```
AgentStep → [Think Tool Call] → ThinkTool → [Reasoning Output] → AgentStep

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is adding any value.

```

For more information, see the [Agent blocks quickstart](/agent-blocks-quickstart).

## ThinkTool parameters

<PartialParams />

| Name | Display Name | Type | Description |
|------|--------------|------|-------------|
| reasoning_prompt | Reasoning Prompt | String | Input parameter. The prompt for the reasoning step. |
| reasoning_model | Reasoning Model | LanguageModel | Input parameter. Optional LLM for reasoning (uses the [**Agent Step** component](/agent-blocks-agent-step)'s LLM if not provided). |
| reasoning_output | Reasoning Output | String | Output parameter. The structured reasoning output. |
| toolset | Toolset | Tool | Output parameter. Tool interface for the [**Agent Step** component](/agent-blocks-agent-step) (when Tool Mode is enabled). |

## See also

* [Agent Blocks](/agent-blocks-quickstart)
* [Agent Step](/agent-blocks-agent-step)
* [Execute Tool](/agent-blocks-execute-tool)
* [Configure tools for agents](/agents-tools)
45 changes: 45 additions & 0 deletions docs/docs/Components/agent-blocks-while-loop.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
title: WhileLoop
slug: /agent-blocks-while-loop
---

import Icon from "@site/src/components/icon";
import PartialParams from '@site/docs/_partial-hidden-params.mdx';

The **While Loop** component provides loop control for iterative agent execution. It manages the agent's reasoning loop, continuing iteration until the agent determines the task is complete.

**While Loop** is the control structure that wraps the agent's reasoning loop:

```
ChatInput → WhileLoop → AgentStep → [Tool Calls] → ExecuteTool → WhileLoop
↓ [AI Message - done]
ChatOutput
```

**While Loop** stops iterating when:

* The [**Agent Step** component](/agent-blocks-agent-step) outputs an `ai_message` (final answer) instead of `tool_calls`
* Maximum iterations are reached
* An explicit stop condition is met

For more information, see the [Agent blocks quickstart](/agent-blocks-quickstart).

## WhileLoop parameters

<PartialParams />

| Name | Display Name | Type | Description |
|------|--------------|------|-------------|
| input_value | Input | Message | Input parameter. Initial input or input from previous iteration. |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of code font in the tables and paragraphs isn't consistent. tool_calls is in code font elsewhere, but not on the table, and 15 is in code font in the table but nothing else.

| max_iterations | Max Iterations | Integer | Input parameter. Maximum number of iterations allowed. Default: `15`. |
| iteration | Iteration | Integer | Output parameter. Current iteration count. |
| output | Output | Message | Output parameter. Output from the current iteration (routes to the [**Agent Step** component](/agent-blocks-agent-step)). |
| done | Done | Message | Output parameter. Final result when loop completes. |
Comment on lines +35 to +37

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the quickstart, you can only see 2 outputs. I think I would omit iteration if it's not actually visible to the user, or mention that it's not typically used except for debugging or something.

For Output, the description sounds like it is automatically routed to Agent Step no matter what, but I think you have to attach it in your flow, like you showed in the quickstart?

I would also suggest explaining what to do with Done. Users might think they have to attach Done to something, but it's the Agent Step that decides when the loop is done?


## See also

* [Agent Blocks](/agent-blocks-quickstart)
* [Agent Step](/agent-blocks-agent-step)
* [Execute Tool](/agent-blocks-execute-tool)
* [Agent Loop](/agent-blocks-agent-loop)
* [Loop component](/loop)
Comment on lines +39 to +45

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure you want to include this on all of these pages. It will be a maintenance chore.

5 changes: 5 additions & 0 deletions docs/docs/Support/release-notes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ For all changes, see the [Changelog](https://github.com/langflow-ai/langflow/rel

### New features and enhancements

- Agent blocks

Use **Agent Blocks** to build custom agents with control over iteration, tool calls, and persistent memory.
For more information, see the [Agent Blocks quickstart](/agent-blocks-quickstart).

- Mustache templating support for Prompt Template component

The **Prompt Template** component now supports Mustache templating syntax.
Expand Down
13 changes: 13 additions & 0 deletions docs/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,19 @@ module.exports = {
label: "Bundles",
items: [
"Components/components-bundles",
{

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strange this is under bundles instead of core 🤷🏻‍♀️

type: "category",
label: "Agent Blocks",

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agent blocks

items: [
"Components/agent-blocks-quickstart",
"Components/agent-blocks-agent-loop",
"Components/agent-blocks-agent-step",
"Components/agent-blocks-execute-tool",
"Components/agent-blocks-shared-context",
"Components/agent-blocks-think-tool",
"Components/agent-blocks-while-loop",
]
},
"Components/bundles-aiml",
"Components/bundles-altk",
"Components/bundles-amazon",
Expand Down
Binary file added docs/static/img/component-agent-blocks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading