Problem It Solves
Closes gap: #168
When a reviewer sends code back to the coder, the state file records the regression but tracks no iteration count, no loop history, and no maximum. A coder→reviewer→coder loop can spin indefinitely, accumulating cost and time with no automatic escalation.
Proposed Behavior
The workflow engine tracks re-entry counts per step in the state file. A loop_limit field in SKILL.md (or config.yaml as a default) sets the maximum number of times a step can be re-entered before automatic escalation:
# config.yaml
workflows:
loop_limits:
default: 3 # escalate to human after 3 re-entries of any step
coder: 2 # coders get fewer retries before escalation
When a step exceeds its loop limit:
- The engine emits a
loop_limit_exceeded metrics event
- The workflow transitions to a
blocked state with reason: "Step N (coder) has been re-entered 3 times. Human review required before continuing."
teamwork next surfaces the blocked workflow prominently with the loop history
Loop history (timestamps, reasons for re-entry, handoff summaries per iteration) is stored in the state file and displayed by teamwork history.
Dependencies
Complexity Estimate
Medium — 3–4 files: state schema loop counter, engine loop detection, config schema extension, CLI display, tests
Problem It Solves
Closes gap: #168
When a reviewer sends code back to the coder, the state file records the regression but tracks no iteration count, no loop history, and no maximum. A coder→reviewer→coder loop can spin indefinitely, accumulating cost and time with no automatic escalation.
Proposed Behavior
The workflow engine tracks re-entry counts per step in the state file. A
loop_limitfield in SKILL.md (orconfig.yamlas a default) sets the maximum number of times a step can be re-entered before automatic escalation:When a step exceeds its loop limit:
loop_limit_exceededmetrics eventblockedstate with reason: "Step N (coder) has been re-entered 3 times. Human review required before continuing."teamwork nextsurfaces the blocked workflow prominently with the loop historyLoop history (timestamps, reasons for re-entry, handoff summaries per iteration) is stored in the state file and displayed by
teamwork history.Dependencies
Complexity Estimate
Medium — 3–4 files: state schema loop counter, engine loop detection, config schema extension, CLI display, tests