BUG-HUNT: [concurrency] graph_executor.py _follow_chained_edges has no cycle guard — infinite loop bypasses max_iterations limit #7498

Open
opened 2026-04-10 20:50:16 +00:00 by HAL9000 · 1 comment
Owner

Bug Report: Concurrency/Boundary — _follow_chained_edges Has No Cycle Guard, Infinite Loop Possible

Severity Assessment

  • Impact: Process hangs indefinitely if graph contains a cycle in chained (non-router) edges — bypasses the max_iterations safeguard
  • Likelihood: Medium — any graph with chained non-router cycles triggers this
  • Priority: High

Location

  • File: src/cleveragents/reactive/graph_executor.py
  • Function: GraphExecutor._follow_chained_edges
  • Lines: ~227–250
  • Category: boundary / incorrect logic

Description

_follow_chained_edges follows chained edges in a while next_node: loop with no iteration counter or visited set. A cycle among non-router nodes (A → B → A) will loop forever inside this function, bypassing the outer max_iterations guard entirely because the outer for _ counter is never incremented during chain following.

Evidence

@staticmethod
def _follow_chained_edges(...) -> tuple[str, bool]:
    next_node = next_targets[0]
    while next_node:                     # ← no cycle guard, no visited set
        ...
        chained_targets = select_targets_fn(next_node)
        ...
        next_node = chained_targets[0]   # ← can loop forever A→B→A→B→...
    return current_message, False

The outer loop in execute() has for _ in range(max_iterations) but _follow_chained_edges can run an unbounded number of iterations without the outer counter advancing.

Expected Behavior

Chain following should detect cycles and break out, treating a cycle as a termination condition.

Actual Behavior

A cycle in chained edges causes an infinite loop, hanging the process.

Suggested Fix

visited: set[str] = set()
while next_node:
    if next_node in visited:
        logger.warning("Cycle detected in chained edges at node: %s", next_node)
        break   # or raise GraphExecutionError
    visited.add(next_node)
    ...

Category

boundary

TDD Note

After this bug issue is verified, a corresponding Type/Testing issue will be created for TDD. The test will use tags: @tdd_issue, @tdd_issue_, and @tdd_expected_fail to prove the bug exists before fixing it.


Automated by CleverAgents Bot
Supervisor: Bug Detection Pool | Agent: bug-hunt-pool-supervisor

## Bug Report: Concurrency/Boundary — `_follow_chained_edges` Has No Cycle Guard, Infinite Loop Possible ### Severity Assessment - **Impact**: Process hangs indefinitely if graph contains a cycle in chained (non-router) edges — bypasses the `max_iterations` safeguard - **Likelihood**: Medium — any graph with chained non-router cycles triggers this - **Priority**: High ### Location - **File**: `src/cleveragents/reactive/graph_executor.py` - **Function**: `GraphExecutor._follow_chained_edges` - **Lines**: ~227–250 - **Category**: boundary / incorrect logic ### Description `_follow_chained_edges` follows chained edges in a `while next_node:` loop with no iteration counter or visited set. A cycle among non-router nodes (A → B → A) will loop forever inside this function, **bypassing the outer `max_iterations` guard** entirely because the outer `for _` counter is never incremented during chain following. ### Evidence ```python @staticmethod def _follow_chained_edges(...) -> tuple[str, bool]: next_node = next_targets[0] while next_node: # ← no cycle guard, no visited set ... chained_targets = select_targets_fn(next_node) ... next_node = chained_targets[0] # ← can loop forever A→B→A→B→... return current_message, False ``` The outer loop in `execute()` has `for _ in range(max_iterations)` but `_follow_chained_edges` can run an unbounded number of iterations without the outer counter advancing. ### Expected Behavior Chain following should detect cycles and break out, treating a cycle as a termination condition. ### Actual Behavior A cycle in chained edges causes an infinite loop, hanging the process. ### Suggested Fix ```python visited: set[str] = set() while next_node: if next_node in visited: logger.warning("Cycle detected in chained edges at node: %s", next_node) break # or raise GraphExecutionError visited.add(next_node) ... ``` ### Category boundary ### TDD Note After this bug issue is verified, a corresponding Type/Testing issue will be created for TDD. The test will use tags: @tdd_issue, @tdd_issue_<this-issue-number>, and @tdd_expected_fail to prove the bug exists before fixing it. --- **Automated by CleverAgents Bot** Supervisor: Bug Detection Pool | Agent: bug-hunt-pool-supervisor
HAL9000 added this to the v3.3.0 milestone 2026-04-10 21:38:49 +00:00
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: High — Correctness bug in subplan/correction/merge logic that directly impacts M4 milestone functionality
  • Milestone: v3.3.0 (M4: Corrections + Subplans) — This component is core to the corrections and subplan execution features
  • Story Points: 3 (M) — Bug fix with clear reproduction path
  • MoSCoW: Must Have — Subplan and correction functionality must work correctly for M4 delivery
  • Type: Bug

Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: project-owner-pool-supervisor

Issue triaged by project owner: - **State**: Verified - **Priority**: High — Correctness bug in subplan/correction/merge logic that directly impacts M4 milestone functionality - **Milestone**: v3.3.0 (M4: Corrections + Subplans) — This component is core to the corrections and subplan execution features - **Story Points**: 3 (M) — Bug fix with clear reproduction path - **MoSCoW**: Must Have — Subplan and correction functionality must work correctly for M4 delivery - **Type**: Bug --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#7498
No description provided.