Summary
Formally support repeating agents in the flow pattern (e.g., agent1 -> agent2 -> agent1) to enable iterative refinement workflows.
Background
The duplicate agent check in validate_flow() is already commented out (agent_rearrange.py lines 330-333):
# # If the length of the agents does not equal the length of the agents in flow
# if len(set(agents_in_flow)) != len(agents_in_flow):
# raise ValueError(
# "Duplicate agent names in the flow are not allowed."
# )
This suggests the feature was considered but not fully implemented. Agent repetition is valuable for patterns like:
- Iterative refinement:
writer -> reviewer -> writer (revise based on feedback)
- Multi-pass analysis:
researcher -> analyst -> researcher -> analyst
- Self-correction:
coder -> tester -> coder
What needs to happen
-
Ensure conversation context is correct — When an agent appears a second time, it should see its own prior output plus the intermediate agent's feedback, not just re-process the same input.
-
Update team awareness — _get_sequential_awareness() currently finds the first occurrence of an agent name. It should be position-aware so agent1 at step 1 knows it leads to agent2, while agent1 at step 3 knows it follows reviewer.
-
Response dict handling — response_dict[agent_name] = result (line 686) overwrites prior results from the same agent. Use a list or indexed key (e.g., agent1_1, agent1_2).
-
Document the pattern — Add examples to the docstring and docs showing iterative refinement flows.
Acceptance criteria
Summary
Formally support repeating agents in the flow pattern (e.g.,
agent1 -> agent2 -> agent1) to enable iterative refinement workflows.Background
The duplicate agent check in
validate_flow()is already commented out (agent_rearrange.py lines 330-333):This suggests the feature was considered but not fully implemented. Agent repetition is valuable for patterns like:
writer -> reviewer -> writer(revise based on feedback)researcher -> analyst -> researcher -> analystcoder -> tester -> coderWhat needs to happen
Ensure conversation context is correct — When an agent appears a second time, it should see its own prior output plus the intermediate agent's feedback, not just re-process the same input.
Update team awareness —
_get_sequential_awareness()currently finds the first occurrence of an agent name. It should be position-aware soagent1at step 1 knows it leads toagent2, whileagent1at step 3 knows it followsreviewer.Response dict handling —
response_dict[agent_name] = result(line 686) overwrites prior results from the same agent. Use a list or indexed key (e.g.,agent1_1,agent1_2).Document the pattern — Add examples to the docstring and docs showing iterative refinement flows.
Acceptance criteria
agent1 -> agent2 -> agent1execute without error