How do you stop a workflow from looping endlessly on model output?
Why B is the answer
Add stopping conditions in Step Functions
Stopping conditions in Step Functions end a workflow that would otherwise loop on model output.
In detail
- Stopping conditions are enforced by the workflow.
- Choose what happens when the limit is reached.
Use case
An illustrative scenario, not a real incident.
A rewriting loop repeats forever. A Step Functions limit stops it after three tries and sends it to a person.
See it in different ways
flowchart TD
A["Reason"] --> B["Act with a tool"]
B --> C["Observe the result"]
C --> D{"Done or limit reached?"}
D -->|No| A
D -->|Yes| E["Finish or hand to a person"]stateDiagram-v2 [*] --> Prepare Prepare --> ModelCall ModelCall --> Decide Decide --> ModelCall: retry, within the limit Decide --> HumanReview: high value Decide --> Finish: approved HumanReview --> Finish Finish --> [*]
flowchart TD
Q{"Has it reached the limit?"}
Q -->|"No"| A0["Run again"]
Q -->|"Yes"| A1["Stop and escalate"]Key point: Workflows need stopping conditions.
Why the other options are wrong
- A. Raise the maximum output length so that each turn can do more work
- That makes each turn longer.
- C. Add a second model that reviews the output on each loop of the workflow
- A reviewer adds cost and does not stop the loop.
- D. Ask the model in the prompt to stop when it believes it has finished
- The model may never stop.

