Close the Loop

lesson patterns active patterns/close-the-loop.md View on GitHub

Close the Loop

Rule

Every point where an agent would stop and wait for human input is an opportunity for automation.

Context

When building or improving autonomous agent workflows that currently require human intervention.

Detection

Observable signals that a loop needs closing:

Pattern

Core Principle

Identify every "handoff to human" point in a workflow. For each, ask:

  1. Is it predictable? Does the human always make the same decision given the same inputs?
  2. Is it measurable? Can success/failure be determined programmatically?
  3. Is it low-risk? Would automation failures be recoverable?

If yes to all three, close the loop with automation.

The Pattern

BEFORE (Open Loop):
  Agent → Work → Stop → Human decides → Agent continues → Stop → Human decides → ...

AFTER (Closed Loop):
  Agent → Work → Automated check → Continue/Fix → ... → Human only for judgment calls

Closing Techniques

Human Intervention Automation Approach
"Is the output correct?" Automated validation/testing
"Should this proceed?" Rules + criteria → auto-approve or escalate
"What's wrong?" Parse error messages → auto-fix common issues
"Is this ready?" Checklists → programmatic verification

Implementation Questions

When designing autonomous workflows, ask for each step:

Escalation Threshold

Not all loops should be closed. Escalate to humans when:

Outcome

Following this pattern results in:

Anti-Patterns

Premature escalation: Asking humans before exhausting automated options.

Open loops: Starting work requiring human approval when autonomous completion was possible.

Over-automation: Closing loops on high-stakes decisions that genuinely need human judgment.

Examples

The principle applies broadly. See these lessons for specific implementations:

Quality Gates (Code quality before human review):

Communication Loops (Complete feedback cycles):

Development Workflow (CI/Pre-commit automation):

Session Structure (Autonomous completion):

Related

Match Keywords

reduce human intervention in autonomous workflows make agents more autonomous automate the feedback loop autonomous long-running tasks minimize human touchpoints close the loop feedback loop autonomous operation waiting for human input human bottleneck