Sobmit Docs

Iterate node

Iterate node card

The Iterate node runs an until-loop of language-model turns. A number of parties (distinct roles — often two agents) take alternating turns, each seeing the full conversation so far. After every turn an optional stop condition is checked; when it matches, the loop ends early. Otherwise it runs until the round cap is reached.

Use it for anything that converges through repeated passes: two agents debating toward an agreement, a writer + critic refining a draft, or several drafts of a piece being improved until one meets a bar.

Handles

HandlePurpose
TopicThe starting point (the topic, task or spec)
ResultThe converged result: { final, transcript, … }

Configuration

  • Model — the language model that runs once per turn.
  • Parties — how many distinct roles take turns (2–4).
  • Instructions — the shared goal for every party, describing what a converged result looks like (supports {…} templates).
  • Party instructions (optional) — one system prompt per party; a party without its own row uses the shared instructions. This is how you give two agents different roles (e.g. “proposer” vs “critic”).
  • Max rounds — the safety cap. Each round is one turn per party.
  • Temperature (optional) — sampling temperature for every turn.
  • Early stop (optional) — a condition checked after every turn (path, operator and value). Leave the path empty to test the turn’s text directly.

Where the conversation lives

Every turn is re-fed as the next party’s prompt — a model has no memory between calls, so the node rebuilds the conversation from the seed (the incoming payload) plus the transcript of all turns so far, and hands the full thing to each party in turn. No state is lost between parties.

Example — two agents agree on a plan

A Prompt node feeds the topic into Topic. The Iterate node is configured:

parties:     2
instructions: "Discuss the topic and converge on a single concrete plan.
              Keep each turn short."
party 1:     "You are the proposer: draft and defend a plan."
party 2:     "You are the critic: find weaknesses and demand a better one."
max rounds:  3
early stop:  path empty · op contains · value "AGREED"

The Result handle emits:

{
  "final": "The agreed plan is …",
  "transcript": [
    { "party": 0, "text": "Draft …" },
    { "party": 1, "text": "Weakness: …" },
    { "party": 0, "text": "Revised … AGREED" }
  ],
  "rounds": 2,
  "stopped": true
}

Wire Result into a Table Generation node, an Agent or an Output — reference {payload.final} to hand just the converged answer downstream.

Notes

  • One durable step — turns run in order, not in parallel, so re-runs are deterministic and every call is billed separately.
  • The stop condition is evaluated after every turn; a match ends the loop immediately (stopped: true).
  • A failed turn stops the loop and reports the error.
  • The transcript lets you inspect the whole conversation in the run log.

Related

  • Agent — the single-turn equivalent of one party.
  • For-each — loop over an array of items, not a conversation until a condition holds.
  • Router — a one-shot branch instead of a loop.