# 循环环环

Canonical URL: https://developers.iagenify.com/zh/sdk/workflows/steps/loop/
Language: zh

`type: "loop"`

重复列表上的一步。最多500个项目,每次最多10个,失败的项目不会阻止其他的项目。

Status: over and body required · 500 items · 10 in parallel

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `over` | string | 必填 | 命名列表的模板 。 |
| `body` | string | 必填 | 步骤的ID重复。 |
| `max` | integer | 100 | 有多少项,1到500项 |
| `concurrency` | integer | 1 | 一次有多少个 1比10 |

```javascript
{ id: "each",   type: "loop", config: {
    over: "{{steps.inbox.output.messages}}", body: "triage", max: 50, concurrency: 4 } }

{ id: "triage", type: "model.generate", config: {
    model: "gemini-3.5-flash",
    inputs: [{ type: "text", content: "Classify: {{item.subject}}" }] } }
```

## 身体没有边缘 {#body}

> **它属于环环,不属于图**
>
> 以身体命名的一步必须没有自己连接,而任何其他环状系统也不能声称它。 这就是保持图单环绕,而重复发生在一步之内的原因。

循环无法重复自己, 也不能重复 `human`, `condition`, `switch`, `merge`, `wait` 或 另一 `loop`.

## 身体看到物品和索引 {#item}

`{{item}}` 和 `{{index}}`,在运行本身的背景之上。

## 默认的货币为 1 {#concurrency}

故意地:以前节省的工作流程应该成本相同,并保持其效果的顺序。 提高工作流程会改变循环需要多长时间以及是否适合,但上限是10,因为超出这一范围,供应商开始拒绝。

## 结果按指数排序 {#results}

```javascript
{{steps.each.output.count}}        // processed
{{steps.each.output.failed}}       // how many failed
{{steps.each.output.total}}        // how many the list held
{{steps.each.output.results}}      // [{ index, ok, output } | { index, ok: false, error }]
```

按指数计算,从来就没有按完成顺序排列——将完成顺序同清单的顺序混为一谈,而顺序取决于时间的输出不能在下游使用。

## 失败无法阻止其余的失败 {#failures}

失败的项目被记录为错误,循环继续。 `failed` 检验后的条件是什么——失去49个项目的工作,因为第五十个项目的畸形,将是错误的交易。

## 超过最大项数的项目 {#truncation}

额外文件没有处理,警告说有多少人到达时,有多少人被处理。

- [mail.read](/zh/sdk/workflows/steps/mail-read): 清单的共同来源。
- [警告](/zh/sdk/workflows/warnings): 包括缺勤
- [工作流步骤](/zh/sdk/workflows/steps): 全部 23 种类型。

```python
{"id": "each", "type": "loop", "config": {
    "over": "{{steps.inbox.output.messages}}", "body": "triage", "max": 50, "concurrency": 4}}

{"id": "triage", "type": "model.generate", "config": {
    "model": "gemini-3.5-flash",
    "inputs": [{"type": "text", "content": "Classify: {{item.subject}}"}]}}
```

```python
"{{steps.each.output.count}}"      # processed
"{{steps.each.output.failed}}"     # how many failed
"{{steps.each.output.total}}"      # how many the list held
"{{steps.each.output.results}}"    # [{"index", "ok", "output"} | {"index", "ok": False, "error"}]
```
