Problem
AgentRearrange retries and fallbacks are global — you can't express "retry B three times, and if it still fails, route to C" in the flow itself. Error handling has to live in the caller's try/except, which breaks the declarative model.
Proposed feature
Annotate individual nodes in the flow string with retry and fallback directives:
"A -> B!3 -> C" # B retries up to 3 times
"A -> B!3>D -> C" # B retries 3 times, then falls back to D
"A -> B?D -> C" # B on error routes to D
Design sketch
- Extend the flow parser to recognize
!N (retry count) and >X or ?X (fallback agent).
- Each node becomes a small state machine:
attempt, on exception retry or fallback or raise.
- Fallback agents are resolved from the same
agents list; unknown names fail at parse time.
Files
swarms/structs/agent_rearrange.py
Why
Puts error handling where it belongs — next to the node that can fail — instead of in every caller.
Problem
AgentRearrangeretries and fallbacks are global — you can't express "retry B three times, and if it still fails, route to C" in the flow itself. Error handling has to live in the caller's try/except, which breaks the declarative model.Proposed feature
Annotate individual nodes in the flow string with retry and fallback directives:
Design sketch
!N(retry count) and>Xor?X(fallback agent).attempt, on exceptionretry or fallback or raise.agentslist; unknown names fail at parse time.Files
swarms/structs/agent_rearrange.pyWhy
Puts error handling where it belongs — next to the node that can fail — instead of in every caller.