agent-zero icon indicating copy to clipboard operation
agent-zero copied to clipboard

feat: Improve subordinate delegation with loop prevention and depth limits

Open TerminallyLazy opened this issue 2 months ago • 1 comments

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_depth parameter (default: 5) with hard validation in call_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 guidance
  • prompts/agent.extras.agent_info.md: Added depth tracking placeholders

Code

  • agent.py: Added max_agent_depth: int = 5 to AgentConfig
  • python/tools/call_subordinate.py: Added depth limit validation and same-profile warning
  • python/extensions/message_loop_prompts_after/_70_include_agent_info.py: Added depth calculation and dynamic warnings

TerminallyLazy avatar Oct 20 '25 19:10 TerminallyLazy

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

gjadams avatar Oct 23 '25 04:10 gjadams