fix: prevent subagent permission bypass via tools field inheritance
Summary
Fixes a security vulnerability where subagents bypassed permission restrictions due to direct tools array inheritance from parent agents.
Problem
Agents with restricted tool access could access parent agent tools they shouldn't have permission to use. The tools field was being spread directly from agent config, bypassing permission evaluation.
Solution
- Exclude
toolsfield from agent config spread to prevent inheritance - Filter tools by agent-specific permission rules in ToolRegistry
- Apply permission filtering in session initialization and prompt construction
Fixes: #7474 Related: #5894, #3808, #7296, #6527
Test Coverage 4 test files with comprehensive coverage validating agents cannot access tools outside their permission scope.
Verified manually to finally fix this issue. I had been stuck on 1.0.200 for few days due to this and having a rather complex multi-sub-agent configuration that relies on permissions guard rails working correctly.