Skip to content
This repository was archived by the owner on Apr 4, 2026. It is now read-only.

feat(#25): Subordinate delegation loop prevention and depth limits#40

Merged
Nafania merged 2 commits into
mainfrom
feat/25-delegation-loop-prevention
Mar 31, 2026
Merged

feat(#25): Subordinate delegation loop prevention and depth limits#40
Nafania merged 2 commits into
mainfrom
feat/25-delegation-loop-prevention

Conversation

@Nafania
Copy link
Copy Markdown
Owner

@Nafania Nafania commented Mar 31, 2026

Summary

  • Add max_agent_depth to AgentConfig (default: 5) — hard limit on delegation depth
  • Refuse delegation when depth limit reached with clear error message
  • Detect same-profile delegation loops: if same profile delegates to itself 3+ times consecutively, delegation is refused
  • Add depth awareness to agent info prompt (shows current depth, max, remaining levels)
  • Show subordinate status in agent info prompt

Test plan

  • test_refuses_at_max_depth — verifies depth limit enforcement
  • test_allows_under_max_depth — verifies normal delegation works
  • test_refuses_after_3_same_profile_delegations — verifies loop detection
  • test_allows_different_profile — verifies different profiles bypass loop check

Nafania added 2 commits March 31, 2026 18:14
- Add max_agent_depth to AgentConfig (default 5)
- Refuse delegation when depth limit reached
- Detect same-profile delegation loops (streak >= 2)
- Add depth awareness to agent info prompt
- Show subordinate status in agent info

Made-with: Cursor
Mock agents need explicit max_agent_depth=5 on config to avoid
MagicMock vs int comparison errors in depth/loop checks.
Update agent info test assertion to include new prompt parameters.

Made-with: Cursor
@Nafania Nafania merged commit 2cf1423 into main Mar 31, 2026
4 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant