Source: user_feedback/08-add-per-step-visit-limit-to-bound-loops-user-story.txt
User story
As a workflow author running agent review loops, I want to declare a maximum number of times a given step can be visited in a single run, so that runaway loops fail fast and cleanly instead of exhausting the global step budget or running indefinitely.
Background
The only current loop guard is max_total_steps in the policy block, which is a global budget shared across all steps. It cannot distinguish a setup step from a tight review loop, and setting it low enough to bound the loop also risks cutting off legitimate long workstreams.
Acceptance criteria
- max_visits is an optional integer field on any step block (0 or omitted means unlimited).
- When a step visit count exceeds max_visits, the run transitions to failed with a clear error message.
- The engine tracks visit counts per step per run, not per attempt (retries count toward the limit).
- Compile-time warning if a step is reachable from its own outcome graph and no max_visits is set and max_total_steps is over a configurable threshold.
- Existing max_total_steps behavior is unchanged.
- Unit tests cover visit limit hit on loop step, not hit, and omitted limit behavior.
Source: user_feedback/08-add-per-step-visit-limit-to-bound-loops-user-story.txt
User story
As a workflow author running agent review loops, I want to declare a maximum number of times a given step can be visited in a single run, so that runaway loops fail fast and cleanly instead of exhausting the global step budget or running indefinitely.
Background
The only current loop guard is max_total_steps in the policy block, which is a global budget shared across all steps. It cannot distinguish a setup step from a tight review loop, and setting it low enough to bound the loop also risks cutting off legitimate long workstreams.
Acceptance criteria