Skip to main content
Discussion runs N agents in turn on a shared thread until a criterion is met — round-robin by default, with an optional stop condition.
The user hands in a draft; the two agents take turns refining it until they agree.

Quick Start

1

Two agents, two rounds

Turn order: ['critic', 'author', 'critic', 'author'] — two full passes.
2

Add an early stop

The loop exits as soon as any turn returns text containing AGREED.

How It Works


API Reference

Discussion

Parameters

Result Variables

The transcript lands on the run result’s variables (i.e. result.get("variables") from flow.run(...)) — not on flow.variables, which stays the declared initial state a second run would start from.

Common Patterns

Round-robin debate

Default behavior — position i in round r runs agents[i], no selector needed.

Custom speaker selection

Set select= to choose the next speaker per turn. The signature is (turn_index, context) -> agent.

Early stop with until=

Stop as soon as a consensus keyword appears in the latest turn.

Using the transcript downstream

Follow the discussion with a summarizer whose prompt references {{discussion_transcript}}.

Refusals / Guardrails

Discussion is opinionated — it fails loudly rather than quietly wasting spend.

Stop Propagation

A speaker with on_error="stop" (the Task default) halts the entire enclosing workflow, not just the discussion — later steps do not run. This mirrors route(), loop(), repeat(), parallel(), and if_(). See Workflow Error Handling.

Nesting

Discussion is a first-class workflow step and runs correctly inside loop, parallel, route, if_, and repeat.
See Nested Workflows.

Discussion vs. Repeat vs. AgentTeam


Best Practices

Start at 2–3; every additional round is a full pass over every speaker.
A critic + an author debate is more useful than two agents with identical instructions.
A keyword like AGREED is more reliable than string-similarity heuristics.
A summarizer that receives only previous_result sees just the final turn.

Workflow Patterns

Overview of routing, parallel, loop, and repeat

Workflow Repeat

Repeat a single step until a condition is met

Workflow Loop

Iterate over lists and files

Workflow Error Handling

How stop propagates through nested patterns

Nested Workflows

Compose Discussion inside loop, parallel, route, and repeat