-
Notifications
You must be signed in to change notification settings - Fork 596
Support nested sub agents #262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
JoshuaC215
merged 10 commits into
JoshuaC215:main
from
aperkins1310:feature/hierarchical-sub-agents
Sep 3, 2025
Merged
Support nested sub agents #262
JoshuaC215
merged 10 commits into
JoshuaC215:main
from
aperkins1310:feature/hierarchical-sub-agents
Sep 3, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Enhanced service.py to handle sub-agent message filtering - Added langgraph_supervisor_hierarchy_agent.py with 3-layer hierarchy example - Added comprehensive test for hierarchical agent message flow - Updated test fixtures for better import handling This builds on upstream's basic subgraph support (2e6c622) by adding: - Sophisticated node detection for supervisors and sub-agents - Proper message handling for handback tools and results - Support for nested agent hierarchies with proper naming conventions
Enhanced Streamlit UI to properly display nested agent hierarchies: - Different visual indicators for sub-agents (💼) vs tools (🛠️) - Recursive handling of nested sub-agent transfers - Proper status container management for multi-level hierarchies - Support for transfer_back_to handoff messages - Expanded status containers for better visibility - Updated tests to match new UI labels This complements the service layer changes by providing a clear visual representation of complex agent hierarchies in the UI.
Added test fixtures and test cases to validate: - Multi-agent message fixtures for reusable test data - Hierarchical sub-agent UI rendering with proper status containers - Visual indicators (💼 for sub-agents, 🛠️ for tools) - Popover functionality for tool calls within sub-agents - Proper message flow through transfer_to/transfer_back_to patterns These tests ensure the UI correctly displays complex agent hierarchies with proper visual organization and user experience.
Added three critical test patterns for hierarchical sub-agents: 1. test_app_streaming_single_sub_agent: - Tests single sub-agent with multiple tool calls - Validates popover functionality for tools within sub-agents - Ensures proper status container organization 2. test_app_streaming_sequential_sub_agents: - Tests supervisor -> agent A -> supervisor -> agent C -> supervisor flow - Validates sequential agent handoffs with proper UI separation - Ensures multiple status containers are handled correctly 3. test_app_streaming_nested_sub_agents: - Tests true nesting: supervisor -> agent A -> agent B -> agent A -> supervisor - Validates recursive status container nesting - Ensures proper visual hierarchy for deeply nested agents These tests provide comprehensive coverage of all hierarchical patterns and ensure the UI correctly handles complex multi-agent workflows.
I’m traveling the next few days but will take a look at this next week, thanks! |
Codecov Report✅ All modified and coverable lines are covered by tests.
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
This is awesome!! Thank you @aperkins1310 !!! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Firstly thanks, this project is super helpful and so I've made a bunch of changes that I'll submit back to upstream to try give back a bit.
The first of which is this, supporting more complex hierarchies of agents. Such as:


This is the existing "supervisor + 2 siblings" 2-layer system:
A few bits of note:
STOP
even for tool calls. An explicit handback message makes this work across all models. Also included tests.supervisor
,research_expert
andmath_expert
. Now the only requirement is supervisor graphs containsupervisor
, and sub agents containsub-agent
in their names. Thelanggraph_supervisor_hierarchy_agent
shows how to handle the "middle" layers, which are both supervisors and sub agents. Included tests for the service behaviour.memory/__init__.py