agent-zero
agent-zero copied to clipboard
feat: Improve subordinate delegation with loop prevention and depth limits
Summary
Improvement to the agent delegation system to prevent infinite loops and over-delegation:
- Decision Framework: Added 3-question evaluation system (Subtask Boundary Check, Context Efficiency Check, Specialization Check) with 2-of-3 rule for delegation decisions
- Depth Limiting: Configurable
max_agent_depthparameter (default: 5) with hard validation incall_subordinate - Loop Prevention: Same-profile delegation warning system to detect and log potential loop scenarios
- Enhanced Awareness: Agents display their delegation depth, remaining levels, and receive warnings when near limits or as subordinates
Changes
Prompts
prompts/agent.system.tool.call_sub.md: Complete rewrite with decision framework, anti-patterns, and profile selection guidanceprompts/agent.extras.agent_info.md: Added depth tracking placeholders
Code
agent.py: Addedmax_agent_depth: int = 5to AgentConfigpython/tools/call_subordinate.py: Added depth limit validation and same-profile warningpython/extensions/message_loop_prompts_after/_70_include_agent_info.py: Added depth calculation and dynamic warnings
I like it, Nice, looks to address a long-time existing issue with more than just prompt engineering. might be nice to have the settings.json parameter versus hard coded, but that is just a thought. Glad someone engineered a nicely constructed answer to this using agent config and numerical controls. thank you