Skip to content

Implement loop prevention (depth limits, dedup, circuit breakers, ancestry) #17

@Aureliolo

Description

@Aureliolo

Context

Implement all 5 loop prevention mechanisms from spec section 5.5. Delegation loops are a critical failure mode in multi-agent systems where agents can endlessly delegate tasks back and forth, consuming resources and never completing work.

Acceptance Criteria

Five Prevention Mechanisms

  • Max delegation depth — default limit of 5 levels; configurable
  • Rate limiting — max 10 delegations per agent pair per minute; configurable
  • Identical request dedup — reject duplicate requests within a 60-second window
  • Circuit breaker — after 3 bounces between same agents, trigger 5-minute cooldown
  • Task ancestry tracking — prevent delegation to any agent in the current task's ancestor chain

On Loop Detection

  • Block the delegation attempt
  • Notify the sending agent with a clear error message
  • Escalate to manager or human-in-the-loop
  • Log the loop detection event with full context

Configuration & Testing

  • All thresholds configurable via `LoopPreventionConfig` model
  • Clear, actionable error messages on detection
  • Escalation pathway works end-to-end
  • Unit tests for each of the 5 mechanisms individually
  • Integration test that creates a would-be loop and verifies prevention

Dependencies

Design Spec Reference

  • Section 5.5 — Loop Prevention

Metadata

Metadata

Assignees

No one assigned

    Labels

    prio:criticalBlocks other work, must do firstscope:medium1-3 days of workspec:agent-systemDESIGN_SPEC Section 3 - Agent Systemspec:communicationDESIGN_SPEC Section 5 - Communication Architecturespec:task-workflowDESIGN_SPEC Section 6 - Task & Workflow Enginetype:featureNew feature implementation

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions